• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..
 
Ranch Hand
Posts: 122
Mac IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 : https://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.


 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic