I would like to set a value on a DynaForm, which is easy to do in the Action class, but I would like to do so in the JSP itself, by copying a value from the session into the form.
<form-bean name="inputCIDs" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="containerIDFormat" type="java.lang.String"/>
</form-bean>
The following Java code works in the JSP, but is there a Struts 1.x or JSTL tag that would do the equivalent action?
<%
DynaActionForm form = (DynaActionForm) request.getAttribute("inputCIDs");
form.set("containerIDFormat", session.getAttribute("varInSession"));
%>
The property will be used and changed by the user using a select box
<html:select property="containerIDFormat">
<html:options collection="containerIDFormats" property="value" labelProperty="description"/>
</html:select>
Environment:
Struts 1.2.4
taglibs 1.1.2
JBoss 4.0.2
Why? The JSP isn’t the appropriate place for this type of work.
If you just set the form value it won’t survive the submission anyway, because a new request-scoped form will be created. And if it’s a session-scoped form there’s even less reason to do this work in JSP.