2011-08-22 101 views
0

我已富含延伸的面數據表中的行以下數據,擴展數據表和模式面板

加入日期,註釋,用戶,修改日期等

當項目被填充用戶將能夠編輯特定的東西,如筆記字段。

我有一個commandButton與該註釋字段,它彈出一個豐富的面模態面板,但由於某種原因,我的模態面板不檢索正確的行。而是總是返回擴展數據表的第一行

有什麼建議嗎?

繼承人爲特定列的代碼,請注意這是一個多A4J:形式

<a4j:commandButton value="Edit Status Notes" rendered="#{selectedErrorInfo.errorId == errInfo.errorId}" 
             oncomplete="Richfaces.showModalPanel('statusNotesPanel', {width: 350, top: 150});" > 


            </a4j:commandButton> 
             <rich:modalPanel id="statusNotesPanel">          
              <center> 
              <h:inputTextarea value="#{errInfo.statusNotes}" style="height:100px; width:300px;" maxlength="4000"/> 
              <br/>           
              <a4j:commandButton value="Close" oncomplete="Richfaces.hideModalPanel('statusNotesPanel');" /> 
              </center>           
             </rich:modalPanel> 

解答

好了,所以兩件事情。 首先,模態面板不能處於原始數據表格的形式。這是的例子是

<h:form> 
<rich:ExtendedDatatable> 
    ...... info here (if there is any ModalPanel within this area with forms, it will not work 
</rich?:ExtendedDataTable> 
</h:form> 

所以你需要它在原始形式之外。

其次,您需要在打開的動作中重新調用模態面板。我所做的是使用commandButton並將reRender =設置爲modalPanel窗體的ID。例如:

<rich:commandButton reRender="blah" oncomplete="Richfaces.showModalPanel('blah', {width: 350, top: 150});"> 

<rich:modalPanel id= "blah"> 

第三,我使用DataModelSelection讓ajax做我所有的選擇。 你必須說,爲了使用它是

class.SelectedItem.property so例如。

public class TestClass 
{ 

@DataModel 
List<Person> testItems; 

@DataModelSelection("testItems") 
Person selectedlistItem; 
} 

public class person 
{ 

String name; 
String lastName; 

//getters setters etc. 
} 

您將需要使用XHTML。

<rich:modalPanel> 
<h:form> 
<h:inputText value="#{TestClass.selectedListItem.name}"/> in order to retrieve the name 
</h:form> 
+0

什麼是errInfo.statusNotes和selectedErrorInfo.errorId?你可以給更多的源代碼(數據表)? –

+0

selectedErrorInfo實際上是DataModelSelection – Kevin

+0

和errInfo只是var,它包含狀態說明 – Kevin

回答

1

您的modalPanel是否在數據表的迭代中聲明?

在這種情況下(我認爲是這樣),問題是所有的模態面板都有相同的ID(statusNotesPanel)。 嘗試連接statusNotesPanelerrInfo.errorId作爲rich:modalPanel的ID。

+0

如果沒有在數據表中聲明,你可以給更多的源代碼嗎? –

+0

對不起,我還在試圖找出解決這個問題的方法。我會嘗試更多的事情。我覺得我很接近。 – Kevin

+0

好吧,我明白了。我會在編輯中發佈答案。非常感謝牛仔! – Kevin