how about added a public Entry getEntry(index i) which returns a specific entry
from your array?

Dave





"Gao, Gang" <[EMAIL PROTECTED]> on 09/06/2001 12:58:04
PM

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:    (bcc: David Hay/Lex/Lexmark)
Subject:  Array in nested bean form class issue?



Hi,
I'm trying to use nested class array in my project. The jsp page is like :
<html:text property="entry[0].customerName" size="18"/>
<html:text property="entry[1].telephoneNum" size="3" maxlength="3"/>

and in the Form bean class, I define the class:
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import common.Entry;

public final class RequestForm extends ActionForm {
   private Entry[] entry = new Entry[10];
   public Entry[] getEntry() {
      return entry;
   }

   public void setEntry(Entry[] entry) {

               this.entry= entry;
   }
}

Entry class is like:

package common;
import java.io.Serializable;
public final class Entry implements Serializable {

   private String customerName = null;
   private Phone  telephoneNum = new Phone();
   public String getCustomerName() {
      return customerName;
   }

   public void setCustomerName(String customerName) {
      this.customerName = customerName;
   }

  public Phone getTelephoneNum() {
    return telephoneNum;
  }

  public void setTelephoneNum(Phone telephoneNum) {
    this.telephoneNum = telephoneNum;
  }
}
so when I compile it and run the jsp page in weblogic 6.0 server, I get a
error message:
Servlet failed with exception:
java.lang.IllegalArgumentException: Null property value for 'entry[0]'
     at
org.apache.struts.util.PropertyUtils.getNestedProperty(PropertyUtils.java:34
7)
     at
org.apache.struts.util.PropertyUtils.getProperty(PropertyUtils.java:381)
     at
org.apache.struts.util.BeanUtils.getArrayProperty(BeanUtils.java:189)
     at
org.apache.struts.taglib.html.SelectTag.doStartTag(SelectTag.java:289)
     at
jsp_servlet._request_manual_order._jspService(_request_manual_order.java:270
)
     at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
     at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:213)
     at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:246)
     at
weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImp
l.java:157)
     at
org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.ja
va:1697)
     at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1540)
     at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:213)
     at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:1265)
     at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:1631)
     at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
     at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
Please tell me what is wrong with my Form Bean.
Thanks

Frank

Title: Array in nested bean form class issue?

Hi,
I'm trying to use nested class array in my project. The jsp page is like :
<html:text property="entry[0].customerName" size="18"/>
<html:text property="entry[1].telephoneNum" size="3" maxlength="3"/>

and in the Form bean class, I define the class:
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import common.Entry;

public final class RequestForm extends ActionForm {
   private Entry[] entry = new Entry[10];
   public Entry[] getEntry() {
      return entry;
   }

   public void setEntry(Entry[] entry) {
          
                this.entry= entry;
   }
}

Entry class is like:

package common;
import java.io.Serializable;
public final class Entry implements Serializable {
  
   private String customerName = null;
   private Phone  telephoneNum = new Phone();
   public String getCustomerName() {
      return customerName;
   }

   public void setCustomerName(String customerName) {
      this.customerName = customerName;
   }

  public Phone getTelephoneNum() {
    return telephoneNum;
  }

  public void setTelephoneNum(Phone telephoneNum) {
    this.telephoneNum = telephoneNum;
  }
}
so when I compile it and run the jsp page in weblogic 6.0 server, I get a error message:
Servlet failed with exception:
java.lang.IllegalArgumentException: Null property value for 'entry[0]'
        at org.apache.struts.util.PropertyUtils.getNestedProperty(PropertyUtils.java:347)
        at org.apache.struts.util.PropertyUtils.getProperty(PropertyUtils.java:381)
        at org.apache.struts.util.BeanUtils.getArrayProperty(BeanUtils.java:189)
        at org.apache.struts.taglib.html.SelectTag.doStartTag(SelectTag.java:289)
        at jsp_servlet._request_manual_order._jspService(_request_manual_order.java:270)
        at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
        at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213)
        at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246)
        at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:157)
        at org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.java:1697)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1540)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213)
        at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265)
        at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1631)
        at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
        at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
Please tell me what is wrong with my Form Bean.
Thanks

Frank

Reply via email to