Good Afternoon Mike-
Tough to diagnose without seeing the service interface defined in your
action
e.g.
public class HHSAction implements Preparable {
private HHSService service;
}
package quickstart.service;
import java.util.List;
import quickstart.model.Person;
public interface HHSService
{
public List<Person> findAll();
public void save(Person person);
public Person find(int id);
}
?
Martin-
----- Original Message -----
From: "Griffith, Michael *" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[email protected]>
Sent: Friday, April 18, 2008 10:33 AM
Subject: Clarification on Type Conversion?
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
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]