selectitem和selectitems标记之间的区别 [英] Difference between selectitem and selectitems tags

查看:657
本文介绍了selectitem和selectitems标记之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jsf中selectitem和selectitems标记之间有什么区别?

解决方案

不同之处正是您期望的。 selectitem 标记向HTML列表添加单个项目,而 selectitems 添加多个项目。



JSF Core Tag Reference :
$ b

SelectItem:



SelectItem 标记将子元素 UISelectItem 组件添加到与封闭标记关联的组件。在HTML renderkit中,这会创建一个单一元素。它可以与JSF HTML标记库中的任何选择标记一起使用。

示例:



<$ p $这个标签的主体内容必须是空的。 p> < h:selectOneMenu id =list1>
< f:selectItem itemLabel =Option 1itemValue =1>< / f:selectItem>
< / h:selectOneMenu>

HTML输出:

 < select id =list1name =list1size =1> 
< option value =1>选项1< / option>
< / select>



SelectItems:



SelectItems 标记向与封闭标记关联的组件添加子元素 UISelectItems 组件。您可以使用此标记将域模型中的对象列表设置为选定组件的选项。

示例:



<$ p $这个标签的主体内容必须是空的。 p> < h:selectManyListbox id =list>
< / h:selectManyListbox>

HTML输出:

 < select id =listname =listmultiple =truesize = -  2147483648> 
< option value =1>选项1< / option>
< option value =2>选项2< / option>
< option value =3>选项3< / option>
< / select>


What is the difference between the selectitem and selectitems tags in jsf?

解决方案

The difference is exactly what you would expect. The selectitem tag adds a single item to the HTML list while selectitems adds multiple items.

From JSF Core Tag Reference:

SelectItem:

The SelectItem tag adds a child UISelectItem component to the component associated with the enclosing tag. In the HTML renderkit, this creates a single element. It can be used with any of the select tags in the JSF HTML tag library. The body content of this tag must be empty.

Example:

<h:selectOneMenu id="list1">
    <f:selectItem itemLabel="Option 1" itemValue="1"></f:selectItem>
</h:selectOneMenu>

HTML Output:

<select id="list1" name="list1" size="1">
    <option value="1">Option 1</option>
</select>

SelectItems:

The SelectItems tag adds a child UISelectItems component to the component associated with enclosing tag. You can use this tag to set a list of objects in your domain model as the options for a select component. The body content of this tag must be empty.

Example:

<h:selectManyListbox id="list">
    <f:selectItems value="#{optionBean.optionList}"></f:selectItem>
</h:selectManyListbox>

HTML Output:

<select id="list" name="list" multiple="true" size="-2147483648">
    <option value="1">Option 1</option>
    <option value="2">Option 2</option>
    <option value="3">Option 3</option>
</select>

这篇关于selectitem和selectitems标记之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆