1.h:commandButton 删除一个对象。
<h:commandButton value="删除厨房" οnclick="return confirm('确定删除?')" action="#{kitchenController.delete()}">
<f:setPropertyActionListener target="#{kitchenController.kitchen.id}" value="#{kitchen.id}"/>
</h:commandButton>
2.点击 h:selectOneRadio 刷新。
<h:selectOneRadio value="#{kitchenController.listCondition}" οnclick="this.form.submit();" >
<f:selectItem itemValue="all" itemLabel="全部"/>
<f:selectItem itemValue="can" itemLabel="看允许发布餐饮的厨房"/>
<f:selectItem itemValue="cannot" itemLabel="看不允许发布餐饮的厨房"/>
</h:selectOneRadio>
3.按钮提交 h:selectOneRadio 的更新。
<h:form>
<span>针对该厨房的订单,是否需要中央管理后台审核</span><br></br>
<h:selectOneRadio value="#{kitchen.needAuditOrders}">
<f:selectItem itemValue="true" itemLabel="需要审核"/>
<f:selectItem itemValue="false" itemLabel="不需要审核"/>
</h:selectOneRadio>
<h:commandButton value="提交" action="#{kitchenController.modifyCheck()}" class="submit_review">
<f:setPropertyActionListener target="#{kitchenController.kitchen.id}" value="#{kitchen.id}" />
<f:setPropertyActionListener target="#{kitchenController.kitchen.needAuditOrders}" value="#{kitchen.needAuditOrders}"/>
</h:commandButton>
</h:form>
如果是修改list 里的内容,必须保证list 不更新。public List<Kitchen> getKitchens(){
if(kitchens != null && !refreshList){
return kitchens;
}
// 其他代码
return kitchens;
}
4.f:validateRegex 匹配电话。
<label for="admin_contact">联系电话(如:13866669999)</label>
<h:message for="admin_contact" style="color:red" class="error-message"/>
<h:inputText value="#{kitchenController.adminTel}" validatorMessage="格式不正确" requiredMessage="必填" required="true" id="admin_contact" class="text ui-widget-content ui-corner-all">
<f:validateRegex pattern="((?=.*\d).{11})" />
</h:inputText>
或
<f:validateRegex pattern="((?=.*\d)(?=.*[-]).{12}|(?=.*\d).{11})" />
匹配13866669999 或 021-81234567。
5.c:if
<c:forEach var="admin" items="#{kitchenController.admins}">
<c:if test="#{admin.loginId == kitchen.adminId}">
<span>duty:</span><span class="admin_role">#{admin.duty}</span>
<span>tel:</span><span class="admin_contact">#{admin.tel}</span>
</c:if>
</c:forEach>
6.c:choose
<c:choose>
<c:when test="${..}">...</c:when> <!-- if condition -->
<c:when test="${..}">...</c:when> <!-- else if condition -->
<c:otherwise>...</c:otherwise> <!-- else condition -->
</c:choose>