...
Wiki Markup |
---|
Unlike Map and List element properties, if fooCollection(22) does not exist it will not be created. To do that, use the notation *fooCollection.makeNew\[index\]* where index is an integer 0, 1, and so on. Thus, parameter value pairs *fooCollection.makeNew\[0\]=Phil* and *fooCollection.makeNew\[1\]=John* would add two new Foo objects to fooCollection one with name property value Phil and the other with name property value Bar. Note, however, that in the case of a Set, the equals and hashCode methods should be defined such that they don't only include the id property. That will cause one element of the null id propertied Foos to be removed from the Set. |
Sample
Code Block | ||||
---|---|---|---|---|
| ||||
public class MyBean implements Serializable {
private Long id;
private String name;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String toString() {
return "MyBean{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
}
|
Code Block | ||||
---|---|---|---|---|
| ||||
ublic class MyBeanAction implements Action {
private List beanList = new ArrayList();
private Map beanMap = new HashMap();
public List getBeanList() {
return beanList;
}
public void setBeanList(List beanList) {
this.beanList = beanList;
}
public Map getBeanMap() {
return beanMap;
}
public void setBeanMap(Map beanMap) {
this.beanMap = beanMap;
}
public String execute() throws Exception {
return SUCCESS;
}
}
|
Code Block | ||||
---|---|---|---|---|
| ||||
KeyProperty_beanList=id
Element_beanList=com.opensymphony.xwork.util.MyBean
CreateIfNull_beanList=true
Key_beanMap=java.lang.Long
KeyProperty_beanMap=id
Element_beanMap=com.opensymphony.xwork.util.MyBean
|
Type Conversion Error Handling
...