[EMAIL PROTECTED] wrote:

I want to use a bean to supply options to a select widget.

I have a business object, DevicesBO that has a method that returns a Collection.

Class Name:     DevicesBO
Method: Collection getDevices()

The collection is a List of CodeDecodeDTO objects.

Class Name:     CodeDecodeDTO
Methods:        String getCode()
               String getDecodeDesc()

The value should be retrieved using the getCode() method and the label should be retrieved using getDecodeDesc.


I've tried with no success to setup my JSP, below is what I've tried.

snippet from my struts-config.xml
...
...
<form-beans>
<form-bean name="myAppFm" type="org.apache.struts.validator.DynaValidatorForm">
...
...
<form-property name="devices" type="sample.DeviceBO" />
</form-bean>
...
...



snippet from my JSP

...
...
<html:select name="myAppFm" property="dvcTyp" >
<html:options collection="devices" name="myAppFm" property="devices.code" labelProperty="devices.decodeDesc"
/>
</html:select>
...
...




From the documentation for html:options:

The *property* attribute is interpreted as the name of a property of the individual beans included in the collection, and is used to retrieve the value that will be returned to the server if this option is selected.


Since your methods are getCode and getDecodeDesc, your property names would be "code" and "decodeDesc". So it should be property="code" and labelProperty="decodeDesc" if I'm not mistaken.


What is the correct way to setup the html:options tag? Is there a way to use OSCache tags so I can cache the DevicesBO in my application?



I often write a Struts plug-in that sets static collections (such as select box values) as ServletContext attributes in the init method.


Erik


Thanks,

James

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to