Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Problems with Indexed Properties, Hidden Values and Logic Iterate Tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problems with Indexed Properties, Hidden Values and Logic Iterate Tag" Watch "Problems with Indexed Properties, Hidden Values and Logic Iterate Tag" New topic
Author

Problems with Indexed Properties, Hidden Values and Logic Iterate Tag

Michele Giunti
Greenhorn

Joined: Jun 02, 2008
Posts: 12
Hi to all.
I'm using Struts 1.3, Tomcat 6.0 and Eclipse.

I have a problem with Indexed Properties.
I have a jsp that should save hidden values and pass it to the linked Action.

I show you my code.

********
JSP PAGE
********

where
- 'listaSport' is a list containing a list of sports. This list is correctly populated by the previous Action through 'select' and 'optionsCollection' tags.
- 'hSportBean' is a LabelValueBean list where I have to save the select options.

***********
ACTION FORM
***********


******
ACTION
******


The problem is that I can't load in Action the hidden values saved in the jsp page.
I tried to print the values received

but I always obtain null values (for all indexes).

So, I don't know how to solve my problem.

I also followed guidelines in:
http://faq.javaranch.com/java/IndexedProperties
http://struts.apache.org/1.x/struts-taglib/indexedprops.html
http://mail-archives.apache.org/mod_mbox/struts-user/200604.mbox/%3C5B7D2ACE8204B748980CEB2DBFAB90B3972E53@mail.delta-informatique.net%3E
but with no success.

Can you help me?

Thanks a lot in advance.
Michele Giunti
Greenhorn

Joined: Jun 02, 2008
Posts: 12
Help!
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Frankly, I don't see anything wrong with your code. It should work! Just a couple of questions:

Is the result of the System.out.println statements a null pointer exception, or is the value simply null?

Use your browser's "view source" option on this page. The hidden fields should look like this. do they?


Merrill
Consultant, Sima Solutions
Michele Giunti
Greenhorn

Joined: Jun 02, 2008
Posts: 12
Originally posted by Merrill Higginson:
Frankly, I don't see anything wrong with your code. It should work! Just a couple of questions:

Is the result of the System.out.println statements a null pointer exception, or is the value simply null?

Use your browser's "view source" option on this page. The hidden fields should look like this. do they?


Dear Merrill, first of all tahnks for your reply.


About your questions.
1) I modified my Action to check the values returned from jsp. I don't get a NullPointer Exception. I just get null values. For examples, I print the first (index=0) LabelValueBean of the list but I get the following output:
lvb[0].label=null
lvb[0].value=null



2) Yes, I get what you expect.


So, I can't understand where is the problem.
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
I ran into something similar to this once a long time back. The problem was that java.beans.Introspector.getBeanInfo() was being called on my form it was determining that my private ArrayList was a propert (not an indexed property). If I remember correctly my solution was to make sure that I had an indexed version of both getter and setter methods. I think I may have also had to play with the order that the methods appeared in my form class.

I was using java 1.4.2 at the time and when I used a debugger on the Introspector class it appeared to me that it was finding a non-indexed getter or setter and from that assuming that the property itself wasn't indexed. I can't be sure that this is your problem but its something you might want to try. I know I wasted a huge amount of time figuring it out.
Michele Giunti
Greenhorn

Joined: Jun 02, 2008
Posts: 12
Originally posted by Tom Rispoli:
I ran into something similar to this once a long time back. The problem was that java.beans.Introspector.getBeanInfo() was being called on my form it was determining that my private ArrayList was a propert (not an indexed property). If I remember correctly my solution was to make sure that I had an indexed version of both getter and setter methods. I think I may have also had to play with the order that the methods appeared in my form class.

I was using java 1.4.2 at the time and when I used a debugger on the Introspector class it appeared to me that it was finding a non-indexed getter or setter and from that assuming that the property itself wasn't indexed. I can't be sure that this is your problem but its something you might want to try. I know I wasted a huge amount of time figuring it out.


Thanks for your reply.
Unfortunately, this is not my problem.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problems with Indexed Properties, Hidden Values and Logic Iterate Tag