You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by catchme <ca...@gmail.com> on 2009/03/05 13:05:15 UTC
Re: tag causing could not be resolved as a
collection/array/map/enumeration/iterator type error
HI
I was lookin for the same Query for last whole day . i m working on struts
2.0.11.2
an dfinnaly got to know that its not tah much easy to use selct tag :-|
anywasy finally i got the answer
that v need to passs list in action class
to get record list in select tag
thx 4 help
Mark Greene wrote:
>
> Hi All,
>
> After a couple of days I can't seem to figure this validation problem out.
> I
> have a basic JSP form (create.jsp) with a textfield (with validation) and
> a
> select list (WITHOUT validation). When I submit the form to trigger a
> validation failure on purpose, the text field is validated correctly and
> the
> user input is still present, however, the select list disappears below it
> and the following error is given:
>
> ERROR [[default]] Servlet.service() for servlet default threw exception
> tag 'select', field 'list', name 'catID': The requested list key
> 'categories' could not be resolved as a
> collection/array/map/enumeration/it
> erator type. Example: people or people.{name} - [unknown location]
>
> I've read about similar problems and they say to initialize the
> collections
> in the prepare(). I did that and I'm still getting the problem. Another
> solution I've heard was to put the Collection in the session. This doesn't
> seem like a scalable solution for applications that are deployed in a
> session replicated enviornement like clustering. Please tell me that
> putting
> the list in the seseion isn't the only work around?
>
> -----------------------------------------------------------------------------------------------------------
> Action Code:
> ------------------------------------------------------------------------------------------------------------
> public class CreateTicket extends ActionSupport implements Preparable {
>
> private Map categories;
>
> public Map getCategories() {
> return categories;
> }
>
> public void setCategories(Map categories) {
> this.categories = categories;
> }
>
> public String execute() throws Exception {
> this.prepare();
> return SUCCESS;
> }
>
> public void prepare() throws Exception {
> categories = new HashMap();
> categories.put(1, "test");
> categories.put(2, "test2");
> categories.put(3, "test3");
> }
> }
>
>
> public class HelloWorld extends ActionSupport {
>
> public static final String MESSAGE = "Struts is up and running ...";
> private String name;
> private Integer catID;
>
> public Integer getCatID() {
> return catID;
> }
>
> public void setCatID(Integer catID) {
> this.catID = catID;
> }
>
> public String execute() throws Exception {
>
> setMessage(MESSAGE + " " + getName());
>
> return SUCCESS;
>
> }
>
> private String message;
>
> public void setMessage(String message) {
> this.message = message;
> }
>
> public String getMessage() {
> return message;
> }
>
> public String getName() {
> return name;
> }
>
> public void setName(String name) {
> this.name = name;
> }
>
> ----------------------------------------------------------------------------------------------------------
> /tutorial/create.jsp Code:
> ----------------------------------------------------------------------------------------------------------
>
>
>
>
>
>
> ----------------------------------------------------------------------------------------------------------
> struts.xml Code:
> ----------------------------------------------------------------------------------------------------------
>
>
>
>
>
>
> /ticket/create.jsp
>
>
> /ticket/createconfirm.jsp
> /ticket/create.jsp
>
>
>
>
> ----------------------------------------------------------------------------------------------------------
> HelloWorld-validaiton.xml:
> ----------------------------------------------------------------------------------------------------------
>
>
> name
> 10
> 10
> true
> Your name needs to be 10 characters long
>
>
>
>
HI
--
View this message in context: http://www.nabble.com/%3Cs%3Aselect%3E-tag-causing-could-not-be-resolved-as-a-collection-array-map-enumeration-iterator-type-error-tp20725739p22350315.html
Sent from the Struts - User mailing list archive at Nabble.com.