• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4201
  • Last Modified:

Struts - Nested or Indexed Array not working - Invalid argument looking up property of bean

Hello,
I have an array of a class in my bean and when I try loading the JSP, it throws me the error given below.

javax.servlet.jsp.JspException: Invalid argument looking up property emailTO[0].internetIdentifier of bean org.apache.struts.taglib.html.BEAN
      at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:959)
      at org.apache.struts.taglib.html.BaseFieldTag.prepareValue(BaseFieldTag.java:121)
      at org.apache.struts.taglib.html.BaseFieldTag.renderInputElement(BaseFieldTag.java:102)
      at org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:81)
      

public class FieldIntellFormBean extends BaseFormBean {

      private InternetIdentifierTO[] emailTO = new InternetIdentifierTO[3];

      private InternetIdentifierTO[] imNameTO = new InternetIdentifierTO[3];

      public FieldIntellFormBean() {

            for (int j = 0; j < SIZE; j++) {
                  emailTO[j] = new InternetIdentifierTO();

                  imNameTO[j] = new InternetIdentifierTO();
            }
        }
}

public class InternetIdentifier{

      private String internetIdentifier;

}

public InternetIdentifierTO(){
      internetIdentifier = "";
}

Any Help?

Thanks,
Kanishk
0
kanishkpanwar
Asked:
kanishkpanwar
1 Solution
 
kanishkpanwarAuthor Commented:
This is how I access the object attribues

<html:text property="emailTO[0].internetIdentifier" styleClass="standardText" maxlength="98" size="21" />
0
 
boonlengCommented:
If you have nested bean, you should use nested tag instead.
Example:
    <nested:text property="emailTO[0].internetIdentifier"/>

Or you can use iterator to loop the array:
    <nested:iterate name="theFormName" property="emailTO">
        <nested:text property="internetIdentifier"/>
    </nested:iterate>


Regards,
Boon Leng
0
 
kanishkpanwarAuthor Commented:
nevermind. I figured it out myself.

I had to put this in my reset method of the bean.

  for (int j = 0; j < SIZE; j++) {
                  emailTO[j] = new InternetIdentifierTO();

                  imNameTO[j] = new InternetIdentifierTO();
            }


Admins: - Can I have a refund for my points?
0
 
mrcoffee365Commented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup Zone:
PAQ - Refund

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

mrcoffee365 Experts Exchange Cleanup Volunteer
0
 
Computer101Commented:
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now