Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / November 2007



Tip: Looking for answers? Try searching our database.

attributeCollection support for CFX tags

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Arun Nallan - 22 Nov 2007 15:34 GMT
We recently went with an upgrade from Version: 7,0,0,91690 to Version:
8,0,0,176276 on our dev box!

ColdFusion 8 release notes says that if we get this error in the CodeAnalyzer,
we can ignore it. However, we are getting this error even while running the
application live.

ColdFusion Code dynamically builds the attributes necessary for the CFX called
CFX_SayHello, using a structure and finally calls the custam tag using the
following code:

<cfx_SayHello attributeCollection="#atts#" />

  We get the below error. Can I get some help from anybody who has any idea of
what might be causing this or a workaround?

The error reads as follows:

[b]The attributeCollection attribute cannot be used in combination with other
attributes in the cfx tag.[/b]

 The above tag call works if all attributes are sent separately in the below
fashion.

  <cfx_SayHello att1="abc" att2="bcd" />

  However, we need to use dynamic attributes for accomplishing our business
requirements. Also, it is a good methodology as the attributes vary in each
scenario when the tag is called. All our apps work fine except this. If we are
not able to fix this, we are planning to rollback our upgrade back to CF 7.

  Any workaround for this? I tried looping over the attribute collection
structure and generating a string that contains the tag call with all
attributes listed separately; thereby, using evaluate() function to evaluate
the string with tag call dynamically. However, this is failing. Is there any
other way or is Adobe working on a fix for CF 8? I can provide any other
details if needed.

The stack trace contains the follows:

coldfusion.compiler.validation.ArgumentsAttributeException: The
attributeCollection attribute cannot be used in combination with other
attributes in the cfx tag.
at coldfusion.compiler.TagNode.validateArgsAttr(TagNode.java:423)
at coldfusion.compiler.SemanticAnalyzer.cftag(SemanticAnalyzer.java:476)
at coldfusion.compiler.SemanticAnalyzer.transform(SemanticAnalyzer.java:104)
at coldfusion.compiler.Treewalker.postorder(Treewalker.java:86).. (truncated)

Thanks,
Arun

<title>Test Case</title>

    <p>This code demonstrates the inability of Coldfusion to send<br/>
    dynamic attributes (using attributeCollection) to a CFX tag.</p>
   
    <!--- <cfx_SayHello att1="abc" att2="bcd" />
        The CFX call above works. The below mentioned call fails.
    --->
   
    <cfset atts = structNew() />
    <cfset atts.att1 = "abc" />
    <cfset atts.att2 = "bcd" />
   
    <cfx_SayHello attributeCollection="#atts#" />

CFX Java Code:

import com.allaire.cfx.*;

/**
 *
 * @author    Arun Nallan (arun.nallan@gmail.com)
 */
public class SayHello_00 implements CustomTag
{
    boolean debug = false;
    Request request;
    Response response;
   
   
  public  void processRequest( Request request, Response response)
  {
     
      this.request = request;
      this.response = response;
     
    String dataIssueMsg = "", requestString = "";
   
    if(request.debug())
        debug = true;
   
    try
    {

      // Get all the parameter names
      String attribs[] = request.getAttributeList();
      String attrib = null;
     
      //Iterate over the names, getting the parameters
      for (int thisAttrib=0;thisAttrib<attribs.length;thisAttrib++)
      {
        attrib = attribs[thisAttrib];
       
        requestString += attrib.replaceAll("_", ".") + " = " +
request.getAttribute(attrib) + "<br/>";
      }
     
      response.write(requestString + "<br>");
     
    }

    // better to catch exceptions than to throw

    catch (Exception ex)
    {
      if(debug)
      {
          StackTraceElement stElements[] = ex.getStackTrace();
          response.writeDebug("<br><br>Exception during CFX
execution:<pre>"+ex.getMessage() + "\n");
          for(int stElementInd=0; stElementInd<stElements.length; stElementInd++)
              response.writeDebug(stElements[stElementInd].toString() + "<br>");
          response.writeDebug("</pre><br>");
      }
      else
          response.write("<br/><font color=\"red\">Error occured during CFX
execution. Please try to enable debug option for any debugging
information.</font><br/>");
     
      ex.printStackTrace();
      // out.flush();
      // out.close();
    }
    finally
    {
      if(debug)
     {
        response.writeDebug("<b>CFX Debugging Information</b>:<br>" +
getCFXInfo() + "<br><br>\n");
        // Get all the parameter names
        String parameters[] = request.getAttributeList();
        String param = null;
        //Iterate over the names, getting the parameters
        response.writeDebug("<table border=\"2\" bordercolor=\"blue\"
bgcolor=\"aliceblue\">");
        for (int thisParam=0;thisParam<parameters.length;thisParam++)
        {
          param = parameters[thisParam];
          response.writeDebug("<tr><td><b>" + param + "</b> :</td><td>" +
request.getAttribute(param).replaceAll("/^[ ]*$/","&nbsp;") + "</td></tr>");
        }
        response.writeDebug("</table>");
        }
    }
  }

  public String getCFXInfo()
  {
    return "Trial implementation of CFX for ColdFusion MX Bug support by Arun
Nallan";
  }   

}
cf_dev2 - 23 Nov 2007 08:48 GMT
[q]I honestly believe that this is not Java related as Java is/was
pre-compiled. This is error is being raised even before the CFX or even CFC is
actually getting executed. This is kind of like a pre-compile or semantic error.
[/q]

You're right.  The error is raised before any CF code is executed.  

I don't know whether this is deliberate or not.  Either the CF 8 documentation
is wrong (and it is not allowed for CFX tags) . or this might be a bug.

http://livedocs.adobe.com/coldfusion/8/htmldocs/Elements_04.html

As a work around, you could always pass in your own structure of attributes
into the tag and extract them manually.
Arun Nallan - 29 Nov 2007 16:41 GMT
You seem to be along my side. I agree with you. I shall try the work around you
mentioned.

Additionally, the same CFX tag used to work before we went in for CF8. Hence,
I think this is a bug. I also report the same as a bug to Adobe. I get no
replies from them till now if or not they are working on it.

We are thinking to roll back to version 7 due to this. I will try the work
around. If that works, thats good.

Regardless of the workaround, I think Adobe needs to come up with a fix to
this as this is a regression problem.
cf_dev2 - 29 Nov 2007 22:43 GMT
I don't know if its deliberate or a bug.  Assuming attributeCollection is a
documented attribute of [b]all[/b] custom tags (including CFX)  then that would
suggest a bug to me.  

A workaround shouldn't be too difficult.  The request class has few methods
and most are already built-in methods of the Hashtable class.  Example
request.attributeExists()  > Hashtable.containsKey().

You might even try creating a local copy of DebugRequest just inside the
processRequest method.  You could pass your structure of attributes into the
constructor and use it locally to get the attributes.   I haven't tried it but
it might work for you.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.