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>


原文链接: http://blog.csdn.net/vanessa219/article/details/4001425

你可能感兴趣的:(JSF select 组件)