Rendering problem of tree in IE

UI Components for JSF
Post Reply
tatun78
Posts: 22
Joined: 04 Jun 2009, 13:32

31 Jul 2009, 07:54

Hi Cagatay. Hope you are doing fine and had a great holiday.
I am again having one issue with p:tree. My tree code looks like this:
<p:tree value="#{treeBean.model}" cache="false" toggleMode="client"
onNodeClick="nodeClick" nodeSelectListener="#{treeBean.onNodeSelect}"
nodeExpandListener="#{treeBean.onNodeExpand}"
nodeCollapseListener="#{treeBean.onNodeCollapse}" widgetVar="myTree">
</p:tree>

Now
I put in <body onLoad="myTree.expandAll()".
Actually I want to populate the tree in Expanded mode at the time of page loading.

It's working in Mozilla. But in case of IE(6/7/8) it's not working. I think IE can't recognize "myTree" at the time of Body onload.

Please suggest.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

02 Aug 2009, 08:59

Hi, thanks holiday was great :)

To my understanding you're trying to display all nodes as expanded initially when the page is opened right?

tatun78
Posts: 22
Joined: 04 Jun 2009, 13:32

04 Aug 2009, 08:20

Yes

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

04 Aug 2009, 19:44

Can you try this, let's try window onload instead of body onload.

Code: Select all

function expandAll() {
    myTree.expandAll();
}

YAHOO.util.Event.addListener(window, "load", expandAll);

tatun78
Posts: 22
Joined: 04 Jun 2009, 13:32

10 Aug 2009, 10:11

Hi. As per your advice, I had done the following :

javascript Methods
function expandAll()
{
myTree.expandAll();
}

window.onload=function()
{
YAHOO.util.Event.addListener("window", "load", expandAll());
}

body portion
<body>

...
...
...

<p:tree value="#{treeBean.model}" cache="false" toggleMode="client"
onNodeClick="nodeClick" nodeSelectListener="#{treeBean.onNodeSelect}"
nodeExpandListener="#{treeBean.onNodeExpand}"
nodeCollapseListener="#{treeBean.onNodeCollapse}" widgetVar="myTree">
</p:tree>

...
...
...

</body>

Still the javascript error "myTree is an undefined object" is being shown in IE; but in Mozilla, it's working fine.
Please suggest what to do.
I need your advice badly.

rudrajyoti
Posts: 1
Joined: 11 Aug 2009, 15:15

12 Aug 2009, 05:58

The problem in IE is due to the fact that the widgetvar for tree is initialized after the containing div of the tree is ready.

One possible solution that worked for us is having an afterRender attribute for the tree component. The tree renderer puts the afterrender javascript function after the tree.render() call, thus ensuring that whatever default action on the tree is asked for (like expandAll) is called only after the widget var for tree is initialized.

tatun78
Posts: 22
Joined: 04 Jun 2009, 13:32

12 Aug 2009, 08:05

Thanks Rudrajyoti!

It would be nice of you, if you could share the code with us.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

29 Aug 2009, 20:14

There's a new attribute that'll be shipped with 0.9.2. Following code renders all nodes as expanded on initial page load.

Code: Select all

<p:tree expanded="true" />

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 20 guests