Solved

Struts validation problem with string array for text fields

Posted on 2009-04-07
1
1,047 Views
Last Modified: 2013-11-24
Hi,
I have a requirement for struts validation for a number of text fields which will use the same name. As the number can be up to 50 text boxes, obviously, I want to use the same name.
The name of my text box if firstName[]

Below is my form beans:
package strutspackage;

import org.apache.struts.validator.ValidatorForm;

public class appForm extends ValidatorForm {

      private static final long serialVersionUID = 1L;

      private String[] firstName;
      
      public String[] getFirstName() {
            return this.firstName;
      }
      public void setFirstName(String[] firstName) {
            this.firstName = firstName;
      }
}

My validation is a simple 'required' validation:
 <field
                property="firstName"
                depends="mask"
                page="1">
                     <arg key="genericInvalid.amount"/>
                     <var>
                          <var-name>mask</var-name>
                          <var-value>^[0-9]*$</var-value>
                     </var>
            </field>

However, when I run this application form, I'm getting errors:
javax.servlet.ServletException: Invalid argument looking up property firstName[] of bean org.apache.struts.taglib.html.BEAN
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
      org.apache.jsp.appForm1_jsp._jspService(appForm1_jsp.java:172)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

I presume this has something to do with my form class.
I don't have much experience using string array within Struts so if anyone can lend a hand or has previous experience with this, it would be much appreciated.
0
Comment
Question by:aibdev
1 Comment
 
LVL 12

Accepted Solution

by:
Gibu George earned 250 total points
ID: 24089827
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
scoresAverage challenge 8 91
Return ZipOutputStream using Servlet 2 41
eclipse compiler vs Installed JREs option 3 77
eclipse argument 14 53
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now