RestoreViewState  with HTMLB-TREES/TREENODES

Hello,
we want to achieve that our dynamic tree will
be built up in the state it was before we jumped onto another page. When navigating backwards, the tree
does not remember any more it treenodes properties.
Just the root is displayed, not any more the information which node was open and which not.
Also restoreViewState  = "TRUE" did not help.
Any ideas ?
Thanks.

Here is a complete (yet simplistic) example that proves that the serialization idea works.
Stateless Application
Page One called tree.htm
Page Attributes (Auto Flag is NOT set)
h1_isopen     TYPE     STRING
h2_isopen     TYPE     STRING
view_state     TYPE     SHSVALTAB
OnInitialization
* event handler for data retrieval
DATA: istream TYPE string,
         xslt_err TYPE REF TO cx_xslt_exception.
**** Read Server cookie
CALL METHOD cl_bsp_server_side_cookie=>get_server_cookie
   EXPORTING
     name                  = 'view_state'
     application_name      = runtime->application_name
     application_namespace = runtime->application_namespace
     username              = sy-uname
     session_id            = runtime->session_id
     data_name             = 'view_state'
   CHANGING
     data_value            = istream.
**** deserialize the Class
IF istream IS NOT INITIAL.
   TRY.
       CALL TRANSFORMATION id
       SOURCE XML istream
       RESULT view_state = view_state.
     CATCH cx_xslt_exception INTO xslt_err.
   ENDTRY.
ENDIF.
CHECK view_state IS NOT INITIAL.
FIELD-SYMBOLS: <wa_state> LIKE LINE OF view_state.
LOOP AT view_state ASSIGNING <wa_state>.
   IF <wa_state>-key CS 'Header1'.
     IF <wa_state>-value = 'O'.
       h1_isopen = 'TRUE'.
     ENDIF.
   ENDIF.
   IF <wa_state>-key CS 'Header2'.
     IF <wa_state>-value = 'O'.
       h2_isopen = 'TRUE'.
     ENDIF.
   ENDIF.
ENDLOOP.
OnInputProcessing
* event handler for checking and processing user input and
* for defining navigation
DATA: fields TYPE tihttpnvp.
request->get_form_fields( CHANGING fields = fields ).
FIELD-SYMBOLS: <wa_field> LIKE LINE OF fields,
               <wa_state> LIKE LINE OF view_state.
LOOP AT fields ASSIGNING <wa_field>.
  IF <wa_field>-name CS 'test'. "My Tree ID
    APPEND INITIAL LINE TO view_state ASSIGNING <wa_state>.
    <wa_state>-key   = <wa_field>-name.
    <wa_state>-value = <wa_field>-value.
  ENDIF.
ENDLOOP.
DATA: ostream TYPE string,
        xslt_err TYPE REF TO cx_xslt_exception.
***** serialize model class
TRY.
    CALL TRANSFORMATION id
    SOURCE view_state = view_state
    RESULT XML ostream.
****Write cookie it into the Server Cookie
    cl_bsp_server_side_cookie=>set_server_cookie( name = 'view_state'
      application_name = runtime->application_name
      application_namespace = runtime->application_namespace
      username = sy-uname
      session_id = runtime->session_id
      data_name = 'view_state'
      data_value = ostream
      expiry_time_rel = '1200' ).
  CATCH cx_xslt_exception INTO xslt_err.
ENDTRY.
navigation->goto_page( 'Navigate.htm' ).
Layout of tree.htm
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2003" >
  <htmlb:page title=" " >
    <htmlb:form>
      <htmlb:tree id               = "test"
                  restoreViewState = "TRUE" >
        <htmlb:treeNode id     = "Header1"
                        text   = "Header1"
                        isOpen = "<%= h1_isopen %>" >
          <htmlb:treeNode id     = "Header2"
                          text   = "Header2"
                          isOpen = "<%= h2_isopen %>" >
            <htmlb:treeNode id   = "Item1"
                            text = "Item1" />
            <htmlb:treeNode id   = "Item2"
                            text = "Item2" />
          </htmlb:treeNode>
          <htmlb:treeNode id   = "Item3"
                          text = "Item3" />
          <htmlb:button text    = "test"
                        onClick = "TEST" />
        </htmlb:treeNode>
      </htmlb:tree>
    </htmlb:form>
  </htmlb:page>
</htmlb:content>
Second Page Navigate.htm (Just a dummy page to simulate Navigation)
OnInputProcessing
* event handler for checking and processing user input and
* for defining navigation
navigation->goto_page( 'tree.htm' ).
Layout for Navigate.htm
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<htmlb:content design="design2003">
  <htmlb:page title = " ">
    <htmlb:form>
      <htmlb:textView     text          = "Hello World!"
                          design        = "EMPHASIZED" />
      <htmlb:button       text          = "Press Me"
                          onClick       = "myClickHandler" />
    </htmlb:form>
  </htmlb:page>
</htmlb:content>

Similar Messages

  • Htmlb:tree node count limitation

    Hi Experts,
    I have a problem with htmlb:tree. Rendering up to 60 nodes will works well, if my tree has more than 60-65  nodes and I klick any link or the tree itself, after rendering has been finished, the Browser will get stuck and keep searching forever. SAP recommends to use htmlb:tree for trees with 30-50 nodes. Some suggestion was to load the node using AJAX. Are there some other ideas?
    Many thanks for help!

    check out this weblog
    [BSP/How-To: Build performance-efficient dynamic htmlb:tree|BSP/How-To: Build performance-efficient dynamic htmlb:tree]
    Raja

  • Bsp htmlb:tree

    Hi,
    I created a BSP application with dynamic htmlb:tree using TVIEW2. Everything works fine BUT... when I navigate to another page and I return to the page containing the tree-object, my tree is no longer displayed, although the internal table TVIEW2 is properly filled. Anyone experienced this problem also??? Possible solution?

    Layout:
        <myhtmlb:gridLayoutCell columnIndex = "1"
                                rowIndex    = "1" >
          <%-- Overview tree --%>
          <myxhtmlb:overflowContainer height = "495"
                                      width  = "350"
                                      mode   = "SCROLL" >
            <myhtmlb:tree id               = "TREE_PROP"
                          onTreeClick      = "OnInputProcessing"
                          restoreViewState = "TRUE"
                          height           = "495"
                          width            = "350"
                          table2           = "<%= i_tree %>"
                          title            = "Personnel Overview" />
          </myxhtmlb:overflowContainer>
        </myhtmlb:gridLayoutCell>
    internal table i_tree is filled in OnInitialization event. The table is proporly filled.

  • How to change color of htmlb tree...

    Hi, I am analyzing the htmlb tree tag, and wondering how I can change the color of each row, or change the color of the whole tree white?  I know about the style editor, but I'm looking for a way code-wise to make this change.  I have pasted code below for your reference.  Any help or styling tips would be very appreciated!
    Thank you so much! Baggett
    <b>   <hbj:tree id="S_Tree" title="e-enviroment" tooltip="enviroment of my computer">
               <hbj:treeNode id="e_root" text="Desk" isOpen="true" tooltip="My desk">
                   <hbj:treeNode id="e_comp" text="Computer" isOpen="true">
                        <hbj:treeNode id="e_comp_fl" text="Floppy"/>           
                      </hbj:treeNode>
                   <hbj:treeNode id="e_net" text="Network" isOpen="true" tooltip="Company network">
                        <hbj:treeNode id="n_lan" text="LAN" tooltip="Local Area Network"/>                 
                    </hbj:treeNode>
               </hbj:treeNode>
       </hbj:tree></b>

    What rajesh suggested won't work.
    <hbj:tree id="S_Tree" title="e-enviroment" tooltip="enviroment of my computer">
    <%
      S_tree.setEncode(false);
      S_tree.setText("<span style=background-color: #FFFF00>e-enviroment</span>");
    %>
    <hbj:treeNode id="e_root" text="Desk" isOpen="true" tooltip="My desk">
    <%
      e_root.setEncode(false);
      e_root.setText("<span style=background-color: #FFFF00>Desk</span>");
    %>
    <hbj:treeNode id="e_comp" text="Computer" isOpen="true">
    <%
      e_comp.setEncode(false);
      e_comp.setText("<span style=background-color: #FFFF00>Computer</span>");
    %>
    <hbj:treeNode id="e_comp_fl" text="Floppy"/>
    </hbj:treeNode>
    <hbj:treeNode id="e_net" text="Network" isOpen="true" tooltip="Company network">
    <%
      e_net.setEncode(false);
      e_net.setText("<span style=background-color: #FFFF00>Network</span>");
    %>
    <hbj:treeNode id="n_lan" text="LAN" tooltip="Local Area Network"/>
    </hbj:treeNode>
    </hbj:treeNode>
    </hbj:tree>
    Message was edited by: Prakash  Singh

  • Htmlb:tree differentiate between nodeclick and tree node expander click

    Hi,
    how can i differentiate between nodeclick and tree node expander (to get to its children) click in my event processing in htmlb:tree element.
    <u><b>What i am trying to achieve?</b></u>
    Onload just load root node and its immediate children.
    On node expand get the children of the current node and modify htmlb:tree table2 with additional node inofs.
    on node click  call some client function.
    But my issue is that i am not able to differentiate between node expander click and node click in my event handling. Any help on this is appreciated.
    (I am not using MVC)
    Thanks in advance.
    Regards
    Raja
    Message was edited by: Durairaj Athavan Raja

    After reading your weblog I think I understand better. I did some testing with my example.  I am using the toggle = "true", so that the page returns to the server each time an expander is selected.
    <htmlb:tree id          = "myTree1"
                  height      = "75%"
                  toggle      = "true"
                  title       = "<b><otr>EQI Reporting Tree</otr></b>"
                  width       = "90%"
                  onTreeClick = "myTreeClick"
                  table       = "<%= application->selection_model->itview                             %>" >
      </htmlb:tree>
    However I have not added any coding in my event handler to respond to the expander event.  I only respond to myTreeClick (which loads some data for the given selection).  The BSP tree element itself must be doing the hard work for me. 
      if event_id cs 'tr_myTree1'.
        data: tree_event type ref to cl_htmlb_event_tree.
        tree_event ?= htmlb_event.
        if tree_event->server_event = 'myTreeClick'.
          clear appl->message1.
          appl->selection_model->get_chart_data( appl = appl
                                                 node = tree_event->node ).
        endif.
      endif.
    I pass my entire tree defintion to the element.  It appears that it only sends visible nodes to be rendered. When the expander is selected, I don't have to do anything, the tree re-renders with only the newly visible rows. 
    I tested and turned off the toggle (toggle = "false") and my page took forever to load because it was sending all the nodes to the frontend on the first load.

  • Htmlb:tree: Expand All

    I tried to implement an "Expand All" functionality for my htmlb:tree. Strangely, I can change the nodes in the tree table, but they are still displayed as closed on the screen.
    LOOP AT me->t_tree ASSIGNING <fs> WHERE status = cl_htmlb_treenode=>c_treenode_closed
                                             OR toggle = cl_bdv_co=>c_true.
          <fs>-status = cl_htmlb_treenode=>c_treenode_open.
          <fs>-toggle = cl_bdv_co=>c_false.
    ENDLOOP.
    Why is this? Has this anything to do with the TOGGLE functionality of the tree (which loads certain subtrees with a new server event) ?

    >Has anybody an explanation for this
    Delta-Handling is half Black Magic Voodoo anyway.  I assume that the DH server side cache doesn't see any change in those fields (since you have removed them) and therefore doesn't resend them to the client (it only sends changed values).
    The Client side cache still has the old values in memory and didn't get an update from the server.  Therefore it still renders the old values.
    You might try placing a delta handler block around your tree coding:
    <bsp:deltaHandlerBlock id="protectionR2" >
        <htmlb:tree ... />
    </bsp:deltaHandlerBlock>
    You can try playing with the attributes of the DHBlock.  Try attribute clientCacheClear when you want force a change to the tree.

  • Create columns for HTMLB:TREE

    Hi All,
    In our appplication we are are using <htmlb:tree />. Using CL_BSP_BEE_TABLE we were able to show checkbox inside the tree node. CL_BSP_BEE_TABLE was of great help.
    Now we need columns in tree. Is there a way to create columns using BEE?
    Thanks and regards,
    Bindiya

    I am using a tree with about 2500 nodes and and around 5000 final children (leaves)  and we dont face any problem using the approach i have explained in my weblog.
    i guess the best approach would be to just do it and check whether you are having problem.
    <i>Do you know of any good alternatives to the htmlb:tree?</i>
    there are other javascrip/dhtml trees but you will still face the same kind of issues.
    Regards
    Raja

  • Htmlb:tree

    Hi,
    I created a BSP application with dynamic htmlb:tree using TVIEW2.  Everything works fine BUT...  when I navigate to another page and I return to the page containing the tree-object, my tree is no longer displayed, although the internal table TVIEW2 is properly filled.  Anyone experienced this problem also???  Possible solution?

    What exactly happens?
    Is nothing at all displayed?
    Can you post some coding?

  • HtmlB tree context menu

    Hi guys,
    do you if it is possible to add a context menu on an htmlb tree?
    regards,
    Marc

    Hi Marc,
         You can use the hover menu which works as a context menu.
    The below code is just a sample.
    TreeNode name1 = new TreeNode(strid, strtext, name);
    //you to have build the hovermenu
    HoverMenu menu = new HoverMenu("test");
    name1.setHoverMenu(menu);

  • Report with ALV tree and ALV list?

    I need to create a report with layout as same as this one
    [http://trangiegie.com/MyFile/output.JPG]
    It looks like a report with combination of ALV tree and list. The tree works like a navigation bar. Wonder if there are any demo programs like this. Will appreciate any help.

    For Tree alone - You can check program : BCALV_TREE_02
    Program Name                   Report title
    BCALV_GRID_DND_TREE            ALV Grid: Drag and Drop with ALV Tree
    BCALV_GRID_DND_TREE_SIMPLE     ALV GRID: Drag and drop with ALV tree (simple)
    BCALV_TEST_COLUMN_TREE         Program BCALV_TEST_COLUMN_TREE
    BCALV_TEST_SIMPLE_TREE         Program BCALV_TEST_SIMPLE_TREE
    BCALV_TREE_01                  ALV Tree Control: Build Up the Hierarchy Tree
    BCALV_TREE_02                  ALV Tree Control: Event Handling
    BCALV_TREE_03                  ALV Tree Control: Use an Own Context Menu
    BCALV_TREE_04                  ALV Tree Control: Add a Button to the Toolbar
    BCALV_TREE_05                  ALV Tree Control: Add a Menu to the Toolbar
    BCALV_TREE_06                  ALV tree control: Icon column and icon for nodes/items
    BCALV_TREE_DEMO                Demo for ALV tree control
    BCALV_TREE_DND                 ALV tree control: Drag & Drop within a hierarchy tree
    BCALV_TREE_DND_MULTIPLE        ALV tree control: Drag & Drop within a hierarchy tree
    BCALV_TREE_EVENT_RECEIVER      Include BCALV_TREE_EVENT_RECEIVER
    BCALV_TREE_EVENT_RECEIVER01
    BCALV_TREE_ITEMLAYOUT          ALV Tree: Change Item Layouts at Runtime
    BCALV_TREE_MOVE_NODE_TEST      Demo for ALV tree control
    BCALV_TREE_SIMPLE_DEMO         Program BCALV_TREE_SIMPLE_DEMO
    BCALV_TREE_VERIFY              Verifier for ALV Tree and Simple ALV Tree

  • Lead selection with a tree-based table.

    I've created a recursive context node to display contents of a KM folder.  The structure has been mapped to a table, which works just fine.  I can expand nodes of the tree and display the contents of sub-folders.  Great.  However, I need to know which backing KM object has been selected via the table.  Since this is a recursive structure, using
    wdContext.currentXXXX()
    does not work, since that's the top of the tree.  Parameter mapping will only give you the column and/or row of the item selected in the table, not the object itself.
    I'm missing something obvious here, but I can't figure out how to get the context element behind the selected row in a table which is displaying a recursive structure.
    I can do this with a Tree structure, since you can map the 'path' parameter to the actual context object.  However, the Table UI doesn't offset that information (a severe oversight, at least in my mind).
    Suggestions?

    Thanks Armin, that works great.
    Had I finished reading this page:
    http://help.sap.com/saphelp_nw70/helpdata/en/60/1f1f056f057d4d962375efd3c92ed0/frameset.htm
    I would have found the correct documentation.

  • Report with Dynamic tree control

    I have a report with a TREE CONTROL.
    <p>
    A Tree is referenced to: CL_GUI_ALV_TREE_SIMPLE and is located on the left side of the screen.
    <p>
    See diagram below.  The Tree has MULTI-LEVEL nodes and the user can click on any of the nodes which will
    trigger a report (rellevant for that node) to appear in the REPORT container.
    <p>
    Everythign is working fine. 
    <p>
    I now have a requirement to add a TREE ON/OFF functionality.  I have added this by 'Freeing' TREE
    container and by initializing when the user Turns ON the TREE.  It is working fine, HOWEVER, when
    it initilizes the TREE it is COLLAPSED and obviously does not point to the NODE that was clicked.
    <p>
    My goal is to retain the value of the NODE that was pressed and EXPAND the tree to that node and
    highlight it...  Please note that I have MULTI-LEVEL nodes and the user can double click on NODES
    and ITEMS. 
    <p>
    I tried using GET_SELECTED_NODES, but it only works if the user selects the LOWEST level node/item.
    <p>
    Any advise will be appreciated.
    <p>
    Also, as an alternative, I was thinking of resizing TREE container to WIDTH of 1 when the user PRESSES
    TREE OFF and resizing back to width 200 when the user presses TREE ON.  I could not find any methods
    that would work with CL_GUI_DOCKING_CONTAINER. 
    Please help! Thank you in advance.
    <br>
    <br>
    <img src="http://img237.imageshack.us/img237/6684/bdccz3.jpg" border="0"/></a>
    <p>
    <p>

    I have a report with a TREE CONTROL.
    <p>
    A Tree is referenced to: CL_GUI_ALV_TREE_SIMPLE and is located on the left side of the screen.
    <p>
    See diagram below.  The Tree has MULTI-LEVEL nodes and the user can click on any of the nodes which will
    trigger a report (rellevant for that node) to appear in the REPORT container.
    <p>
    Everythign is working fine. 
    <p>
    I now have a requirement to add a TREE ON/OFF functionality.  I have added this by 'Freeing' TREE
    container and by initializing when the user Turns ON the TREE.  It is working fine, HOWEVER, when
    it initilizes the TREE it is COLLAPSED and obviously does not point to the NODE that was clicked.
    <p>
    My goal is to retain the value of the NODE that was pressed and EXPAND the tree to that node and
    highlight it...  Please note that I have MULTI-LEVEL nodes and the user can double click on NODES
    and ITEMS. 
    <p>
    I tried using GET_SELECTED_NODES, but it only works if the user selects the LOWEST level node/item.
    <p>
    Any advise will be appreciated.
    <p>
    Also, as an alternative, I was thinking of resizing TREE container to WIDTH of 1 when the user PRESSES
    TREE OFF and resizing back to width 200 when the user presses TREE ON.  I could not find any methods
    that would work with CL_GUI_DOCKING_CONTAINER. 
    Please help! Thank you in advance.
    <br>
    <br>
    <img src="http://img237.imageshack.us/img237/6684/bdccz3.jpg" border="0"/></a>
    <p>
    <p>

  • Client side eventing with HTMLB in a jsp file

    Hi All,
    Can u give me the solution to work with client side eventing with HTMLB with a jsp page but not with a dynpage.
    Regards,
    sireesha.

    Hi sireesha,
      Check this.
    <%@ taglib uri="tagLib" prefix="hbj" %>
    <%@ page import="com.sapportals.htmlb.enum.EventTrigger,com.sapportals.htmlb.event.Event" %>
    <hbj:content id="myContext" >
    <hbj:page title="PageTitle">
    <script language="Javascript">
    function checkinput(){
         var funcName = htmlb_formid+"_getHtmlbElementId";
         func = window[funcName];
         var inputfield1 = eval(func("inf1"));
         var input1 = inputfield1.getValue();
         if (input1==""){
              alert("Enter mandatory fields");
    </script>
    <hbj:form>
    <hbj:textView id="tv1" text="Name"/>
    <hbj:inputField id="inf1"
    type="String"
    required="true"
    jsObjectNeeded="true">
    <% inf1.setClientEvent(EventTrigger.ON_BLUR, "checkinput()"); %>
    </hbj:inputField>
    <br>
    <hbj:textView id="tv2" text="City"/>
    <hbj:inputField id="inf2" type="String"/>
    <hbj:button id="b1" text ="submit" onClick="onSubmitclicked"/>
    </hbj:form>
    </hbj:page>
    </hbj:content>
    Regards,
    Harini S

  • How to: display the pcd in a htmlb tree object?

    Hello @ all,
    I'm currently trying to implement the contents of the PCD into a htmlb tree structure for an application of mine.
    while the tree creation isn't a problem, i have no idea where to start on how to read/parse the pcd structure.
    the reason for me trying to stuff the pcd into a tree is to achieve an easier to handle navigation.
    so of anybody could point me in the right direction as how to get access to the pcd porperly and how to get the complete pcd structure (folder, iviews, everything) so that i could include it in the tree, i would be really thankful.
    cheers,
    jürgen

    Hi Jürgen,
    See http://help.sap.com/saphelp_nw04/helpdata/en/44/6aaf92f5a23672e10000000a114a6b/frameset.htm
    Only Worksets and Roles are not described, anyhow, doing a bit research via decompiling or just by searching on SDN will bring you the needed extra info; just as an example for roles access: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6112ecb7-0a01-0010-ef90-941c70c9e401
    Hope it helps
    Detlev

  • Error in drag and drop with a Tree component

    Hello, everybody.
    I'm doing a drag and drop with two trees.
    But, when I drag from a tree to another show this error:
    "oracle.job.RowNotFoundException:JBO25020: View line of oracle.jbo.Key[4.4] key not found in ViewTreeNodeRepository13_71."
    Besides that, in my property SelectionListerner, when I have this line: "#{bindings.TreeNodeRepository.treeModel.makeCurrent}" there is a warning that says: "Reference makeCurrent not found".
    Anyone can help me?
    Thanks!

    Hi,
    +Besides that, in my property SelectionListerner, when I have this line: "#{bindings.TreeNodeRepository.treeModel.makeCurrent}" there is a warning that says: "Reference makeCurrent not found".+
    Don't worry, its a designtime warning because the EL cannot be resolved. MakeCurrent is a method on the FacesCtrl binding equivalent to ADF, which is applied at runtime and not available at design time
    +But, when I drag from a tree to another show this error: "oracle.job.RowNotFoundException:JBO25020: View line of oracle.jbo.Key[4.4] key not found in ViewTreeNodeRepository13_71."+
    In drag and drop, ADF Faces performs the drag. However, the rest of the drop handling is up to the developer. Without any more information of what yur drop handler is doing, this question cannot be answered
    Frank

Maybe you are looking for