【发布时间】:2015-12-10 13:40:58
【问题描述】:
我有一个复杂的表单,其中包含一个 selectonemenu,我从中选择一个用于添加到表中的值。问题是,当验证所有字段的验证时,我无法使其工作。我尝试了多种解决方案,但无法使其发挥作用。如果有人可以指导我,我将不胜感激,因为我不是很有经验,但非常渴望学习。 thx in advaned
<h:form class="add-form">
<div class="row">
<fieldset class="col-sm-3 col-md-3"><!-- personal info fields -->
<legend>Personal Information</legend>
<div class="required">
<label>First Name</label>
<h:inputText value="#{candidateBean.firstName}"></h:inputText>
</div>
<div class="col-sm-9 col-md-9">
<div class="required">
<label>Select Working City</label>
<h:selectOneMenu value="#{candidateBean.city}" converter="omnifaces.SelectItemsConverter">
<f:selectItem itemValue="#{null}" itemLabel="-- select one --" />
<f:selectItems value="#{settingsBean.settings.citiesListVO.workingCityVO}" var="cities" itemValue="#{cities}" itemLabel="#{cities.name}"/>
</h:selectOneMenu>
</div>
</div>
<div class="col-sm-3 col-md-3">
<div class="required">
<label>Add</label>
<h:commandLink type="button" class="btn btn-primary form-control input-sm"
title="Add"
ajax="false"
href="#!"
actionListener="#{candidateBean.addWorkingCity}">
<span class="glyphicon glyphicon-plus"></span>
</h:commandLink>
</div>
</div>
</div><!-- working cities inputs -->
<div class="row">
<div class="col-sm-12 col-md-12 required">
<label>Current Working Cities:</label><br></br>
<h:dataTable
class="table table-condensed"
value="#{candidateBean.workingCities}" var="currentCity">
<h:column>
<f:facet name="header">
<h:outputText value="City Name" />
</f:facet>
<h:outputText value="#{currentCity.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Options"></h:outputText>
</f:facet>
<h:commandLink type="button" class="btn btn-primary btn-xs"
title="Remove"
ajax="false"
actionListener="#{candidateBean.removeWorkingCity}">
<f:attribute name="selected" value="#{currentCity}"/>
<span class="glyphicon glyphicon-remove"></span>
</h:commandLink>
</h:column>
</h:dataTable>
</div><!-- column -->
</div><!-- workingCity table row -->
这是初始代码。我已经尝试了各种解决方案,例如 ayax 更新,但我没有成功。如果我解释得不够,我很抱歉。请询问更多信息
【问题讨论】:
-
-1 因为你需要花更多的时间来解释你的代码和你试图做什么。您所说的只是您在验证方面遇到了问题,并且您尝试了一些解决方案。有什么解决方案?验证问题是什么意思?
标签: jsf-2