🎶 Sym - 一款用 Java 实现的现代化社区(论坛/BBS/社交网络/博客)平台

📕 思源笔记 - 一款桌面端笔记应用,支持 Windows、Mac 和 Linux

🎸 Solo - B3log 分布式社区的博客端节点,欢迎加入下一代社区网络

♏ Vditor - 一款浏览器端的 Markdown 编辑器

JSF select 组件

JSF CODE

                    <h:selectOneMenu value="#{projectAction.beyondTrackUser}">
                        <s:selectItems value="#{projectAction.beyondTrackUserList}"                                                                            var="beyondTrackUser"

                                                label="#{beyondTrackUser.userName}"/>
                    </h:selectOneMenu>

 

注:<s:selectItems>标签可以用于

        <h:selectBooleanCheckbox>
        <h:selectManyCheckbox>
        <h:selectManyListbox>
        <h:selectManyMenu>
        <h:selectOneRadio>
        <h:selectOneMenu>
        <h:selectOneListbox>中。

label是展现在界面的值。

JAVA CODE

 

@Name("projectAction")
@Scope(ScopeType.SESSION)
@AutoCreate
public class ProjectAction implements Serializable {
    private BeyondTrackUser beyondTrackUser;
    private List<BeyondTrackUser> beyondTrackUserList; public List<BeyondTrackUser> getBeyondTrackUserList() {
        if (beyondTrackUserList == null) {
            beyondTrackUserList = new ArrayList<BeyondTrackUser>();
            final BeyondTrackUser beyondTrackUser1 = new BeyondTrackUser();
            beyondTrackUser1.setUserName("Vanessa");
            beyondTrackUser1.setFirstName("liyuan");
            beyondTrackUser1.setLastName("li");
            beyondTrackUser1.setEmail("[email protected]");
            final BeyondTrackUser beyondTrackUser2 = new BeyondTrackUser();
            beyondTrackUser2.setUserName("taoyang");
            beyondTrackUser2.setFirstName("yang");
            beyondTrackUser2.setLastName("tao");
            beyondTrackUser2.setEmail("[email protected]");
            final BeyondTrackUser beyondTrackUser3 = new BeyondTrackUser();
            beyondTrackUser3.setUserName("Daniel");
            beyondTrackUser3.setFirstName("liang");
            beyondTrackUser3.setLastName("ding");
            beyondTrackUser3.setEmail("[email protected]");
            beyondTrackUserList.add(beyondTrackUser1);
            beyondTrackUserList.add(beyondTrackUser2);
            beyondTrackUserList.add(beyondTrackUser3);
        }
        for (BeyondTrackUser user : beyondTrackUserList) {
            logger.debug("beyondtrack user list [name=#0]", user.getUserName());
        }
        return beyondTrackUserList;
    }

对应的HTML代码为:
<select name="_id0:_id1" size="1">
    <option value="1">Vanessa</option>
    <option value="2">taoyang</option>

    <option value="3">Daniel</option>

</select>


欢迎注册黑客派社区,开启你的博客之旅。让学习和分享成为一种习惯!

留下你的脚步