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-bean>

<action input="/jsp/start.jsp" {{{ name="StartForm" path="/Start"

</action>

jsp is like:

<html:form method="POST" action="/Start.action"> {{{ <html:text property="partnerNumber" size="20" tabindex="1" maxlength="10"/>

</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

StrutsDynaValidatorForm (last edited 2009-09-20 23:33:33 by localhost)