Jsf 使用richfaces选项卡面板在选项卡开关上防止表单提交
有一个选项卡面板,类似于:Jsf 使用richfaces选项卡面板在选项卡开关上防止表单提交,jsf,tabs,richfaces,submit,Jsf,Tabs,Richfaces,Submit,有一个选项卡面板,类似于: <rich:tabPanel > <rich:tab header="Description" > <ui:include src="./tests/description.xhtml"/> </rich:tab> <rich:tab header="Something else"> something else
<rich:tabPanel >
<rich:tab header="Description" >
<ui:include src="./tests/description.xhtml"/>
</rich:tab>
<rich:tab header="Something else">
something else
</rich:tab>
</rich:tabPanel>
别的
description.xhtml中有几个字段:
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:advanced="http://java.sun.com/jsf/composite/advanced">
<h:panelGroup id="description">
// ...
<h:outputLabel value="Name"/>
<h:inputText id="name"
value="#{testTree.selected.name.text}"
rendered="#{description.editing}"/>
// ...
<advanced:button text="Reset" //Just a little upgraded a4j:commandButton
icon="images/clear.png"
action="#{description.resetEditing()}"
execute="@this"
render="description"
rendered="#{description.editing}"/>
<advanced:button text="Save"
icon="images/save2.png"
action="#{description.commitEditing()}"
execute="description" // #name and a few more fields
render="description"
rendered="#{description.editing}"/>
</h:panelGroup>
</ui:composition>
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:advanced="http://java.sun.com/jsf/composite/advanced">
<a4j:form>
<h:panelGroup id="description">
// ...
<h:outputLabel value="Name"/>
<h:inputText id="name"
value="#{testTree.selected.name.text}"
rendered="#{description.editing}"/>
// ...
<advanced:button text="Reset" //Just a little upgraded a4j:commandButton
icon="images/clear.png"
action="#{description.resetEditing()}"
execute="@this"
render="description"
rendered="#{description.editing}"/>
<advanced:button text="Save"
icon="images/save2.png"
action="#{description.commitEditing()}"
execute="description" // #name and a few more fields
render="description"
rendered="#{description.editing}"/>
</h:panelGroup>
</a4j:form>
</ui:composition>
// ...
// ...
切换到第二个标签,我得到了我的“描述”表提交,这是不好的。我想重置所有字段
如何使用RichFaces 4实现这一点?在选项卡之间切换时,默认情况下会提交父选项卡面板。您可以使用tabPanel的switchType属性将此行为更改为ajax或client。我可以想出两种方法防止在从一个选项卡更改为另一个选项卡时提交表单:
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:advanced="http://java.sun.com/jsf/composite/advanced">
<h:panelGroup id="description">
// ...
<h:outputLabel value="Name"/>
<h:inputText id="name"
value="#{testTree.selected.name.text}"
rendered="#{description.editing}"/>
// ...
<advanced:button text="Reset" //Just a little upgraded a4j:commandButton
icon="images/clear.png"
action="#{description.resetEditing()}"
execute="@this"
render="description"
rendered="#{description.editing}"/>
<advanced:button text="Save"
icon="images/save2.png"
action="#{description.commitEditing()}"
execute="description" // #name and a few more fields
render="description"
rendered="#{description.editing}"/>
</h:panelGroup>
</ui:composition>
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:advanced="http://java.sun.com/jsf/composite/advanced">
<a4j:form>
<h:panelGroup id="description">
// ...
<h:outputLabel value="Name"/>
<h:inputText id="name"
value="#{testTree.selected.name.text}"
rendered="#{description.editing}"/>
// ...
<advanced:button text="Reset" //Just a little upgraded a4j:commandButton
icon="images/clear.png"
action="#{description.resetEditing()}"
execute="@this"
render="description"
rendered="#{description.editing}"/>
<advanced:button text="Save"
icon="images/save2.png"
action="#{description.commitEditing()}"
execute="description" // #name and a few more fields
render="description"
rendered="#{description.editing}"/>
</h:panelGroup>
</a4j:form>
</ui:composition>
// ...
// ...
我还将tabPanel的switchType属性设置为ajax,以便只刷新tabPanel的内容 1)将switchType属性更改为client2) 为每个选项卡包含一个表单 我花了6个小时在谷歌上搜索,终于在这里找到了另一个,
更改此属性值节省了我的时间。我想我必须在tabPanel周围设置一个表单,否则它将无法工作。。。事实上:类org.richfaces.component.UITabPanel(id=“j_id2114509110_7e08d978”)未找到父窗体。