Link to home
Start Free TrialLog in
Avatar of cafoster
cafosterFlag for United States of America

asked on

CFDOCUMENTITEM error after upgrade to CF8

We've recently moved a site from a server running CF7 to one running CF8. I had been using CFDOCUMENT to generate a report as a PDF file without any problems, that is until we moved the site. I can still run the report successfully on the CF7 server, but the identical code on the CF8 server gives me this error:

The cause of this exception was that: coldfusion.runtime.UndefinedElementException: Element HARDWARETYPE is undefined in ATTRIBUTES..

I know that attributes.hardwaretype is defined, it's so frustrating! It's a list I'm looping through within a CFDOCUMENTITEM tag, type header. When I comment out the header, I get the same undefined error for my next attributes variable, contained within another CFDOCUMENTITEM tag, type footer. When I comment out the footer, the report runs fine, even though I have other variables from the attributes scope within my CFDOCUMENTSECTION tag.

I had hoped a Hot Fix would take care of the problem, but I think we're up-to-date. We're running CF Version 8,0,1,195765 -- shouldn't that already include all cumulative hot fixes?

Any help would be much appreciated :-)
Avatar of _agx_
_agx_
Flag of United States of America image

Can you post a small example that demonstrates the issue?
Avatar of cafoster

ASKER

Here's a pared-down version that generates the same error ...

<cfdocument format="pdf" orientation="landscape" pagetype="letter">

<cfoutput query="getInventory" group="Dept">
<cfdocumentsection marginbottom=".75" marginleft=".25" marginright=".25" margintop="1">

<html>
<head>
<title>Summary</title>
</head>
<body>

<!--- SET AND DISPLAY HEADER INFORMATION --->

<cfdocumentitem type="header">
      <div>
            CNTS
            <cfloop list="#attributes.hardwaretype#" index="x">
                  <cfif ListLen(attributes.hardwaretype) gt 1 and ListLast(attributes.hardwaretype) eq x> and <cfelseif ListFirst(attributes.hardwaretype) neq x>, </cfif>
                  #x#
            </cfloop> Inventory by Department,
            <cfif val(attributes.ageinmonths) eq 0>Entire Inventory<cfelse>#val(attributes.ageinmonths)# Months or Older as of #DateFormat(Now(),"m/d/yyyy")#</cfif>
      </div>
</cfdocumentitem>

...
unless I'm mistaken, (which is frequent and quite likely) attbitutes should (must?) be attributes of a cf tag

and use it in AttributeCollection
<tagname attributeCollection="#structureName#">

ie: the only attrbiute of cfdocumentitem is type with possible values of header|footer|Pagebreak
afaik "HARDWARETYPE" is not an -attribute- of any cftag

so i think you are using the wrong variable scope
(and CF8 is just being -pickier- than cf7)
attbitutes ??? geez that wasn't even close

Yes, "attributes" is a special scope of custom tags:  ie cf_mytagName  .  "Arguments" is a scope available to cffunctions.

Is this code called within a custom tag?
> geez that wasn't even close

These days if I get more than 50% of the letters right, I declare victory and call it a job well done.
agx - fyi in CF8, use of attribute has been expanded from custom tags to be available to most cftags by using AttributeCollection

good explanation here
http://www.bennadel.com/blog/755-Learning-ColdFusion-8-Defining-Tags-With-AttributeCollection.htm
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It does seem that CF8 is less forgiving when it comes to variable scope ... I've created and used an unscoped version of each "attributes" variable within my CFDOCUMENTITEM tags, and the report now runs without a problem. The report is part of a Fusebox 2 site, which uses the attributes scope heavily. As long as this little workaround does the trick, I'm happy :-)
in fusebox you might want to look at the request scope... I use it heavily in an FB3 app
Thanks for the tip ;-)
> i don't think adobe would break backward compat for custom tags by introducing a -competing- scope...

Hmm... normally they don't.  But unless my example is wrong, it doesn't work (ie it is broken)