tapestry5中select的用法

java 代码
 
  1. // Copyright 2007 The Apache Software Foundation  
  2. //  
  3. // Licensed under the Apache License, Version 2.0 (the "License");  
  4. // you may not use this file except in compliance with the License.  
  5. // You may obtain a copy of the License at  
  6. //  
  7. //     http://www.apache.org/licenses/LICENSE-2.0  
  8. //  
  9. // Unless required by applicable law or agreed to in writing, software  
  10. // distributed under the License is distributed on an "AS IS" BASIS,  
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
  12. // See the License for the specific language governing permissions and  
  13. // limitations under the License.  
  14.   
  15. package org.qiwen.pages;  
  16.   
  17. import java.util.Map;  
  18.   
  19. import org.apache.tapestry.Block;  
  20. import org.apache.tapestry.annotations.Inject;  
  21. import org.apache.tapestry.annotations.Persist;  
  22. import org.apache.tapestry.annotations.Retain;  
  23. import org.apache.tapestry.ioc.internal.util.CollectionFactory;  
  24.   
  25. public class BlockDemo  
  26. {  
  27.     @Inject  
  28.     private Block _fred;  
  29.   
  30.     @Inject  
  31.     private Block _barney;  
  32.   
  33.     // Blocks not injected until page load, so must lazily initialize the map.  
  34.     @Retain  
  35.     private Map<String, Block> _blocks = null;  
  36.   
  37.     @Persist  
  38.     private String _blockName;  
  39.   
  40.     public Block getBlockToRender()  
  41.     {  
  42.         if (_blocks == null)  
  43.         {  
  44.             _blocks = CollectionFactory.newMap();  
  45.             _blocks.put("fred", _fred);  
  46.             _blocks.put("barney", _barney);  
  47.         }  
  48.   
  49.         return _blocks.get(_blockName);  
  50.     }  
  51.   
  52.     public String getBlockName()  
  53.     {  
  54.         return _blockName;  
  55.     }  
  56.   
  57.     public void setBlockName(String blockName)  
  58.     {  
  59.         _blockName = blockName;  
  60.     }  
  61.   
  62. }  


Html 代码
 
  1. <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">   
  2.       
  3.     <form t:type="Form">  
  4.         <select t:type="Select" t:id="blockName" model="',fred,barney'" onchange="this.form.submit();"/>   
  5.         <label t:type="Label" for="blockName">Block to display</label>  
  6.     </form>  
  7.       
  8.     <p>The block: ${blockToRender}</p>  
  9.           
  10. </html>  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值