Tapestry framework component -------propertyselection

 from:james

Tapestry framework component -------propertyselection

Parameters

Name

Type

Direction

Required

Default

 

value

Object

in-out

yes

 

 

model

IPropertySelectionModel

in

yes

 

 

disabled

boolean

in

no

false

 

submitOnChange (deprecated)

boolean

in

no

false

 

displayName

String

in

no

 

 

validators

Array or collection of Validator, or Validator

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);


 [j1]Must be the model class.

 [j2]Or null,if is null look the paramet on the top

 [j3]Must return IPropertySelectionModel’s class or its subclass.

 [j4]Create a items from database or …

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值