You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Kamalakar Thota <ko...@yahoo.com> on 2003/06/17 20:19:53 UTC

Form bean population for and tags

Hello folks,
 
I have the following problem using <nested:iterate> and <logic:iterate> tags. Please help me some one.

Problem:

When i set the values for first time in my action class and forward to jsp page i.e pre-populate , the values are set and works well. But after prepopulating, when i change values in the jsp page and try to submit the form, then i get the "BeanUtils.populate" errors. Is it because, i am trying to populate list/some other reason?

Here i have listed
1. struts code
2. Form Bean code
3. TraineeScoresListBean code
4. Errors

Any suggestions? Please help me, ASAP. Thank You.

1. Here is my form using struts:

a. Using logic:iterate
 
<logic:iterate id="element" name="perfTestGradeForm" 
             property="traineeScoresList" >
       <html::text property="score" name="element" size="5" 
                           maxlength="4" /><br />
</logic:iterate>

b. using nested:iterate
 
<nested:iterate name="perfTestGradeForm" property="traineeScoresList" >
<nested:text property="score" size="5" maxlength="4" /><br />
</nested:iterate>
 
Here the list 'traineeScoresList' is collection of beans
'TraineeTaskScoreListBean' that has attribute 'score' of datatype 'String'.

2. Form Bean Code:

public final class PerfTestGradeFormBean extends ActionForm {
//this traineeScoresList will have TraineeTaskScoreListBean that has
// score as an attribute
private Collection traineeScoresList = new Vector();

public PerfTestGradeForm(){
this.traineeScoresList = new Vector();
}

public Collection getTraineeScoresList(){
System.out.println("In perftestgradeform.java: getTraineeScore...()");
return this.traineeScoresList;
}

public void setTraineeScoresList(Collection list){
this.traineeScoresList = list;
}
}

3. Here is Code for TraineeTaskScoreListBean:

public class TraineeTaskScoreListBean{
private String score;
public TraineeTaskScoreListBean(String score){
this.score = score;
}
public String getScore(){
return this.score;
}
public void setScore(String score){
this.score = score;
}
}


4. Errors:

java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 1
at java.util.Vector.get(Vector.java:713)
at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(Propert
yUtils.java:521)
at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(Propert
yUtils.java:428)
at org.apache.commons.beanutils.PropertyUtils.getNestedProperty(Property
Utils.java:770)
at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.
java:801)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:881
)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1096)
at org.apache.struts.action.RequestProcessor.processPopulate(RequestProc
essor.java:816)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:254)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:142
0)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:520)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360
)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicati
onHandler.java:294)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:5
58)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1714)
at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplication
Context.java:507)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1664)
at org.mortbay.http.HttpServer.service(HttpServer.java:863)
at org.jboss.jetty.Jetty.service(Jetty.java:460)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:775)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:939)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:792)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:
201)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:455)


Again Thanks,
Kamal.

---------------------------------------------------------------------
"When someone LAUGHS, you SMILE
When someone CRIES, make them SMILE" - Kamalakar Thota

"A winner is not one who never fails, but one who
never quits! In LIFE"

"YOU SEE THINGS AND SAY,'WHY?,' BUT I DREAM THINGS AND SAY,'WHY
NOT?'" - Goerge Bernard Shaw
---------------------------------------------------------------------








---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

Re: A Question about Patches

Posted by James Mitchell <jm...@apache.org>.
On Tuesday 24 June 2003 13:46, DeRose Jonathan wrote:
> I have a question about a patch I submitted,
> http://issues.apache.org/bugzilla/show_bug.cgi?id=20784
>
> A quick summary for anyone who may have missed it:
>   The enhancement provides lots of new functionality for error handling
> beyond writing out the errors. (Developers could use it to highlight
> errored inputs, create errors on a group of input elements, have their
> labels turn bold and red, and lots more...
>   It is flexible and allows developers to set up these styles to whatever
> is suitable for their application, or leave them out completely.  It is
> completely backwards compatible.</PLUG>
>
>   I have received several positive replies from people both on the list and
> in private emails.  I would like to know if there is anything I can do
> next. I apologize as I am new to collaboration in an open source
> environment.  I do not want to push too hard, nor do I want to let this
> enhancement slip through the cracks.  So if there is anything I can do to
> promote this enhancement/refine it/answer questions about it, I would love
> to do so.  I think it would be a really great addition to Struts.

Are you hosting this as a project somewhere?  Sourceforge?

If not, then might want to.  

The Struts project on SourceForge is a great place for these kinds of 
enhancements/extensions.

http://sourceforge.net/projects/struts 

If you want, let me know and I'll add you.  That would allow you to package 
and release it with incremental improvements and also allow others to use and 
modify the source to their liking (the essence of OSS).

>
> Thanks for any help/insight,
> Jonathan
>
>

-- 
James Mitchell
Software Developer/Struts Evangelist
http://www.struts-atlanta.org
770-822-3359
AIM:jmitchtx



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


A Question about Patches

Posted by DeRose Jonathan <de...@bah.com>.
I have a question about a patch I submitted,
http://issues.apache.org/bugzilla/show_bug.cgi?id=20784

A quick summary for anyone who may have missed it:
  The enhancement provides lots of new functionality for error handling
beyond writing out the errors. (Developers could use it to highlight errored
inputs, create errors on a group of input elements, have their labels turn
bold and red, and lots more...
  It is flexible and allows developers to set up these styles to whatever is
suitable for their application, or leave them out completely.  It is
completely backwards compatible.</PLUG>

  I have received several positive replies from people both on the list and
in private emails.  I would like to know if there is anything I can do next.
I apologize as I am new to collaboration in an open source environment.  I
do not want to push too hard, nor do I want to let this enhancement slip
through the cracks.  So if there is anything I can do to promote this
enhancement/refine it/answer questions about it, I would love to do so.  I
think it would be a really great addition to Struts.

Thanks for any help/insight,
Jonathan



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


RE: Form bean population for and tags

Posted by Malcolm Davis <ma...@nuearth.com>.
Hello Kamal,
Did you ever get a fix for this problem?
- Malcolm

-----Original Message-----
From: Kamalakar Thota [mailto:kooldude_092002@yahoo.com]
Sent: Tuesday, June 17, 2003 1:20 PM
To: Struts Developers List
Subject: Form bean population for <logic:iterate> and
<nested:iterate>
tags


Hello folks,

I have the following problem using <nested:iterate> and
<logic:iterate> tags. Please help me some one.

Problem:

When i set the values for first time in my action class and
forward to jsp page i.e pre-populate , the values are set
and works well. But after prepopulating, when i change
values in the jsp page and try to submit the form, then i
get the "BeanUtils.populate" errors. Is it because, i am
trying to populate list/some other reason?

Here i have listed
1. struts code
2. Form Bean code
3. TraineeScoresListBean code
4. Errors

Any suggestions? Please help me, ASAP. Thank You.

1. Here is my form using struts:

a. Using logic:iterate

<logic:iterate id="element" name="perfTestGradeForm"
             property="traineeScoresList" >
       <html::text property="score" name="element" size="5"
                           maxlength="4" /><br />
</logic:iterate>

b. using nested:iterate

<nested:iterate name="perfTestGradeForm"
property="traineeScoresList" >
<nested:text property="score" size="5" maxlength="4" /><br
/>
</nested:iterate>

Here the list 'traineeScoresList' is collection of beans
'TraineeTaskScoreListBean' that has attribute 'score' of
datatype 'String'.

2. Form Bean Code:

public final class PerfTestGradeFormBean extends ActionForm
{
//this traineeScoresList will have TraineeTaskScoreListBean
that has
// score as an attribute
private Collection traineeScoresList = new Vector();

public PerfTestGradeForm(){
this.traineeScoresList = new Vector();
}

public Collection getTraineeScoresList(){
System.out.println("In perftestgradeform.java:
getTraineeScore...()");
return this.traineeScoresList;
}

public void setTraineeScoresList(Collection list){
this.traineeScoresList = list;
}
}

3. Here is Code for TraineeTaskScoreListBean:

public class TraineeTaskScoreListBean{
private String score;
public TraineeTaskScoreListBean(String score){
this.score = score;
}
public String getScore(){
return this.score;
}
public void setScore(String score){
this.score = score;
}
}


4. Errors:

java.lang.ArrayIndexOutOfBoundsException: Array index out of
range: 1
at java.util.Vector.get(Vector.java:713)
at
org.apache.commons.beanutils.PropertyUtils.getIndexedPropert
y(Propert
yUtils.java:521)
at
org.apache.commons.beanutils.PropertyUtils.getIndexedPropert
y(Propert
yUtils.java:428)
at
org.apache.commons.beanutils.PropertyUtils.getNestedProperty
(Property
Utils.java:770)
at
org.apache.commons.beanutils.PropertyUtils.getProperty(Prope
rtyUtils.
java:801)
at
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils
.java:881
)
at
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.ja
va:808)
at
org.apache.struts.util.RequestUtils.populate(RequestUtils.ja
va:1096)
at
org.apache.struts.action.RequestProcessor.processPopulate(Re
questProc
essor.java:816)
at
org.apache.struts.action.RequestProcessor.process(RequestPro
cessor.ja
va:254)
at
org.apache.struts.action.ActionServlet.process(ActionServlet
.java:142
0)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.
java:520)

at
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder
.java:360
)
at
org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(Web
Applicati
onHandler.java:294)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandl
er.java:5
58)
at
org.mortbay.http.HttpContext.handle(HttpContext.java:1714)
at
org.mortbay.jetty.servlet.WebApplicationContext.handle(WebAp
plication
Context.java:507)
at
org.mortbay.http.HttpContext.handle(HttpContext.java:1664)
at org.mortbay.http.HttpServer.service(HttpServer.java:863)
at org.jboss.jetty.Jetty.service(Jetty.java:460)
at
org.mortbay.http.HttpConnection.service(HttpConnection.java:
775)
at
org.mortbay.http.HttpConnection.handleNext(HttpConnection.ja
va:939)
at
org.mortbay.http.HttpConnection.handle(HttpConnection.java:7
92)
at
org.mortbay.http.SocketListener.handleConnection(SocketListe
ner.java:
201)
at
org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:2
89)
at
org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:4
55)


Again Thanks,
Kamal.

------------------------------------------------------------
---------
"When someone LAUGHS, you SMILE
When someone CRIES, make them SMILE" - Kamalakar Thota

"A winner is not one who never fails, but one who
never quits! In LIFE"

"YOU SEE THINGS AND SAY,'WHY?,' BUT I DREAM THINGS AND
SAY,'WHY
NOT?'" - Goerge Bernard Shaw
------------------------------------------------------------
---------








---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org