FAQ
This component has a default initial state of collapsed. Is it possible to
have an initial state of expanded. Also what is a possible solution to
keeping it always expanded? I tried extending this component, and doing
something like:



public class HtmlTreeExpanded extends HtmlTree

{

// stores initial state

private boolean initial = true;



public boolean isNodeExpanded()

{

if (!super.isNodeExpanded()){

if (initial){

toggleExpanded();

initial = false;

}

}

return super.isNodeExpanded();

}





}



But this is not working, I get the following error:

18:17:20,828 ERROR [org.apache.myfaces.util.DebugUtils] -
javax.faces.FacesException: Could not get property nodeSelected of component
server-tree



Please advise,



Thanks

Rahul Pilani

Search Discussions

  • Sean Schofield at Jun 21, 2005 at 8:04 pm

    This component has a default initial state of collapsed. Is it possible to
    have an initial state of expanded.
    Search the archives for some earlier discussions regarding this.
    There is interest in a solution but it will require some help from
    users who are willing to put in a little bit of time to help with the
    solution. So far nobody has offered to assist.
    Also what is a possible solution to
    keeping it always expanded? I tried extending this component, and doing
    something like:



    public class HtmlTreeExpanded extends HtmlTree

    {

    // stores initial state

    private boolean initial = true;



    public boolean isNodeExpanded()

    {

    if (!super.isNodeExpanded()){

    if (initial){

    toggleExpanded();

    initial = false;

    }

    }

    return super.isNodeExpanded();

    }





    }
    If you always want the node to be expanded why not just have
    isNodeExpanded return true?

    Also, you seem to be trying to toggle the expanded state in
    isNodeExpanded. That sounds like a recipe for trouble ;-) This
    method is used to *check* if the node is expanded or not. You don't
    know how many times or what will prompt this check. isNodeExpanded is
    essentially a "getter" method. If you decide to override a getter
    method and have it do "setter" stuff you are doing so at your own
    risk.

    [snip]
    Rahul Pilani
    sean
  • Rahul Pilani at Jun 21, 2005 at 8:22 pm

    If you always want the node to be expanded why not just have
    isNodeExpanded return true?

    Also, you seem to be trying to toggle the expanded state in
    isNodeExpanded. That sounds like a recipe for trouble ;-) This
    method is used to *check* if the node is expanded or not. You don't
    know how many times or what will prompt this check. isNodeExpanded is
    essentially a "getter" method. If you decide to override a getter
    method and have it do "setter" stuff you are doing so at your own
    risk.

    sean
    I did that and it works. The problem with that approach is that, the nav
    buttons (namely the "-" button) still shows, and people would want to click
    on it to collapse the tree again. If they do, myfaces throws an error,
    because the toggle method tries to remove nodes from the expanded list
    which are not there.

    Rahul
  • Sean Schofield at Jun 21, 2005 at 8:25 pm
    Ahh I see.

    There has been talk of maintaining the expanded state outside of the
    component (basically per node, or something like that.) There are
    drawbacks to that approach (see archives for earlier discussions.)

    sean
    On 6/21/05, Rahul Pilani wrote:

    If you always want the node to be expanded why not just have
    isNodeExpanded return true?

    Also, you seem to be trying to toggle the expanded state in
    isNodeExpanded. That sounds like a recipe for trouble ;-) This
    method is used to *check* if the node is expanded or not. You don't
    know how many times or what will prompt this check. isNodeExpanded is
    essentially a "getter" method. If you decide to override a getter
    method and have it do "setter" stuff you are doing so at your own
    risk.

    sean
    I did that and it works. The problem with that approach is that, the nav
    buttons (namely the "-" button) still shows, and people would want to click
    on it to collapse the tree again. If they do, myfaces throws an error,
    because the toggle method tries to remove nodes from the expanded list
    which are not there.

    Rahul
  • Rahul Pilani at Jun 21, 2005 at 8:33 pm
    What help would you require for a solution to this problem?

    -----Original Message-----
    From: Sean Schofield
    Sent: Tuesday, June 21, 2005 1:25 PM
    To: MyFaces Discussion
    Subject: Re: HtmlTree in org.apache.myfaces.custom.tree2

    Ahh I see.

    There has been talk of maintaining the expanded state outside of the
    component (basically per node, or something like that.) There are
    drawbacks to that approach (see archives for earlier discussions.)

    sean
    On 6/21/05, Rahul Pilani wrote:

    If you always want the node to be expanded why not just have
    isNodeExpanded return true?

    Also, you seem to be trying to toggle the expanded state in
    isNodeExpanded. That sounds like a recipe for trouble ;-) This
    method is used to *check* if the node is expanded or not. You don't
    know how many times or what will prompt this check. isNodeExpanded is
    essentially a "getter" method. If you decide to override a getter
    method and have it do "setter" stuff you are doing so at your own
    risk.

    sean
    I did that and it works. The problem with that approach is that, the nav
    buttons (namely the "-" button) still shows, and people would want to click
    on it to collapse the tree again. If they do, myfaces throws an error,
    because the toggle method tries to remove nodes from the expanded list
    which are not there.

    Rahul
  • Sean Schofield at Jun 21, 2005 at 9:01 pm
    Have you searched the archives for the discussions I referenced? They
    outline some of the problems. Once you are up to speed on those
    issues let me know if you think you have the time and expertise to
    help with this. Ideally we get several people to help out.

    sean

    On 6/21/05, Rahul Pilani wrote:
    What help would you require for a solution to this problem?

    -----Original Message-----
    From: Sean Schofield
    Sent: Tuesday, June 21, 2005 1:25 PM
    To: MyFaces Discussion
    Subject: Re: HtmlTree in org.apache.myfaces.custom.tree2

    Ahh I see.

    There has been talk of maintaining the expanded state outside of the
    component (basically per node, or something like that.) There are
    drawbacks to that approach (see archives for earlier discussions.)

    sean
    On 6/21/05, Rahul Pilani wrote:

    If you always want the node to be expanded why not just have
    isNodeExpanded return true?

    Also, you seem to be trying to toggle the expanded state in
    isNodeExpanded. That sounds like a recipe for trouble ;-) This
    method is used to *check* if the node is expanded or not. You don't
    know how many times or what will prompt this check. isNodeExpanded is
    essentially a "getter" method. If you decide to override a getter
    method and have it do "setter" stuff you are doing so at your own
    risk.

    sean
    I did that and it works. The problem with that approach is that, the nav
    buttons (namely the "-" button) still shows, and people would want to click
    on it to collapse the tree again. If they do, myfaces throws an error,
    because the toggle method tries to remove nodes from the expanded list
    which are not there.

    Rahul
  • Rahul Pilani at Jun 21, 2005 at 9:25 pm
    I certainly do have the time, but I don't think I have that much expertise
    in JSF, if that's what you are looking for. I went through the archives, and
    I get what you are saying about the TreeNode being an exact representation
    of the data and all rendering issues assigned to HtmlTree. I guess I wanted
    a mechanism by which you could assign/store the expand/collapse state in the
    node. There would be no need for me to persist exactly which nodes were
    expanded as this is just a UI feature and nothing to do with the actual data
    that the user is working on. It could be reset the next time the user logs
    in.

    Anyways, thanks for the help. I really appreciate it.

    Rahul

    -----Original Message-----
    From: Sean Schofield
    Sent: Tuesday, June 21, 2005 2:01 PM
    To: MyFaces Discussion
    Subject: Re: HtmlTree in org.apache.myfaces.custom.tree2

    Have you searched the archives for the discussions I referenced? They
    outline some of the problems. Once you are up to speed on those
    issues let me know if you think you have the time and expertise to
    help with this. Ideally we get several people to help out.

    sean

    On 6/21/05, Rahul Pilani wrote:
    What help would you require for a solution to this problem?

    -----Original Message-----
    From: Sean Schofield
    Sent: Tuesday, June 21, 2005 1:25 PM
    To: MyFaces Discussion
    Subject: Re: HtmlTree in org.apache.myfaces.custom.tree2

    Ahh I see.

    There has been talk of maintaining the expanded state outside of the
    component (basically per node, or something like that.) There are
    drawbacks to that approach (see archives for earlier discussions.)

    sean
    On 6/21/05, Rahul Pilani wrote:

    If you always want the node to be expanded why not just have
    isNodeExpanded return true?

    Also, you seem to be trying to toggle the expanded state in
    isNodeExpanded. That sounds like a recipe for trouble ;-) This
    method is used to *check* if the node is expanded or not. You don't
    know how many times or what will prompt this check. isNodeExpanded is
    essentially a "getter" method. If you decide to override a getter
    method and have it do "setter" stuff you are doing so at your own
    risk.

    sean
    I did that and it works. The problem with that approach is that, the nav
    buttons (namely the "-" button) still shows, and people would want to click
    on it to collapse the tree again. If they do, myfaces throws an error,
    because the toggle method tries to remove nodes from the expanded list
    which are not there.

    Rahul
  • Sean Schofield at Jun 21, 2005 at 9:28 pm
    Lets see if we can't attract a few more people to the cause. Time is
    the most important - expertise is a nice plus ;-) All of us are
    relatively new to JSF so don't worry.

    If we can get a few more people willing to help out then I am willing
    to reopen some of those old discussions. My first priority at the
    moment is to finish up the SVN reorg and get our sandbox up and
    running.

    sean
    On 6/21/05, Rahul Pilani wrote:
    I certainly do have the time, but I don't think I have that much expertise
    in JSF, if that's what you are looking for. I went through the archives, and
    I get what you are saying about the TreeNode being an exact representation
    of the data and all rendering issues assigned to HtmlTree. I guess I wanted
    a mechanism by which you could assign/store the expand/collapse state in the
    node. There would be no need for me to persist exactly which nodes were
    expanded as this is just a UI feature and nothing to do with the actual data
    that the user is working on. It could be reset the next time the user logs
    in.

    Anyways, thanks for the help. I really appreciate it.

    Rahul

    -----Original Message-----
    From: Sean Schofield
    Sent: Tuesday, June 21, 2005 2:01 PM
    To: MyFaces Discussion
    Subject: Re: HtmlTree in org.apache.myfaces.custom.tree2

    Have you searched the archives for the discussions I referenced? They
    outline some of the problems. Once you are up to speed on those
    issues let me know if you think you have the time and expertise to
    help with this. Ideally we get several people to help out.

    sean

    On 6/21/05, Rahul Pilani wrote:
    What help would you require for a solution to this problem?

    -----Original Message-----
    From: Sean Schofield
    Sent: Tuesday, June 21, 2005 1:25 PM
    To: MyFaces Discussion
    Subject: Re: HtmlTree in org.apache.myfaces.custom.tree2

    Ahh I see.

    There has been talk of maintaining the expanded state outside of the
    component (basically per node, or something like that.) There are
    drawbacks to that approach (see archives for earlier discussions.)

    sean
    On 6/21/05, Rahul Pilani wrote:

    If you always want the node to be expanded why not just have
    isNodeExpanded return true?

    Also, you seem to be trying to toggle the expanded state in
    isNodeExpanded. That sounds like a recipe for trouble ;-) This
    method is used to *check* if the node is expanded or not. You don't
    know how many times or what will prompt this check. isNodeExpanded is
    essentially a "getter" method. If you decide to override a getter
    method and have it do "setter" stuff you are doing so at your own
    risk.

    sean
    I did that and it works. The problem with that approach is that, the nav
    buttons (namely the "-" button) still shows, and people would want to click
    on it to collapse the tree again. If they do, myfaces throws an error,
    because the toggle method tries to remove nodes from the expanded list
    which are not there.

    Rahul
  • CONNER, BRENDAN \(SBCSI\) at Jun 21, 2005 at 9:31 pm
    I could potentially help out....

    - Brendan

    -----Original Message-----
    From: Sean Schofield
    Sent: Tuesday, June 21, 2005 4:28 PM
    To: MyFaces Discussion
    Subject: Re: HtmlTree in org.apache.myfaces.custom.tree2


    Lets see if we can't attract a few more people to the cause. Time is
    the most important - expertise is a nice plus ;-) All of us are
    relatively new to JSF so don't worry.

    If we can get a few more people willing to help out then I am willing
    to reopen some of those old discussions. My first priority at the
    moment is to finish up the SVN reorg and get our sandbox up and
    running.

    sean
    On 6/21/05, Rahul Pilani wrote:
    I certainly do have the time, but I don't think I have that much expertise
    in JSF, if that's what you are looking for. I went through the
    archives, and
    I get what you are saying about the TreeNode being an exact
    representation
    of the data and all rendering issues assigned to HtmlTree. I guess I wanted
    a mechanism by which you could assign/store the expand/collapse state in the
    node. There would be no need for me to persist exactly which nodes were
    expanded as this is just a UI feature and nothing to do with the
    actual data
    that the user is working on. It could be reset the next time the user logs
    in.

    Anyways, thanks for the help. I really appreciate it.

    Rahul

    -----Original Message-----
    From: Sean Schofield
    Sent: Tuesday, June 21, 2005 2:01 PM
    To: MyFaces Discussion
    Subject: Re: HtmlTree in org.apache.myfaces.custom.tree2

    Have you searched the archives for the discussions I referenced? They
    outline some of the problems. Once you are up to speed on those
    issues let me know if you think you have the time and expertise to
    help with this. Ideally we get several people to help out.

    sean

    On 6/21/05, Rahul Pilani wrote:
    What help would you require for a solution to this problem?

    -----Original Message-----
    From: Sean Schofield
    Sent: Tuesday, June 21, 2005 1:25 PM
    To: MyFaces Discussion
    Subject: Re: HtmlTree in org.apache.myfaces.custom.tree2

    Ahh I see.

    There has been talk of maintaining the expanded state outside of the
    component (basically per node, or something like that.) There are
    drawbacks to that approach (see archives for earlier discussions.)

    sean
    On 6/21/05, Rahul Pilani wrote:

    If you always want the node to be expanded why not just have
    isNodeExpanded return true?

    Also, you seem to be trying to toggle the expanded state in
    isNodeExpanded. That sounds like a recipe for trouble ;-) This
    method is used to *check* if the node is expanded or not. You
    don't
    know how many times or what will prompt this check.
    isNodeExpanded is
    essentially a "getter" method. If you decide to override a
    getter
    method and have it do "setter" stuff you are doing so at your own
    risk.

    sean
    I did that and it works. The problem with that approach is that,
    the nav
    buttons (namely the "-" button) still shows, and people would want
    to
    click
    on it to collapse the tree again. If they do, myfaces throws an
    error,
    because the toggle method tries to remove nodes from the expanded
    list
    which are not there.

    Rahul

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriesmyfaces
postedJun 17, '05 at 8:24a
activeJun 21, '05 at 9:31p
posts9
users3
websitemyfaces.apache.org

People

Translate

site design / logo © 2019 Grokbase