0

my code:

<h:form id="form">
            <p:tabView dynamic="true" id="tabform" orientation="left">
                <p:tab id="tab1" title="Tree">
                    <p:growl id="messages" showDetail="true" />
                    <p:panel style="float:left">
                        <p:tree value="#{treeBean.root}" var="node" dynamic="true" cache="false"  
                                selectionMode="single"  selection="#{treeBean.selectedNode}" id="tree" >  
                            <p:ajax event="expand" update=":form:tabform:tab1" listener="#{treeBean.onNodeExpand}" /> 

and i have an error: http://i283.photobucket.com/albums/kk308/breakbk/Untitled-1.jpg

please explain to me why, thank for any suggestion :)

Rong Nguyen
  • 4,143
  • 5
  • 27
  • 53
Family
  • 41
  • 1
  • 2
  • 10

2 Answers2

0

This seems to be a problem of wrong id in p:ajax's update attribute.

Look into the rendered html source of your page and identify the correct id of the tab. Maybe you missed a sub-component in the id string.

Matt Handy
  • 29,855
  • 2
  • 89
  • 112
0

You can use the following solution

you can bind the element that you want to render to a hashmap that will exist in request scope

and than use that binding in the render attribute , it might sound complicated , but its not

here an example

put a HashMap in the request scope by faces-config.xml:

<managed-bean>
    <description>Holder of all component bindings.</description>
    <managed-bean-name>components</managed-bean-name>
    <managed-bean-class>java.util.HashMap</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
</managed-bean>

than use it like this:

<p:message binding="#{components.myMessage}"></p:message>

or

 <p:tab binding="#{components.myTabName}"></p:tab>

and finally render it like this

<p:ajax event="expand" update="#{components.myMessage.clientId}" listener="#{treeBean.onNodeExpand}"></p:ajax>

or

<p:ajax event="expand" update="#{components.myTabName.clientId}" listener="#{treeBean.onNodeExpand}"></p:ajax>

This solution was taken from BalusC older answers on how to get the id look here...

Community
  • 1
  • 1
Daniel
  • 36,833
  • 10
  • 119
  • 200