richfaces extendedDataTable を a4j:support で使用して、rich:panel の「レンダリング」属性の値を変更しようとしていますが、機能していません。
これは、rich:extendedDataTable と rich:panel を含む私の JSF ページの一部です。
<h:form id="tabForm">
<rich:extendedDataTable id="myTable" width="500px" height="250px"
value="#{extDataTableBean.extList}" var="dataRow"
selection="#{extDataTableBean.selection}" selectionMode="single">
<rich:column>
<f:facet name="header"><h:outputText value="ID" /></f:facet>
<h:outputText value="#{dataRow.id}"></h:outputText>
</rich:column>
<rich:column>
<f:facet name="header"><h:outputText value="Name" /></f:facet>
<h:outputText value="#{dataRow.name}"></h:outputText>
</rich:column>
<a4j:support id="myTableTakeSelection" action="#{extDataTableBean.takeSelection}" event="onselectionchange" reRender="pane" />
</rich:extendedDataTable>
</h:form>
<rich:panel id="pane" rendered="#{extDataTableBean.showPane}">
<h:form id="secForm">
<h:outputText value="ID : " />
<h:inputText id="inTextID" value="#{extDataTableBean.idFd}" />
<br/>
<h:outputText value="Name : " />
<h:inputText id="inTextName" value="#{extDataTableBean.nameFd}" />
</h:form>
</rich:panel>
rich:panel 'rendered' 属性のデフォルト値は false (バッキング Bean で設定) です。私が達成したかったのは、extendedDataTable の行が選択されたときに、その値が true に変更されて GUI に表示されるようにすることです。
そして、これは私のバッキング Bean の一部です。
/* Constructor */
public ExtDataTableBean(){
setShowPane(false); // default to false
loadDataList();
}
/* Load some test data into extendedDataTable */
public void loadDataList(){
extList = new ArrayList<MyData>();
MyData e1 = new MyData();
e1.setId(1);
e1.setName("name 1");
extList.add(e1);
MyData e2 = new MyData();
e2.setId(2);
e2.setName("name 2");
extList.add(e2);
}
public String takeSelection(){
Iterator iterator = getSelection().getKeys();
Object key = null;
while(iterator.hasNext()){
key = iterator.next();
}
/* set the values of inputText with value from selected row */
setIdFd(extList.get(Integer.parseInt(key.toString())).getId());
setNameFd(extList.get(Integer.parseInt(key.toString())).getName());
setShowPane(true);
return null;
}
public List<MyData> getExtList() {
/* Lazy loading */
if(extList == null){
loadDataList();
}
return extList;
}
takeSelection( ) メソッドで setShowPane(true) を使用して、rich:panel 'rendered' 属性の値を true に変更しました。問題は豊富です。行が選択されているときにパネルが GUI に表示されません。
次のように、a4j:support を指定して ah:commandButton を追加し、showPane を true に設定して、別の簡単なテストを行いました。
<h:commandButton id="cmdBtn" value="Show Pane">
<a4j:support id="cmdBtnSupport" reRender="pane" action="#{extDataTableBean.dispPane}" event="onclick" />
</h:commandButton>
バッキング Bean では次のようになります。
public String dispPane(){
setShowPane(true);
return null;
}
期待どおりに動作しています。ボタンをクリックすると、rich:panel が GUI に表示されます。
私のコードで何が欠けていましたか?