You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marcus Edwards <ma...@digitalsteps.com> on 2002/10/31 10:58:20 UTC

DynaValidatorAction and NullPointerException (again)...

Hi,

I have run into a problem that, judging by the posts in the archive,
numerous others have run into:

java.lang.NullPointerException
 at
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm.java:
551)
 at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:365)

I read all of the previous messages and have tried the suggestions listed
there but I still haven't got it
to work. I would greatly appreciate some help with this.

---8<--- struts-config.xml
<form-bean name="applyPersonalDetailsForm"
type="org.apache.struts.validator.DynaValidatorForm" dynamic="true">
    <form-property name="title" type="java.lang.String"/>
   <form-property name="forenames" type="java.lang.String"/>
   <form-property name="surname" type="java.lang.String"/>
   <form-property name="previousSurname" type="java.lang.String"/>
...etc...
</form-bean>

<action path="/applyPersonalDetails"
            type="com.sun.elearning.ui.apply.ApplyPersonalDetailsAction"
            name="applyPersonalDetailsForm"
            input="/personal_details.jsp"
            scope="request"
            attribute="applyPersonalDetailsForm">
                <forward name="success"
path="/editApplication.do?action=edit" />
</action>

<action path="/editPersonalDetails"
         type="com.sun.elearning.ui.apply.EditPersonalDetailsAction"
         name="applyPersonalDetailsForm"
         scope="request"
         validate="false">
            <forward name="success" path="/personal_details.jsp" />
</action>

---8<--- personaldetails.jsp
<html:form action="/applyPersonalDetails">
<p>1.01 *Title</p>
<p><html:select styleId="titleID" property="title"
styleClass="entry-textfield">
 <html:option value="">- Please select -</html:option>
 <html:options name="lists" property="titlesList"/>
</html:select></p>

<p>1.02 *Forenames / given names</p>
<p><html:text property="forenames" styleId="forenameID"
styleClass="entry-textfield" maxlength="256" size="16"/></p>

<p>1.03 *Surname</p>
<p><html:text property="surname" styleId="forenameID"
styleClass="entry-textfield" maxlength="256" size="16"/></p>

<p>1.04  Previous Surname</p>
<p><html:text property="previousSurname" styleId="forenameID"
styleClass="entry-textfield" maxlength="256" size="16"/></p>

<html:submit/>
</html:form>

---8<--- EditPersonalDetails.java
  public ActionForward execute(
    ActionMapping mapping,
    ActionForm actionForm,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception
  {
    ActionForward result = null;
    Application appl = null;

    if (meetsRequirements(request))
    {
      appl = (Application)
request.getSession().getAttribute(Constants.APPLICATION_KEY);
      DynaValidatorForm daForm = (DynaValidatorForm) actionForm;

      // Create the DynaForm & reconfigure it based on the mapping config
for this action
      if(daForm == null)
      {
       daForm = new DynaValidatorForm();
       daForm.reset(mapping, request);
      }

      populateDynaForm(daForm, appl);

      // set the updated appplication into the session
      request.getSession().setAttribute(Constants.APPLICATION_KEY, appl);

      // forward to the success page
      result = mapping.findForward(Constants.SUCCESS_FORWARD);
    }
    else
    { // the action could not be completed because the pre-requisites were
not met
      result = mapping.findForward(Constants.SUCCESS_FORWARD);
    }
    return result;
  }

---8<---

Volumous thanks in advance...

Marcus



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>