[英]RichFaces rich:tree nodeSelectListener not being listened to
我有一個rich:tree
組件,其用法如下:
<rich:tree switchType="client" value="#{MyBacking.logTree}"
reRender="selectedLog" var="item" nodeFace="#{item.type}"
nodeSelectListener="#{MyBacking.processLogSelection}"
style="width: 50px;">
<rich:treeNode type="folder"
icon="/img/logListFolderIconClosed.png"
iconLeaf="/img/logListFolderIconOpen.png">
<h:outputText value="#{item.name}" />
</rich:treeNode>
<rich:treeNode type="log" iconLeaf="/img/logFileIcon.png"
icon="/img/logFileIcon.png">
<h:outputText value="#{item.name}" />
</rich:treeNode>
</rich:tree>
我的MyBacking processLogSelection()方法是:
public void processLogSelection(NodeSelectedEvent event) {
logger.info("In processLogSelection");
HtmlTree tree = (HtmlTree) event.getComponent();
nodeTitle = (String) tree.getRowData();
selectedNodeChildren.clear();
TreeNode currentNode = tree.getModelTreeNode(tree.getRowKey());
if (currentNode.isLeaf()){
selectedNodeChildren.add((String)currentNode.getData());
} else {
Iterator<Map.Entry<Object, TreeNode>> it = currentNode.getChildren();
while (it != null && it.hasNext()) {
Map.Entry<Object, TreeNode> entry = it.next();
selectedNodeChildren.add(entry.getValue().getData().toString());
logger.info("selected node: " + entry.getValue().getData().toString());
}
}
}
但是,當頁面呈現樹(精細)時,在節點上單擊會突出顯示該節點,但是任何一個Bean logger調用都不會記錄任何內容-該方法只是不被調用。 任何幫助回答為什么會這樣的幫助將不勝感激。 標記
編輯添加了建議的標簽/簡化的bean方法-就日志而言,似乎仍未從bean獲得響應:
<h:panelGrid columns="2" border="0" width="100%" rowClasses="tt">
<rich:panel styleClass="panelLogTree" header="Log Select">
<h:form>
<rich:tree switchType="client" value="#{MyBacking.logTree}"
var="item" nodeFace="#{item.type}" reRender="selectedLog"
nodeSelectListener="#{MyBacking.processLogSelection}"
ajaxSubmitSelection="true" style="width: 50px;">
<rich:treeNode type="folder"
icon="/img/logListFolderIconClosed.png"
iconLeaf="/img/logListFolderIconOpen.png">
<h:outputText value="#{item.name}" />
</rich:treeNode>
<rich:treeNode type="log" iconLeaf="/img/logFileIcon.png"
icon="/img/logFileIcon.png">
<h:outputText value="#{item.name}" />
</rich:treeNode>
</rich:tree>
</h:form>
</rich:panel>
<rich:panel styleClass="panelLogOutput" header="Log Content">
<h:outputText escape="false"
value="Log content: #{MyBacking.nodeTitle}" id="selectedLog" />
</rich:panel>
</h:panelGrid>
</rich:tab>
請注意rich:tab
結尾,因為此樹是從包含的jsp文件在選項卡中呈現的。 我的后備bean方法現在也是:
public void processLogSelection(NodeSelectedEvent event) {
logger.info("In processLogSelection");
}
進一步編輯有趣的是,我認為我會回到一種基本的工作模型。 我從RichFaces演示頁面中獲取了代碼。 我修改了faces-config.xml以包含SimpleTreeData
bean。 我很難獲得在( simple-tree-data.properties
)中讀取數據文件的bean代碼,因此我改用FileReader
。 這樣就好了,我得到了一個經過修改的index.jsp jsf頁面,以在演示頁面上列出簡單的樹示例,除了單擊列表項未將選定的nodeTitle
報告給指定的位置(同樣的問題)。
我可以將其視為上面報告的相同問題,或者將SimpleTreeData.java
bean中的loadTree
方法更改為事實。 在更改中,我刪除了以下幾行,並適當地更改了無關的代碼:
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
InputStream dataStream = externalContext.getResourceAsStream(DATA_PATH);
如前所述,我使用了FileReader
但有人認為這個問題可能與我刪除這3行有關嗎? 就像上面也列出的那樣,我的processLogSelection
方法不使用getCurrentInstance
但是我不確定如果JSF中列出了ajaxSubmitSelection="true"
它就不需要。
難過
我嘗試了這個facelets模板和這個示例Java支持bean ,並調用了該方法。 我以為您使用的是Seam,但也許我錯了:)不久前,有些投訴: seam forum 。 您正在使用什么版本的Richfaces和什么瀏覽器? 如果還使用Seam,請告知其版本。
解決此問題的方法是安裝facelets jar。 看這里 。 毫不奇怪,它影響了我的其他問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.