This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Struts and the fly likes s:select tag issue in struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "s:select tag issue in struts2" Watch "s:select tag issue in struts2" New topic
Author

s:select tag issue in struts2

Arun Kumar
Ranch Hand

Joined: May 22, 2006
Posts: 62
I have some code like the below.

<s:iterator value="tprcollateral" status="stat">

<s:select list="selectCollateral" name="tprcollateral[%{#stat.index}].colArrayList" headerKey="-1" headerValue="Select Asset" value="%{colArrayList}" multiple="true" />

</s:iterator>

I have no issue at all with the display of the values on page. But when I try to submit the form I get this error.


tag 'select', field 'list', name 'tprcollateral[0].colArrayList': The requested list key 'selectCollateral' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]




The action class has these definitions.


private List<TprCollateral> tprcollateral;
private Map<String,String> selectCollateral;


and the TprCollateral class has this definition.


private ArrayList<String> colArrayList ;


all the getters and setters are there in the respective class.
[ June 04, 2008: Message edited by: Bear Bibeault ]
Arun Kumar
Ranch Hand

Joined: May 22, 2006
Posts: 62
Still waiting for any pointer.

Thanks in advance.
rupesh kumar
Greenhorn

Joined: Oct 18, 2007
Posts: 2
U should initialise the ArrayList.

either in construtor or some method..
Arun Kumar
Ranch Hand

Joined: May 22, 2006
Posts: 62
Sorry I got the issue, when submitting the form I had a dummy action method which was not doing anything useful and was just returning the control back to the page.

What i found out that while loading the page the array was fine but when coming back after hitting the action servlet this array which populates the select list was becoming null.

That was the reason of the error. I got it resolved and thought I will share my findings here.
Phill Pafford
Greenhorn

Joined: Jul 31, 2009
Posts: 2
Hi I'm having this same issue, after I post the list comes back as NULL. how do I fix this???
Marc Heruela
Ranch Hand

Joined: Jul 23, 2009
Posts: 38
Phill Pafford wrote:Hi I'm having this same issue, after I post the list comes back as NULL. how do I fix this???


What I did is in my Action class, I implement Preparable.

and in the prepare method i load the list..

but i know this is not optimal.

Im still looking forward to easier and more optimal solutions..

any advise guys?

-marckun


-marckun
Phill Pafford
Greenhorn

Joined: Jul 31, 2009
Posts: 2
Thanks,

I figured it out, I wasn't passing the values back in the action on submit. Well I have two actions, one for loading the page and one for submitting the page. Just needed to repopulate the second page call. Wish this error was a little less cryptic.
 
Don't get me started about those stupid light bulbs.
 
subject: s:select tag issue in struts2