Meaningless Drivel is fun!*
The moose likes Struts and the fly likes <html:options> and ActionForms Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "&lt;html:options&gt; and ActionForms" Watch "&lt;html:options&gt; and ActionForms" New topic
Author

&lt;html:options&gt; and ActionForms

Matt Connors
Greenhorn

Joined: Sep 08, 2004
Posts: 23
I need some help with finding the correct syntax for the <html ptions> tag.

Form Bean Code:

public class ActivityForm extends ActionForm {
private Collection departments;
private Collection categories;
...
public Collection getDepartments() {
return departments;
}
public void setDepartments(Collection departments) {
this.departments = departments;
}

JSP Code:
...
<tr>
<th class="required">Department:</th>
<td class="input">
<html:select styleClass="input" alt="Department"
property="departmentId" size="1">
<html ption value="">--------------</html ption>
<html ptions property="departments"
labelProperty="departmentLabel"/>
</html:select>
</td>
</tr>
...

The runtime error I receive is:

javax.servlet.jsp.JspException: No getter method available for property departmentLabel for bean under name null

In fact, the departments Collection is made up of department records and the department records DO have a getter method for departmentLabel.

Can anyone tell me the correct syntax?

Thanks,
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4442
    
    5

I highly recommend using the optionsCollection tag instead. The attributes are better named and the intent is much clearer than the options tag. In your case, it would be


[ October 07, 2004: Message edited by: Junilu Lacar ]

Junilu - [How to Ask Questions] [How to Answer Questions]
Matt Connors
Greenhorn

Joined: Sep 08, 2004
Posts: 23
Many Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: &lt;html:options&gt; and ActionForms
 
Similar Threads
Validation of Html options
JspException: No getter method
Editing and submitting multiple records
struts - logic:iterator used with html:select
Does validator can't work with html:options tag??