This content has been marked as final. Show 4 replies
wouldn't you want to loop over the query data?
i'm guessing you have a struct (myStruct) that holds the image height/width (myStruct.height and myStruct.width)? what is it that's coming from the query that you want the struct to hold (that it's not currently holding)?
I would like to populate the structure with the image file names that are coming from the query. The structure is built from a java object. Here is the function to create it.
<cffunction name="getSize" returntype="struct" access="public" output="No">
<cfargument name="Image" required="Yes" type="string">
<cfset myImage = createObject("java", "javax.swing.ImageIcon")>
<cfset myStruct = StructNew()>
<cfset myStruct.width = myImage.getIconWidth()>
<cfset myStruct.height = myImage.getIconHeight()>
<cfobject component="imageSize" name="objImage">
<cfset myStruct = objImage.getSize("/images/someimage.jpg")>
Right now the structure only gives me the first row of the query. I have tried using the cfquery loop to populate the structure with now results. I suspect I am using the wrong syntac.
well, a structure by design can only have one key with a given name. you can't have myStruct.height multiple times for multiple images returned from the query.
Sounds like you want an array of structs.
I tried running your code but I get this error.
<cfset ArrayAppend(myArray, objImage.getSize("images/products/largeImages/#Recordset1.elink#")>
When I dump this it works.
<cfset myStruct = objImage.getSize("images/products/largeImages/#Recordset1.elink#")>
The error I am getting says.
The CFML compiler was processing:
an expression beginning with "ArrayAppend", on line 23, column 13.This message is usually caused by a problem in the expressions structure.
a cfset tag beginning on line 23, column 7.
The error occurred in C:\CFusionMX7\wwwroot\flash\setSize.cfm: line 23
22 : <cfoutput query="Recordset1">
23 : <cfset ArrayAppend(myArray, objImage.getSize("images/products/largeImages/#Recordset1.elink#")>
24 : </cfoutput>