collapse/expand all - Websphere

This is a discussion on collapse/expand all - Websphere ; Hi all, Is there a tag to collapse/expand all the nodes in the side navigation ? Thanks...

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 20 of 36

Thread: collapse/expand all

  1. collapse/expand all

    Hi all,

    Is there a tag to collapse/expand all the nodes in the side navigation ?

    Thanks

  2. Re: collapse/expand all

    there is no tag, but you can use the url generation spi to do this

    Jim





    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

  3. Re: collapse/expand all

    Hi,



    actually What i want is to add 2 links (expand all/collapse all) in my side navigation. is there any examples or article on how to do it with the url generation ?

    first i was thinking on doing it with javascript, something like:



    <portal-fmt:title />

    getType() can return either collapse or expand

  4. Re: collapse/expand all

    well you can see this article that talks about it a little

    http://www.ibm.com/developerworks/websphere/library/techarticles/0612_behl/0612_behl.html

    This is an example of using the expansion state accessors



    http://www-1.ibm.com/support/docview.wss?rs=688&ca=portall2&uid=swg21283387



    If you want to do it for all children to be expanded, then you would just create a link to the current page, and in that loop through all children of the master set and set the state to expand or collapse





    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

  5. Re: collapse/expand all

    hi ,

    i guessed that if we want the node to collapse we use false .. but its not working (not collapsing)

    is this correct ?



    String url = "";

    url = ServletURLGenerator.generateUrlStringWithExpansion (wpsNavNode, false, request, response);




    Thanks


  6. Re: collapse/expand all

    well it is not going to change anything in the current, it is going going to affect the specific node passed on. The method in there will not work for your need. That is just an example of how to work with the expansion state, you will need to use the current node as the target

    selectionCtrl.setSelection(wpsNavNode.getObjectID( ));


    and then iterate over all nodes setting the expansion state to true for each node at the current level, So get a navigationSelectionModel, then get all children of the 2nd level or 3rd level, and then iterate over them to set them to false or true



    expansionCtrl.setToggled(wpsNavNode.getObjectID(), toggle);

    expansionCtrl.dispose();



    then once you click on the link generated it will either collapse or expand, I will try and create a sample





    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM


  7. Re: collapse/expand all

    hi,

    Yeah an example would be great cause i dont think i really understand

    Thanks

  8. Re: collapse/expand all

    Hi,

    Ps :

    but can i still use this for my sideNav ?



    <c-rt:choose>

    <c-rt:when test="<%=nodeHasChildren && isExpanded %>">

    a class="selectedLink" href='<portal-navigation:navigationUrl type="collapse"/>'><portal-fmt:title />

    </c-rt:when>

    <c-rt:when test="<%=nodeHasChildren && !isExpanded %>">

    a href='<portal-navigation:navigationUrl type="expand"/>'><portal-fmt:title />

    </c-rt:when>

    </c-rt:choose>

  9. Re: collapse/expand all

    yes that code just works on a single node at a time





    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

  10. Re: collapse/expand all

    Ok,

    i will try to follow your suggestion but a sample would be greatly appreciated

    Thank you for your help

  11. Re: collapse/expand all

    hi jim,

    i noticed a strange behavior (unless its suppose to happen) :

    here is my nav tree :

    Page1

    --page11

    --page12

    Page2

    --page21

    --page22



    When i collapse page1,page 2 expand and vice versa ..its like i cant have both of theme collapsed ..its this a normal behavior ?

    Thanks

  12. Re: collapse/expand all

    it depends are you on any of the children pages when clicking that?

    Jim





    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

  13. Re: collapse/expand all

    hi,

    i'm trying a new way :

    a href="<portal-navigation:navigationUrl type="link" varname="<%=theActiveNode%>"><portal-navigation:urlParam name="collapseAll" value="true"/></portal-navigation:navigationUrl>">Reduce all

    is there a way to retrieve the parameter in my page(sideNave.jspf) ?



    Thanks

  14. Re: collapse/expand all

    well there is a way to retrieve the currentpage objectid, and from that you can use the navigation model locator, to retrieve the navigationnode and then set that as a parameter,



    The classes in here

    http://www-1.ibm.com/support/docview.wss?rs=688&ca=portall2&uid=swg21265900



    have a way to retieve the current page



    You would then need to use the navigation spi to locate the navigation node based on the objectid



    you can ALSO use the navigation selection model and just get the last item in the list, there are examples on this in the infocenter





    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

  15. Re: collapse/expand all

    I have created a method

    public static String expandAllPages(

    ObjectID objectID,

    boolean toggle,

    HttpServletRequest request,

    HttpServletResponse response)

    throws StateException, NamingException, IOException {



    final PortalStateManagerService mgr = getStateManager(request, response);


    // Get the URL factory

    final URLAccessorFactory urlFactory = (URLAccessorFactory) mgr.getAccessorFactory(URLAccessorFactory.class);



    // Request a URL

    // The 3rd argument specifies whether the URL points to the protected (authenticated) area;

    // pass in "false" if your page is accessible for unauthenticated users



    //final EngineURL url = urlFactory.newURL(serverContext, false, nonPublicPage, mgr.newState(), Constants.EMPTY_COPY);

    final EngineURL url = urlFactory.newURL(request, response, mgr.newState(), Constants.EMPTY_COPY);



    // Set the page this URL should point to

    final SelectionAccessorFactory selectionFactory = (SelectionAccessorFactory) mgr.getAccessorFactory(SelectionAccessorFactory.cl ass);

    // Request the selection controller to set the page; pass in the state associated with the created URL

    final SelectionAccessorController selectionCtrl = selectionFactory.getSelectionAccessorController(ur l.getState());

    // Set the page; you need the unique name (String) or the ObjectID of that page

    selectionCtrl.setSelection(objectID);

    // Dispose the accessor (avoids memory leak)

    selectionCtrl.dispose();



    final ExpansionStatesAccessorFactory expansionFactory = (ExpansionStatesAccessorFactory) mgr.getAccessorFactory(ExpansionStatesAccessorFact ory.class);

    final ExpansionStatesAccessorController expansionCtrl = expansionFactory.getExpansionStatesAccessorControl ler(url.getState());

    try{

    Context ctx = new InitialContext();

    NavigationSelectionModelHome home = (NavigationSelectionModelHome) ctx.lookup("portal:service/model/NavigationSelectionModel");

    if (home != null) {

    NavigationSelectionModelProvider provider =

    home.getNavigationSelectionModelProvider();

    NavigationSelectionModel model =

    provider.getNavigationSelectionModel(request, response);

    int level = 1;

    for (java.util.Iterator i = model.iterator(); i.hasNext(); ) {

    NavigationNode node = (NavigationNode) i.next();



    if(level == 3) {

    NavigationModelHome nmhome = (NavigationModelHome) ctx.lookup("portal:service/model/NavigationModel");

    NavigationModel nmodel = nmhome.getNavigationModelProvider().getNavigationM odel(request, response);

    Locator locator = nmodel.getLocator();



    }

    System.out.println(node.getTitle(request.getLocale ()));

    level++;


    }

    }

    } catch (Exception ex) {

    System.err.println("there was a problem in the call");

    }


    expansionCtrl.setToggled(objectID, toggle);

    expansionCtrl.dispose();



    return url.writeDispose(new StringWriter()).toString();

    }



    right now if you create the link like this

    <%
    try{


    String url1 = ThemeURLHelper.expandAllPages(ServletURLHelper.get CurrentPage(request, response), true, request, response);

    %>The URL is ....<%=url1%>

    < a href=" <%=url1 %> " >CLICK HERE 3

    <%
    }catch(Exception e)
    {
    %><%=e.getMessage()%>

    <%
    e.printStackTrace(System.out);
    }
    %>


    I have included a test portlet that does this I am working on the expand all





    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM


  16. Re: collapse/expand all

    Ok I changed the code and now both expand and collapse work for me

    public static String expandAllPages(

    ObjectID objectID,

    boolean toggle,

    HttpServletRequest request,

    HttpServletResponse response)

    throws StateException, NamingException, IOException {



    final PortalStateManagerService mgr = getStateManager(request, response);


    // Get the URL factory

    final URLAccessorFactory urlFactory = (URLAccessorFactory) mgr.getAccessorFactory(URLAccessorFactory.class);



    // Request a URL

    // The 3rd argument specifies whether the URL points to the protected (authenticated) area;

    // pass in "false" if your page is accessible for unauthenticated users



    //final EngineURL url = urlFactory.newURL(serverContext, false, nonPublicPage, mgr.newState(), Constants.EMPTY_COPY);

    final EngineURL url = urlFactory.newURL(request, response, mgr.newState(), Constants.EMPTY_COPY);



    // Set the page this URL should point to

    final SelectionAccessorFactory selectionFactory = (SelectionAccessorFactory) mgr.getAccessorFactory(SelectionAccessorFactory.cl ass);

    // Request the selection controller to set the page; pass in the state associated with the created URL

    final SelectionAccessorController selectionCtrl = selectionFactory.getSelectionAccessorController(ur l.getState());

    // Set the page; you need the unique name (String) or the ObjectID of that page

    selectionCtrl.setSelection(objectID);

    // Dispose the accessor (avoids memory leak)

    selectionCtrl.dispose();



    final ExpansionStatesAccessorFactory expansionFactory = (ExpansionStatesAccessorFactory) mgr.getAccessorFactory(ExpansionStatesAccessorFact ory.class);

    final ExpansionStatesAccessorController expansionCtrl = expansionFactory.getExpansionStatesAccessorControl ler(url.getState());

    try{

    Context ctx = new InitialContext();

    NavigationSelectionModelHome home = (NavigationSelectionModelHome) ctx.lookup("portal:service/model/NavigationSelectionModel");

    if (home != null) {

    NavigationSelectionModelProvider provider =

    home.getNavigationSelectionModelProvider();

    NavigationSelectionModel model =

    provider.getNavigationSelectionModel(request, response);

    int level = 1;

    for (java.util.Iterator i = model.iterator(); i.hasNext(); ) {

    NavigationNode node = (NavigationNode) i.next();

    NavigationNode childNode2ndLevel = null;



    if(level == 3) {

    NavigationModelHome nmhome = (NavigationModelHome) ctx.lookup("portal:service/model/NavigationModel");

    NavigationModel nmodel = nmhome.getNavigationModelProvider().getNavigationM odel(request, response);

    Iterator childrenIter = nmodel.getChildren(node);

    while (childrenIter.hasNext()) {

    childNode2ndLevel = (NavigationNode)childrenIter.next();

    expansionCtrl.setToggled(childNode2ndLevel.getObje ctID(), toggle);

    }

    }

    System.out.println(node.getTitle(request.getLocale ()));

    level++;

    }

    }

    } catch (Exception ex) {

    System.err.println("there was a problem in the call");

    }

    expansionCtrl.setToggled(objectID, toggle);

    expansionCtrl.dispose();



    return url.writeDispose(new StringWriter()).toString();

    }



    and then the links

    <%
    try{


    String url1 = ThemeURLHelper.expandAllPages(ServletURLHelper.get CurrentPage(request, response), false, request, response);

    %>The URL is ....<%=url1%>

    collapse all

    <%
    }catch(Exception e)
    {
    %><%=e.getMessage()%>

    <%
    e.printStackTrace(System.out);
    }
    %>


    <%
    try{


    String url1 = ThemeURLHelper.expandAllPages(ServletURLHelper.get CurrentPage(request, response), true, request, response);

    %>The URL is ....<%=url1%>

    expand all

    <%
    }catch(Exception e)
    {
    %><%=e.getMessage()%>

    <%
    e.printStackTrace(System.out);
    }
    %>


    example in the attached portlet





    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM


  17. Re: collapse/expand all

    Thanks Jim,

    i'm gonna try that method and i'll let you know how it goes .

    ps: should i put it (the function) in the URLUTIL jar ?

  18. Re: collapse/expand all

    oh the other thing, is that I designed this off of single top nav, you may need to change it to set the expansion state at level 4 for double top nav





    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

  19. Re: collapse/expand all

    i dont use the top nav so i guess i'm ok

  20. Re: collapse/expand all



    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

+ Reply to Thread
Page 1 of 2 1 2 LastLast