<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>
类型(枚举):
D("Doctor"), R("Resident"), I("Instructor");
private String type;
private Type(String type) {
this.type = type;
}
public String getType() {
return type;
}
豆:
@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
答案 0 :(得分:0)
您必须在视图文件中添加<h:head/>
。 Primefaces查找此标记并将其组件(CSS和JS)放入其中。
请阅读我之前关于设置p:selectonemenu
的评论。也许你有错。