• Post Reply Bookmark Topic Watch Topic
  • New Topic

lazy action form problem  RSS feed

BC claudio
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how come it always ends up with an exception?

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


Define the form in the struts-config.xml:


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

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


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


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

Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!