2011-09-05 37 views
0

有一個標籤面板類似:防止表單標籤交換機上提交與RichFaces的一個tabpanel

<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> 

切換到第二個選項卡我得到了我「描述」表單提交,這不好。我想重置所有字段。

如何用RichFaces 4實現此目的?

回答

1

默認情況下,在製表符之間切換時,會提交父級tabPanel。您可以使用tabPanel的switchType屬性將其更改爲ajax或客戶端。我能想到的兩種方法可以防止您的形式從改變從一個標籤到另一個提交:

  1. 更改switchType屬性客戶

  2. 包括每個選項卡

形式

我看不到你的表單在哪裏定義,但我猜測整個富有:tabPanel在表單內。我看到在description.xhtml頁面中沒有定義表單。你可以嘗試刪除你有表格,然後添加一個窗體爲每個標籤,即在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">  

<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屬性,以便只有一個tabpanel的內容刷新。

+0

我想我必須有一個tabPanel的表格,如果不是它不會工作...確實:類org.richfaces.component.UITabPanel(id =「j_id2114509110_7e08d978」)沒有找到父窗體。 – mmoossen

0

1)改變switchType屬性爲客戶
2)包括形式爲每個標籤

我已經花了6小時谷歌搜索,終於結束了在這裏尋找另一個
更改此屬性值救了我的一天。