Is it possible to use the DynaValidatorForm to transport data from model to view.
struts-config.xml:
<form-bean name="StartForm" type="org.apache.struts.validator.DynaValidatorForm"> {{{ <form-property name="partnerNumber" type="java.lang.String"/>
<form-property name="language" type="java.lang.String" initial="DE"/> }}}
</form-bean>
<action input="/jsp/start.jsp" {{{ name="StartForm" path="/Start"
scope="request" type="de.company.actions.StartAction" validate="true"> <forward name="go" path="/jsp/dealerlist.jsp"/> }}}
</action>
jsp is like:
<html:form method="POST" action="/Start.action"> {{{ <html:text property="partnerNumber" size="20" tabindex="1" maxlength="10"/>
<html:text property="language" size="2" tabindex="2" maxlength="2"/> <html:submit styleClass="buttonSave" tabindex="4"><bean:message key="common.button.goon"/></html:submit> }}}
</html:form>
for inserting values, there is no problem. Also validating is fine.
But if I want to edit the values, I had to take them from the persistence layer and put it into a bean in order to write it to the view by the tag-libs. But I can't initialize the DynaValidatorForm to fill it with the data and store it to the request?
It is quite simple.
Just take a Bean set it to the specified Attribute name in the request or session. request.setAttribute("key", bean);
Struts will take this bean for writing the values to the view and will fill a DynaValidatorForm for validating and sending data to action-class