name="status" means that you are trying to pass the status object itself as
a parameter to a method setStatus. That is not possible--you need to pass
the id of the status if you want to indicate which status the user chose,
like this for example:
<s:select key="form.status" name="id"
    list="statusList"
    listKey="id"
    listValue="description"/>

You also need setId method in the action you submit the form to.

On Fri, Apr 18, 2008 at 5:33 PM, Griffith, Michael * <
[EMAIL PROTECTED]> wrote:

> Hello All,
>
>
>
> I am having a problem with Struts 2 form submission, because I believe a
> related <s:select> field is not being converted correctly.  I have read
> the documentation at: http://struts.apache.org/2.x/docs/select.html and
> http://struts.apache.org/2.0.11.1/docs/type-conversion.html  It is my
> understanding that I should not need to provide any custom converter,
> that this conversion should be automatic.  When I submit the form, I
> receive the error: Invalid field value for field "status".
>
>
>
> Here is the setup:
>
>
>
> I have a form with a <s:select> field:
>
>            <s:select key="form.status" name="status"
>
>                               list="statusList"
>
>                               listKey="id"
>
>                               listValue="description"/>
>
>
>
> The action has the method:
>
>
>
>            public List<Status> getStatusList(){
>
>                        return statusService.findAll();
>
>            }
>
>
>
> The model object that status is mapped to looks like this:
>
>
>
> @Entity
>
> @Table(name="STATUS")
>
> @Validation
>
> public class Status implements Identifiable, Serializable {
>
>
>
>            private static final long serialVersionUID =
> -8017026685032314796L;
>
>            private Integer id;
>
>            private String description;
>
>
>
>            @Id
>
>            @GeneratedValue(strategy = GenerationType.AUTO)
>
>            @Column(name = "ID", unique = true, nullable= false)
>
>            public Integer getId() {
>
>                        return id;
>
>            }
>
>
>
>            public void setId(Integer id){
>
>                        this.id= id;
>
>            }
>
>
>
>            @Column(name="DESCRIPTION", nullable= false)
>
>            public String getDescription() {
>
>                        return description;
>
>            }
>
>
>
>            @RequiredStringValidator(message="Validation Error",
> key="validate.notEmpty", trim=true)
>
>            public void setDescription(String description) {
>
>                        this.description = description;
>
>            }
>
>
>
> I tried creating a mapping properties file called
> actionName-conversion.properties:
>
> KeyProperty_StatusList=id
>
> Element_StatusList=Status
>
> CreateIfNull_statusList=true
>
>
>
> No avail.  I'm sure my problem is obvious, but I can't see it. Any help
> or suggestions would be much appreciated...
>
>
>
> Thanks in advance!
>
> Michael Griffith
>
>
>
>
>
>

Reply via email to