在我点击页面中的“保存”时引入了验证后,没有任何反应。在页面中,我有“保存”和“取消”。我将“immediate=true”设置为取消按钮,这样就不会执行任何验证,它会按预期返回到前一个视图。当我单击保存时,将执行验证并正确显示错误,但是如果/当我输入正确的输入时(以便验证没有错误),而不是处理数据并返回上一页,什么也没有发生...
我错过了什么吗?
这里有一些代码片段:
看法:
<f:metadata>
<f:viewParam name="mode" value="#{roomDetailController.model.mode}"/>
<f:viewParam name="dbId" value="#{roomDetailController.model.dbId}"/>
<f:event listener="#{roomDetailController.processCommand}" type="preRenderView"/>
</f:metadata>
...
<tr>
<td>
<h:outputLabel value="#{msg.roomFormFieldRoomName}:"/>
</td>
<td>
<h:inputText id="roomName" value="#{detailModel.afterObject.roomName}" disabled="#{detailModel.mode == detailModel.viewMode}">
<f:validateBean/>
</h:inputText>
<h:message for="roomName" style="color:red"/><br/>
</td>
</tr>
<tr>
<td>
<h:outputLabel value="#{msg.roomFormFieldRoomIPs}:"/>
</td>
<td>
<h:inputText id="roomIPs" value="#{detailModel.afterObject.roomIPs}" disabled="#{detailModel.mode == detailModel.viewMode}">
<f:validateBean/>
</h:inputText>
<h:message for="roomIPs" style="color:red"/><br/>
</td>
</tr>
...
<!-- SUBMIT BUTTON -->
<h:commandButton
styleClass = "waiButton"
value = "#{commonButtonSubmit}"
action = "#{detailController.submitAction()}"
rendered = "#{detailModel.mode != detailModel.viewMode}"
/>
<!-- CANCEL BUTTON -->
<h:commandButton
styleClass = "waiButton"
value = "#{commonButtonCancel}"
action = "#{detailController.cancelAction()}"
immediate = "true"
rendered = "#{detailModel.mode == detailModel.cancelMode or detailModel.mode == detailModel.editMode or detailModel.mode == detailModel.multiEditMode or detailModel.mode == detailModel.createMode}"
/>
...
控制器:
...
// Action: "submit" clicked
public String submitAction()
{
detailModel.setCommand( DetailModel.Command.SUBMIT );
return null;
}
// Action: "cancel" clicked
public String cancelAction()
{
if ( detailModel.getEditMode().equals( detailModel.getMode() ) )
{
detailModel.setMode( detailModel.getViewMode() );
return null;
}
else
{
// Multi Edit Mode
return appendUrlParameter( getListViewName(), FACES_REDIRECT_TRUE );
}
}
...
如果您需要更多信息,请告诉我...