• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts - logic:iterator used with html:select

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Collection of IDs. These IDs are of type Integer. I want to iterate over this Collection and for each iteration I want display a dropdown using <html:select....>. Here is the relavent code:

TaskForm.java:

private Collection AdditonalAssignmentIDs = Collections.EMPTY_LIST;
....


TaskAction.java:

Vector IDs = new Vector();
Collection tasks = TaskAssignmentDat.findActiveByTask(task);
for (Iterator iter = tasks.iterator(); iter.hasNext(); ) {
Task task = (Task)iter.next();
Integer employeeID = task.getEmployeeId();
IDs.add(employeeID);
}
taskForm.setAdditonalAssignmentIDs(IDs);



Task.jsp:

<logic:iterate id="ID" name="AdditonalAssignmentIDs"
type="java.lang.Integer">
<tr>
<td>
<html:select styleClass="input" alt="Additional Assignee"
property="ID" size="1">
<html ption value="">--------------</html ption>
<html ptions collection="leaders" property="employeeId"
labelProperty="employeeLabel"/>
</html:select>
</td>
</logic>

The compile time error I am running into is:
"javax.servlet.jsp.JspException: No getter method available for property ID for bean under name org.apache.struts.taglib.html.BEAN"

Any ideas on how to resolve this? Do I need to create a bean whose only attribute is an Integer in order to have the getter and setter methods?

Thanks,
Matt
 
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<html:select styleClass="input" alt="Additional Assignee" property="ID" size="1">
This is causing Struts to look for the method getID() on your form bean.

You probably need to use the "value" attribute.
<html:select styleClass="input" alt="Additional Assignee" value="ID" property="ID" size="1" >

For the "property" attribute the documentation says:

Name of the request parameter that will be included with this submission, set to the specified value.



Sheldon Fernandes
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That error about the getter method is not complaining about Integer missing a getter method; it is looking for getID() in your ActionForm.

But add the method and you still have another problem - all of your dropdowns will access the same getter and setter method with no way to tell the difference between them.

This might be a good opportunity for a map-backed solution:

and then change your html:select to -
<html:select styleClass="input" alt="Additional Assignee"
property='<%= "value(" + ID + ")" %>' size="1">
 
reply
    Bookmark Topic Watch Topic
  • New Topic