Tapestry framework component -------propertyselection
Parameters
Name | Type | Direction | Required | Default |
|
value | Object | in-out | yes |
|
|
model | in | yes |
|
| |
disabled | boolean | in | no | false |
|
submitOnChange (deprecated) | boolean | in | no | false |
|
displayName | String | in | no |
|
|
validators | in | no |
|
| |
id | String | in | no |
|
|
And the param value des is----The property to set. During rendering, this property is read, and sets the default value of the selection (if it is null, no element is selected). When the form is submitted, this property is updated based on the new selection.
Model des is-----The model provides a list of possible labels, and matches those labels against possible values that can be assigned back to the property.
Disabled des is-----Controls whether the <select> is active or not. A disabled PropertySelection does not update its value parameter. Corresponds to the "disabled" HTML attribute.
Submitonchange des is----If true, then additional JavaScript is added to submit the containing form when select is changed. Equivalent to specifying a JavaScript event handler of this.form.submit().
Displayname des is----The user-presentable name for the component, which will be used by a FieldLabel connected to the component.
example
1.First wirte a model : user.java
2.Then create a IPropertySelectionModel class:
public class ItemSelectionModel implements IPropertySelectionModel, Serializable {
private List itemList;
public ItemSelectionModel(List itemList) {
this.itemList = itemList;
}
public int getOptionCount() { return itemList.size(); }
public Object getOption(int index) {
return itemList.get(index);
}
public String getLabel(int index) {
return ((User[j1] ) itemList.get(index)).getName();
}
public String getValue(int index) { return Integer.toString(index); }
public Object translateValue(String value) {
return getOption(Integer.parseInt(value));
}
}
3.Then in out html will add this:
<form jwcid="@Form">
<span jwcid="itemSelection">
</span>
4.And java for page will:
@Component(id="itemSelection",type="PropertySelection",bindings={"model=itemSelectiontest","value=ognl:item[j2] "})
public abstract IComponent getItemSelection();
public ItemSelectionModel [j3] getItemSelectiontest() {
List items = new ArrayList();
items[j4] =//. . . . . . . . . .
ItemSelectionModel model = new ItemSelectionModel(items);
return model;
}
public abstract User getItem();
public abstract void setItem(User value);