Hi,
I have a JSP page that outputs data using a Collection
using the following section
<logic:iterate id="lifeBenefit" name="lifeBenefits"
type="com.quote.dao.BenefitLineItem"
indexId="classNum">
<tr valign="middle" class="bg2">
<td height="28" bgcolor="#FFFFFF">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<html:checkbox name="lifeBenefit"
property="benClsTtl" indexed="true"></html:checkbox>
</td>
<td class="formtext"> <%=i %></td>
<% i++; %>
</tr>
</table>
</td>
</tr>
The above JSP is converted into the following HTML
code
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<input type="text" name="lifeBenefit[0].benClsTtl"
size="17" value="some EMPLOYEES">
</td>
</tr>
I am having a problem writing the corresponding
ActionForm,
the problem is how do I declare the variables to
capture the values entered by the user
I have attempted to write it and here is what I came
up with
public class GotoStep4Form extends ValidatorForm
implements Serializable {
private ArrayList records = null;
private BenefitLineItem [] lifeBenefits;
private String [] benClsTtl;
public ActionErrors validate(
ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = super.validate(mapping,
request);
if(errors == null) errors = new ActionErrors();
if (!errors.empty() ) {
HttpSession session = request.getSession();
}
return errors;
}
public BenefitLineItem getLifeBenefit(int index) {
while(index >=records.size() ){
this.records.add(new
BenefitLineItem());
}
return (BenefitLineItem) records.get(index);
}
/**
* Gets the benClsTtl
* @return Returns a String[]
*/
public String[] getBenClsTtl() {
return benClsTtl;
}
/**
* Sets the benClsTtl
* @param benClsTtl The benClsTtl to set
*/
public void setBenClsTtl(String[] benClsTtl) {
this.benClsTtl = benClsTtl;
}
/**
* Sets the lifeBenefit
* @param lifeBenefit The lifeBenefit to set
*/
public void setLifeBenefit(int index, BenefitLineItem
lifeBenefit) {
this.lifeBenefits[index] = lifeBenefit;
}
public BenefitLineItem[] getLifeBenefits() {
return lifeBenefits;
}
public void setLifeBenefits( BenefitLineItem[] v) {
lifeBenefits = v;
}
}
The above gives me an error :
WebGroup X Servlet Error: BeanUtils.populate:
java.lang.reflect.InvocationTargetException:
java.lang.NullPointerException
at
com.fdl.quoteweb.actionforms.GotoStep4Form.getLifeBenefit(GotoStep4Form.java:53)
at java.lang.reflect.Method.invoke(Native Method)
at
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:475)
at
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:410)
at
org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.java:749)
at
org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:780)
at
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:793)
at
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:726)
at
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:978)
at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:779)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:246)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
What am I doing Wrong? How dow I define the variables
in the ActionForm to have Struts populate the data
in the form?
Any help will be appreciated.
Thanks,
Samir
__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]