Jsf 2 JSF表单验证和更新
我有一个复杂的表单,它包含一个SelectOne菜单,我可以从中选择一个用于添加到表中的值。问题是,当对所有字段进行验证时,我无法使其工作。我尝试了多种解决方案,但都无法奏效。如果有人能指导我,我将不胜感激,因为我不是很有经验,但非常渴望学习。thx提前Jsf 2 JSF表单验证和更新,jsf-2,Jsf 2,我有一个复杂的表单,它包含一个SelectOne菜单,我可以从中选择一个用于添加到表中的值。问题是,当对所有字段进行验证时,我无法使其工作。我尝试了多种解决方案,但都无法奏效。如果有人能指导我,我将不胜感激,因为我不是很有经验,但非常渴望学习。thx提前 <h:form class="add-form"> <div class="row"> <fieldset class=
<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更新版,但都没有成功。如果我解释得不够清楚,我很抱歉。请询问更多信息用下面的代码替换您的添加链接
<h:commandLink actionListener="#{candidateBean.addWorkingCity}"
styleClass="btn btn-primary form-control input-sm"
title="Add">
<span class="glyphicon glyphicon-plus"></span> Add
</h:commandLink>
确保CandidateBean的可视范围为或更宽 -1因为你需要花更多的时间解释你的代码和你想做什么。你所说的只是验证有问题,你尝试了一些解决方案。什么解决方案?你所说的验证问题是什么意思?
<h:commandLink title="Remove"
styleClass="btn btn-primary btn-xs"
action="#{candidateBean.removeWorkingCity(currentCity)}"
>
<span class="glyphicon glyphicon-remove"></span> Remove
</h:commandLink>
public void removeWorkingCity(City c) {
workingCities.remove(c);
}