I have a struts action which populates a field.
public ActionForward appForm(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
DynaValidatorForm dyna = (DynaValidatorForm) form;
String identifier = (String) request.getParameter("id");
ApplicationDTO app = manager.getApplication(identifier);
dyna.set("firstName",app.getFirstName());
return (mapping.findForward("application.success"));
}
The form bean looks like:
<form-bean name="ApplicationForm" type="struts.ApplicationForm">
<form-property name="id" type="java.lang.String" initial="0" />
<form-property name="firstName" type="java.lang.String" />
...
..
.
</form-bean>
ApplicationForm extends DynaValidatorForm and it does some validation.
How do I access a struts form property value inside my jsp.
<html:text property="firstName" styleId="firstName" value="TODO Add code to access the form property fistName END TODO"/>
SOLUTION
user the name attribute within the html:text tag. Name attribute specifies the name of an object (in any scope) whose field, specified by the property attribute will be used to populate this control with data. Example:
<html:text property="firstName" styleId="firstName" name="ApplicationForm"/>