Friday, February 11, 2005 06:18 AM
You can only have one formbean associated with an action. This association is defined in the struts-config.xml file by the 'name' attribute. It seems as though you see how that works.
If you would like to include another javabean (weather it is a actionform extended bean or a POJO) you need to create and populate the bean and put it into either request or session scope.
For example, if you had an action of initListBoxEdit with the associated form of listBoxForm, the listBoxForm object would be populated automatically through the struts framework.
If you would like to include your SourceDatabaseForm bean as part of the request, then your action object must create it:
SourceDatabaseForm sbf = new SourceDatabaseForm();
sbf.setXXX('bbb'); (or however you want to populate it)
Place it in some scope:
request scope would be:
session scope would be:
Your iterate tag then would now have access to the bean even though it is not associated with the action. Make sure that your iterate tag specifies the scope of the bean that you are trying to use:
A second option is to create an attribute on the form associated with the action ( in the above example on the listBoxForm) that would hold the SourceDatabaseForm.
In addition to all the other attributes, listBoxForm would now have an attribute and getter and setter defined as:
SourceDatabaseForm sbf= null:
getSourceDatabaseForm() return sbf;
sbf = inSbf;
Instead of putting the SourceDatabaseForm into either request or session scope as in the first example, just use the setter method of the actionform (listBoxForm) associated with the action to put the new bean into the form.
Once the bean is associated with the actionform associated with the action then it is available in your jsp.
Hope this helps