首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SelectOneMenu PrimeFaces

SelectOneMenu PrimeFaces
EN

Stack Overflow用户
提问于 2015-10-13 04:26:02
回答 1查看 130关注 0票数 0
代码语言:javascript
复制
<h:body>
    <div class="container body-content">
        <h2>Create</h2>
        <h:form id="frm">
            <div class="form-horizontal">
                <h4>Doctor</h4>
            <hr />
            <div class="form-group">
                <h:outputLabel class="control-label col-md-2" for="name"
                    value="Name" />
                <div class="col-md-10">
                    <p:inputText class="form-control text-box single-line" id="name"
                        name="name" value="" placeholder="Ex: John Smith"
                        autofocus="true" maxlength="100" required="true"></p:inputText>
                </div>
            </div>

            <div class="form-group">
                <h:outputLabel class="control-label col-md-2" for="address"
                    value="Address"></h:outputLabel>
                <div class="col-md-10">
                    <p:inputText class="form-control text-box single-line"
                        id="address" name="address" type="text" value=""
                        placeholder="Ex: Fifth Avenue" maxlength="100" required="true"></p:inputText>
                </div>
            </div>

            <div class="form-group">
                <h:outputLabel class="control-label col-md-2" for="cpf" value="CPF"></h:outputLabel>
                <div class="col-md-10">
                    <p:inputMask class="form-control text-box single-line" id="cpf"
                        name="cpf" value="" maxlength="14"
                        placeholder="Ex: 999.999.999-99" required="true"
                        mask="999.999.999-99"></p:inputMask>
                </div>
            </div>

            <div class="form-group">
                <h:outputLabel class="control-label col-md-2" for="phone"
                    value="Phone"></h:outputLabel>
                <div class="col-md-10">
                    <p:inputText class="form-control text-box single-line" id="phone"
                        name="phone" type="tel" value="" placeholder="Ex: (99)9999-9999"
                        maxlength="15" required="true"></p:inputText>
                </div>
            </div>

            <div class="form-group">
                <h:outputLabel class="control-label col-md-2" for="crm" value="CRM"></h:outputLabel>
                <div class="col-md-10">
                    <p:inputText class="form-control text-box single-line" id="crm"
                        name="crm" type="number" min="1" max="1000" step="10" value="" placeholder="Ex: 1234"
                        maxlength="4" required="true"></p:inputText>
                </div>
            </div>

            <div class="form-group">
                <h:outputLabel class="control-label col-md-2"
                    value="Type"></h:outputLabel>
                <div class="col-md-10">
                    <p:selectOneMenu id="type" name="type" value="#{bean.types}"
                        required="true">
                        <f:selectItem itemLabel="-- Select --" itemValue="" />
                        <f:selectItems value="#{bean.types}" var="type"
                            itemLabel="#{type}" itemValue="#{type}" />
                    </p:selectOneMenu>
                </div>
            </div>
        </div>
    </h:form>
</div>

类型(Enum):

代码语言:javascript
复制
D("Doctor"), R("Resident"), I("Instructor");

    private String type;

    private Type(String type) {
        this.type = type;
    }

    public String getType() {
        return type;
    }

豆子:

代码语言:javascript
复制
@ManagedBean
@ViewScoped
public class Bean {

    private Type type;

    public Type getType() {
        return type;
    }

    public List<String> getTypes() {
        List<String> types = new ArrayList<String>();

        for (Type t : Type.values())
            types.add(t.getType());

        return types;
    }

嗯,我不知道为什么,但是在“选择一个菜单”的部分出现了一个输入文本和一个列表。我不知道我的密码有什么问题。因为,我不能把照片贴在这里..。

链接:https://www.dropbox.com/s/gnmgolurk51f680/Annoying.jpg?dl=0

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-14 08:00:15

您必须在视图文件中添加<h:head/>。Primefaces查找此标记并将其组件(CSS和JS)放入其中。

请阅读我之前关于设置p:selectonemenu的评论。也许你搞错了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33094113

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档