aspose file tools*
The moose likes Struts and the fly likes lazy action form problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "lazy action form problem" Watch "lazy action form problem" New topic
Author

lazy action form problem

BC claudio
Greenhorn

Joined: May 02, 2005
Posts: 5
how come it always ends up with an exception?

javax.servlet.ServletException: Exception creating bean of class org.apache.struts.validator.LazyValidatorForm: {1}

http://www.niallp.pwp.blueyonder.co.uk/lazyactionform.html


Define the form in the struts-config.xml:

<struts-config>

<form-beans>
<form-bean name="lazyForm" type="org.apache.struts.validator.LazyValidatorForm"/>
</form-beans>

<action-mappings>
<action path="/myActionPath" type="myPackage.MyAction" name="lazyForm" validate="true"/>
</action-mappings>

</struts-config>

Set up the jsp in the usual way.

<html:form action="/myActionPath">

<h2>Simple Property Example</h2>

Customer Number: <html:text property="custNo"/>
Customer Name: <html:text property="custName"/>

<h2>Mapped Property Example</h2>

Street: <html:text property="address(street)"/>
Town: <html:text property="address(town)"/>
State: <html:text property="address(state)"/>
Country: <html:text property="address(country)"/>

<h2>Indexed Property Example</h2>

<logic:iterate id="products" property="products">
Product Code: <html:text name="products" property="code" indexed="true"/>
Product Description: <html:text name="products" property="description" indexed="true"/>
Product Price: <html:text name="products" property="price" indexed="true"/>
</logic:iterate>

</html:form>

Use in the Action by casting the ActionForm to a DynaBean.

public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServeletRequest request,
HttpServletResponse response) throws Exception {

// Cast form to DynaBean
DynaBean dynaForm = (DynaBean)form;

// Use the DynaBean
String custNo = (String)dynaForm.get("custNo"); // simple
Map address = (Map)dynaForm.get("address"); // mapped
List products = (List)dynaForm.get("products"); // indexed

... etc etc

}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: lazy action form problem