File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes 'select', field 'list', name 'business': The requested list key 'businesses' could not be resolved Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark " Watch " New topic
Author

'select', field 'list', name 'business': The requested list key 'businesses' could not be resolved

Neeraj Narayan
Greenhorn

Joined: Dec 28, 2011
Posts: 4
1. jsp: works fine

<s:form id="createAccountForm" namespace="/accounts"

action="CreateAccount" method="post">

<td><div
class="input-container">

<s:select
label="Business" name="business" id="business"

headerKey="1"
headerValue="Select Business"

list="#{'111':'Food
& Drink- Restaurants/Pubs'}" />

</div></td>

2. jsp: errors out



<td><div
class="input-container">

<s:select
label="Business" name="business" id="business"

headerKey="1"
headerValue="Select Business"

list="businesses"
/>

</div></td>

3. Error:

org.apache.jasper.JasperException: tag 'select', field 'list', name 'business': The requested list key 'businesses' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]


4. CreateAccountAction has the following code:

Map<Long, String> businesses = new HashMap<Long, String>();


public Map<Long, String> getBusinesses() {
return services.getBusinesses();
}

public void setBusinesses(Map<Long, String> businesses) {
this.businesses = businesses;
services.setBusinesses(businesses);
}

5. Services has the following code:

public Map<Long, String> getBusinesses() {
return businesses;
}
public void setBusinesses(Map<Long, String> businesses) {
this.businesses = businesses;
}
Map<Long, String> businesses = new HashMap<Long, String>();


6. struts.xml
<package name="accounts" namespace="/accounts" extends="struts-default">
<action name="CreateAccount"
class="in.firm.bizz.actions.accounts.CreateAccountAction" >
<result>/search/results.jsp</result>
<result name="redirect" type="redirect">${redirectUrl}</result>
</action>

</package>



If would be good if someone could share from his experience what am I missing..
Jesus Mireles
Ranch Hand

Joined: Mar 10, 2010
Posts: 122

You have the map in the wrong action class. From what you have posted it looks like this is the action that the user invokes when the form is submitted.

You need to put your map and getter in setter in the action that is invoked to load this jsp.
Neeraj Narayan
Greenhorn

Joined: Dec 28, 2011
Posts: 4
Thanks for your suggestion and time.

As suggested I put the following lines of code in struts.xml:



And now I am accessing the code using the following action:

http://localhost:8080/bizz.firm.in/RegisterAction.action

The following post was helpful in finding that : http://www.coderanch.com/t/429439/Struts/populate-items-struts-select

But I want it to be accessed using the http://localhost:8080/bizz.firm.in/ which internally calls http://localhost:8080/bizz.firm.in/index.jsp. Please help.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 'select', field 'list', name 'business': The requested list key 'businesses' could not be resolved