There are several examples of how to use "Select" component in the following
link.
They may help you to figure out what's wrong with your code.
http://lombok.demon.co.uk/tapestry5Demo/

Cheers,
Jeffrey Ai


Penyihir Kecil-2 wrote:
> 
> i tried select component but i have difficulty and got stuck on it.
> i had already read the archive milis, but still have no idea what had
> happened with mine
> here's my code....
> 
> i always get null value(no data) to diplay in my select component.
> when i debug it,
> 
> getPositionList() in Home.java always return a list of value.
> but it doesn't work when i try to call the model : return new
> PositionSelectionModel(getPositionList());
> 
> does anyone can help clear me up....
> 
> thnx...
> *
> -----------------------------------------------------------------------------------------------------
> Home.tml*
> <select t:type="select" t:id="position" value="position"
> model="positionSelectionModel" encoder="valueEncoder"/>
> 
> -------------------------------------------------------------------------------------------------
> *Home.java
> .....
> 
> *private PositionSelectionModel positionSelectionModel;
>     public PositionSelectionModel getPositionSelectionModel() {
>         setPositionList(getPositionDao().queryForList("", ""));
>         return new PositionSelectionModel(getPositionList());
>     }
>     public ValueEncoder<Position> getValueEncoder(){
>         return new PositionValueEncoder(getPositionList());
>     }
> 
> ......
> ------------------------------------------------------------------------------------------------------
> *PositionSelectionModel .java *
> 
> public class PositionSelectionModel implements SelectModel {
>     private List<Position> positionList;
> 
>     public PositionSelectionModel(List<Position> positionList){
>         this.positionList = positionList;
>     }
> 
>     public List<OptionGroupModel> getOptionGroups() {
>         return null;
>     }
> 
>     public List<OptionModel> getOptions() {
>         List<OptionModel> optionModelList = new ArrayList<OptionModel>();
> 
>         for(Position position: positionList) {
>             System.out.println(position.getPosition());
>             optionModelList.add(new
> OptionModelImpl(position.getPosition(),
> false, position,new String[0]));
>         }
> 
>         return optionModelList;
>     }
> 
>     public void visit(SelectModelVisitor arg0) {
> 
>     }
> 
> }
> ------------------------------------------------------------------------------------------------------------------------------
> 
> *PositionValueEncoder.java*
> 
> public class PositionValueEncoder implements ValueEncoder<Position> {
>     private List<Position> positionList;
> 
>     public PositionValueEncoder(List positionList) {
>         this.positionList = positionList;
>     }
>     public String toClient(Position position) {
>         return position.getPosition();
>     }
> 
>     public Position toValue(String value) {
>         for(Position position : positionList) {
>             if(position.getPosition().equals(value)) {
>                 return position;
>             }
>         }
>         return null;
>     }
> }
> 
> 

-- 
View this message in context: 
http://www.nabble.com/T5-%3A-NULL-%28no-data%29display-for-SELECT-component---tp14275375p14279159.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to