You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Greg Reddin <Gr...@alltel.com> on 2001/03/23 16:11:00 UTC

FormBean population problem

Forgive me if this has been addressed before.

I have something like the following in my request form:
<select name="searchCriteria">
  <option value="1">Option 1</option>
  <option value="2">Option 2</option>
  <option value="3">Option 3</option>
</select>

My Form bean looks like this:

private Integer searchCriteria = null;

public setSearchCriteria(int searchCriteria)
{
   this.searchCriteria = new Integer(searchCriteria);
}

public Integer getSearchCriteria()
{
   return this.searchCriteria;
}

The problem is that even though the "searchCriteria" parameter is being sent to
me in the request, the bean is not being populated.  What am I missing here?

Here's some background:
1)  We need the get method of the bean to return an Integer, so it can be null.
2)  We use XSL as our output format instead of JSP, so the bean is never
     used from a <useBean> tag.

Any ideas of why this is not being populated?

Thanks,
Greg

Re: FormBean population problem

Posted by Cecil Pang <cp...@10dt.com>.
Don't you have to define the setter to take a String?

setSearchCriteria(String searchCriteria)


At 09:11 AM 3/23/2001 -0600, you wrote:
>Forgive me if this has been addressed before.
>
>I have something like the following in my request form:
><select name="searchCriteria">
>   <option value="1">Option 1</option>
>   <option value="2">Option 2</option>
>   <option value="3">Option 3</option>
></select>
>
>My Form bean looks like this:
>
>private Integer searchCriteria = null;
>
>public setSearchCriteria(int searchCriteria)
>{
>    this.searchCriteria = new Integer(searchCriteria);
>}
>
>public Integer getSearchCriteria()
>{
>    return this.searchCriteria;
>}
>
>The problem is that even though the "searchCriteria" parameter is being 
>sent to
>me in the request, the bean is not being populated.  What am I missing here?
>
>Here's some background:
>1)  We need the get method of the bean to return an Integer, so it can be 
>null.
>2)  We use XSL as our output format instead of JSP, so the bean is never
>      used from a <useBean> tag.
>
>Any ideas of why this is not being populated?
>
>Thanks,
>Greg