zoukankan      html  css  js  c++  java
  • JSF 2 multiple select dropdown box example

    In JSF, <h:selectManyMenu /> tag is used to render a multiple select dropdown box – HTML select element with “multiple” and “size=1” attribute.

    //JSF...
    <h:selectManyMenu value="#{user.favCoffee1}">
       	<f:selectItem itemValue="Cream Latte" itemLabel="Coffee3 - Cream Latte" />
       	<f:selectItem itemValue="Extreme Mocha" itemLabel="Coffee3 - Extreme Mocha" />
       	<f:selectItem itemValue="Buena Vista" itemLabel="Coffee3 - Buena Vista" />
    </h:selectManyMenu>
    
    //HTML output...
    <select name="j_idt6:j_idt8" multiple="multiple" size="1">	
    	<option value="Cream Latte">Coffee3 - Cream Latte</option>
    	<option value="Extreme Mocha">Coffee3 - Extreme Mocha</option>
    	<option value="Buena Vista">Coffee3 - Buena Vista</option>
    </select>
    

    However, the use of h:selectManyMenu tag is highly NOT recommended, because they do not display consistently in different internet browsers, see figures :

    1. Internet Explorer 8

    A tiny scroll bar to manipulate the dropdown box values.
    jsf2-selectManyMenu-IE-example

    2. FireFox 3.6.10

    No scroll bar, look like a normal “textbox”, but you can click on the “textbox” and “drag up or down” or “key up and down” to manipulate the value.
    jsf2-selectManyMenu-FireFox-example

    3. Google Chrome 6.0.472.63

    In Google Chrome, both << select element with "multiple" and size="1" attribute - "h:selectManyMenu” tag >> and << select element with "multiple" and size="total of records" attribute - "h:selectManyListbox” tag >> are display the exact layout.
    jsf2-selectManyMenu-Chrome-example

    Conclusion

    Just forget about “h:selectManyMenu” tag, there is really no reason to use it. The “h:selectManyListbox” tag is a good alternative.

  • 相关阅读:
    关于List,Set,Map集合的遍历方法
    关于内部类的了解
    for循环打印图形的详细解析(三角形)
    SSH 免密码登录
    foreach 和 for 的区别
    有关Java集合的区别,和常用方法的总结
    hadoop完全分布式的安装
    对于Oracle analyze table的使用总结 . 对于Oracle analyze table的使用总结 .
    Oracle执行计划与统计信息的一些总结
    oracle10g 统计信息查看、收集
  • 原文地址:https://www.cnblogs.com/ghgyj/p/4765390.html
Copyright © 2011-2022 走看看