You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jeff Huang <je...@hotmail.com> on 2011/04/05 11:01:15 UTC

s:select dropdown box problem: cannot locate list

Hi All,

I need urgent help on this!
help greatly appreciated..been stuck on this for a LONG time!
it is not able to locate conditionList

Servlet.service() for servlet jsp threw exception
tag 'select', field 'list', name 'bookCondition': The requested list key 'conditionList' could not be resolved as a collection/array/map/enumeration/iterator type


register.jsp

<%@ taglib prefix="s" uri="/struts-tags" %>

<html>
<head>
<title>Struts 2 Insert Data Application!</title>
</head>
<body>
<s:form action="Register" method="POST" validate="false">
<s:select
name="bookCondition" list="conditionList" headerKey="0" headerValue="--
Select Book Condition" label="Condition" />
<s:submit value="Save" align="center"/>
</s:form>
</body>
</html>

RegisterAction.java
package BookRez.Database;

import java.util.ArrayList;

import com.opensymphony.xwork2.ActionSupport;

public class RegisterAction extends ActionSupport {
   
    private ArrayList<String> conditionList;

    public String populate() {
        conditionList = new ArrayList<String>();
        conditionList.add("Like New");
        conditionList.add("Very Good");
        conditionList.add("Good");
        conditionList.add("Acceptable");
        return "populate";
    }

    public String execute() {
        return SUCCESS;
    }

    public ArrayList<String> getConditionList() {
        return conditionList;
    }

    public void setCountryList(ArrayList<String> conditionList) {
        this.conditionList = conditionList;
    }
}

struts.xml
<struts>
    <package name="BookRez" extends="struts-default">
<action name="*Register" method="{1}" class="BookRez.Database.RegisterAction">
                <result name="populate">/register.jsp</result>
                <result name="input">/register.jsp</result>
                <result name="success">/success.jsp</result>
        </action>
    </package>
</struts> 
 		 	   		  

Re: s:select dropdown box problem: cannot locate list

Posted by Kushan Jayathilake <ku...@gmail.com>.
When you invoking the page through the browser, you will be typing something
similar to this right?

*http://localhost:<port>/app_name/action_name*

So it will be as *http://localhost:<port>/app_name/Register.*

and i'm not sure whether mentioning *method="{1}"* will call the
*populate *method
there.

try by putting method="populate" also..




On Tue, Apr 5, 2011 at 2:31 PM, Jeff Huang <je...@hotmail.com> wrote:

>
> Hi All,
>
> I need urgent help on this!
> help greatly appreciated..been stuck on this for a LONG time!
> it is not able to locate conditionList
>
> Servlet.service() for servlet jsp threw exception
> tag 'select', field 'list', name 'bookCondition': The requested list key
> 'conditionList' could not be resolved as a
> collection/array/map/enumeration/iterator type
>
>
> register.jsp
>
> <%@ taglib prefix="s" uri="/struts-tags" %>
>
> <html>
> <head>
> <title>Struts 2 Insert Data Application!</title>
> </head>
> <body>
> <s:form action="Register" method="POST" validate="false">
> <s:select
> name="bookCondition" list="conditionList" headerKey="0" headerValue="--
> Select Book Condition" label="Condition" />
> <s:submit value="Save" align="center"/>
> </s:form>
> </body>
> </html>
>
> RegisterAction.java
> package BookRez.Database;
>
> import java.util.ArrayList;
>
> import com.opensymphony.xwork2.ActionSupport;
>
> public class RegisterAction extends ActionSupport {
>
>    private ArrayList<String> conditionList;
>
>    public String populate() {
>        conditionList = new ArrayList<String>();
>        conditionList.add("Like New");
>        conditionList.add("Very Good");
>        conditionList.add("Good");
>        conditionList.add("Acceptable");
>        return "populate";
>    }
>
>    public String execute() {
>        return SUCCESS;
>    }
>
>    public ArrayList<String> getConditionList() {
>        return conditionList;
>    }
>
>    public void setCountryList(ArrayList<String> conditionList) {
>        this.conditionList = conditionList;
>    }
> }
>
> struts.xml
> <struts>
>    <package name="BookRez" extends="struts-default">
> <action name="*Register" method="{1}"
> class="BookRez.Database.RegisterAction">
>                <result name="populate">/register.jsp</result>
>                <result name="input">/register.jsp</result>
>                <result name="success">/success.jsp</result>
>        </action>
>    </package>
> </struts>
>




-- 
Regards
Kushan Jayathilake