Struts Logic:equal problem compairing bean values
I have two seperate beans available to a .jsp. I am trying to set the "selected" value of a Select option tag to "true" if the value of bean 1 equals the value of bean 2.
Code as below:
<logic:present name="SActionForm" scope="request">
<bean:define id="SActionForm" name="SActionForm" scope="request"/>
</logic:present>
...
...
...
<select name="category" id="category">
<logic:iterate id="category" name="categoryList" type="uk.co.test.scr.bom.Category" scope="session">
<option value='<bean:write name="category" property="category_id"/>'><logic:equal name='category' property='category_id' value='<bean:write name="SActionForm" property="category"/>'> selected='true'</logic:equal>>
<jsp:getProperty name="category" property="category_description"/>
</option>
</logic:iterate>
</select>
-
I've checked the values match by printing out the bean values during each iteration, therfore I think it a problem specific to the logic:equal statement:
<logic:equal name='category' property='category_id' value='<bean:write name="SActionForm" property="category"/>'> selected='true'</logic:equal>
Anyone any ideas?
Thanks in advance
[1378 byte] By [
StrutFoola] at [2007-10-2 9:46:39]

No exceptions, category is a bean in present in session scope.
Bit strange:
<logic:equal name='category' property='category_id' value='<bean:write name="SActionForm" property="category"/>'>
selected="true"
</logic:equal>
doesn't work, yet the following does...
<logic:equal name='category' property='category_id' value='<%=SActionForm.getCategory()%>'>
selected="true"
</logic:equal>
any ideas why? does bean:write get property values in a different manner?
Thanks
Thanks Shanu,
The problem with the way I have written it is that the getter method of said property is non-static, where from a .jsp we would be trying to reference the getter method from a static context. Causing a compilation problem.
Any way around this? other than changing the bean property to a static type?
compairing bean values with that manner is not correct .
you can try this:
<bean:define id="targetvalue">
<bean:write name="name" property="property">
</bean:define>
<logic:equal name="sourcename" value="<%=targetvalue%>">
....
</logic:equal>
That dint work for me... but i found another way; i.e., using EL.. check the code below...
<bean:define id="targetvalue" name="name" property="property"/>
<logic:equal name="sourcename" value="${targetvalue}">
....
</logic:equal>
A * R