Shwetanka
Shwetanka

Reputation: 5046

<html:select> problem with <html:options> tag

I've a form with struts tags as below.

<html:form styleId='catform' action='/cat/submit.html' method='post'>
   <html:select property='catName' styleId='catName'>
      <html:options collection='catList' property='category'>
   </html:select>
</html:form>

In my action I'm setting catList as below

 List <Category> catList = getCategoryList();
   request.setAttribute("catList", catList);

here Category is a class with catName and catId as variables.

I'm getting an error which says no getter for the property category found. What am I missing?

Upvotes: 1

Views: 6020

Answers (2)

kgautron
kgautron

Reputation: 8293

You need to put either a "collection", which is done between java tags like this :

collection="<%= myCollection %>"

or to use the "name" and "property" attributes like this :

name="mybean" property="beanPropertyWhichContainsTheCollection"

Don't use both "property" and "collection" attributes.

Upvotes: 1

Liviu T.
Liviu T.

Reputation: 23664

You need to put

<html:options collection='catList' property='catId' labelProperty='catName'>

struts is trying to get the category property of the Category instance

Upvotes: 2

Related Questions