Nested tags to instantiate a tree of objects

Hi,
I have a class that represents the "site map" of a website. Each instance of this class has a "name", "href" and an array of "child" instances of the same class. The array can be null.
In this manner I can build a tree of navigational data and include it universally in my JSP's.
Here's my issue: In order to allow non-programmers edit the map, I would like to use JSP tags to instantiate the tree, instead of using Java code:
<webutil:link name="home" href="/">
   <webutil:link name="Products" href="/products" />
   <webutil:link name="Services" href="/services" />
   <webutil:link name="About Us" href="/products" />
</webutil:link>This would not result in any text output to the page, but rather objects being instantiated for later use in the page.
Any direction, links or tutorials on how to pull off such a stunt with JSP tags will be much appreciated.
Thanks,
Greg

XML might be a better solution, but using tags should work.
The Sun tutorial at http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPTags5.html#68205 should be helpful to you.
When processing a tag, determine if there is a parent tag by using getParent() or findAncestorWithClass().
If there is no parent, instantiate your site navigation object based on the tag arguments and save a reference within the tag object. You'll probably want to also add the reference to page or session scope as an attribute for later use.
If there is a parent, instantiate the new navigation object and then retrieve the parent navigation object from the parent tag (create a getNavigation() method in tag?). Then add the new navigation object to the array in the parent navigation object.

Similar Messages

  • Nested tags with a List of Objects

    I'm having trouble getting nested tags to work. Here's an example:
    My form has a List that contains a Bean called Car as well as a getter and a setter. The Car Bean has three String attributes: color, model and manufacturer. Getters and setters are present.
    When I navigate to the form, my Action class creates a single Car and adds it to the list: when the page loads I am presented with three text fields representing my Car bean. Good.
    However when I enter some text into the fields and hit the save button I get the following error:
    Error 500: BeanUtils.populateI've read a bit about nested tags but still I can't figure out what exactly I'm doing wrong.
    Here is a small sample of the JSP code;
    <html:form action="/addCar.do">
    <nested:iterate name="carForm" property="carList" type="com.foo.bean.CarBean">
      <nested:text property="color"></nested:text>
      <nested:text property="model"></nested:text>
      <nested:text property="manufacturer"></nested:text>
    </nested:iterate>
    </html:form>Should I be doing something else to properly use a nested tag? Please let me know if more details are required.
    Thank you,
    David

    I am using crystal reports to show names of a bunch of people. insted of each name comes form different function inside the oracle package, I would like to have a single function with an array of names so that I can return it easily
    eg; board member 1 (from function 1)
    board member 2 (from function 2)
    board member 3 (from function 3)
    I should get something like board member n(from a single function that has n number of members) , so that its easy for managing the list later and reduce the code
    This sounds so silly, but i am new to both crystal and pl/sql....
    please help

  • Loading a tree of objects from a cache in a single call using an aggregator

    Hi,
    I currently have the following problem. I am trying to load a tree of objects from coherence by recursing up an object tree from a child object.
    What is currently in place is something like this (not actual implementation).
    Child child...// initialisation of Child;
    List<Parent> parents = new LinkedList<Parent>();
    Parent parent = null;
    int parentId = child.getParentId();
    while (true) {
    parent = cache.get(parentId);
    if (parent != null) {
    parents.add(parent);
    parentId = parent.getParentId();
    } else {
    break;
    However, this results in a number of calls over the network to the coherence cache and is proving to be quite inefficient. What I would like is to be able to write something like a filter or an aggregation function which will simply take in the child, or the parent id of the child, and return a list of all the parents (with the recursion logic taking place on the coherence node). This will hopefully reduce network latency considerably.
    Does anybody know how to go about doing this within coherence?

    XML might be a better solution, but using tags should work.
    The Sun tutorial at http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPTags5.html#68205 should be helpful to you.
    When processing a tag, determine if there is a parent tag by using getParent() or findAncestorWithClass().
    If there is no parent, instantiate your site navigation object based on the tag arguments and save a reference within the tag object. You'll probably want to also add the reference to page or session scope as an attribute for later use.
    If there is a parent, instantiate the new navigation object and then retrieve the parent navigation object from the parent tag (create a getNavigation() method in tag?). Then add the new navigation object to the array in the parent navigation object.

  • Custom taglib with nested tag not working

    Hi everybody,
    I have a question concerning a custom taglib. I want to create a tag with nested child tags. The parent tag is some kind of iterator, the child elements shall do something with each iterated object. The parent tag extends BodyTagSupport, i have overriden the methods doInitBody and doAfterBody. doInitBody initializes the iterator and puts the first object in the pageContext to be used by the child tag. doAfterBody gets the next iterator object and puts that in the pageContext, if possible. It returns with BodyTag.EVAL_BODY_AGAIN when another object is available, otherwise BodyTag.SKIP_BODY.
    The child tag extends SimpleTagSupport and does something with the given object, if it's there.
    In the tld-file I have configured both tags with name, class and body-content (tagdependent for the parent, empty for the child).
    The parent tag is being executed as I expected. But unfortunately the nested child tag does not get executed. If I define that one outside of its parent, it works fine (without object, of course).
    Can somebody tell me what I might have missed? Do I have to do something special with a nested tag inside a custom tag?
    Any help is greatly appreciated!
    Thanks a lot in advance!
    Greetings,
    Peter

    Hi again,
    unfortunately this didn't work.
    I prepared a simple example to show what isn't working. Perhaps it's easier then to show what my problem is:
    I have the following two tag classes:
    public class TestIterator extends BodyTagSupport {
        private Iterator testIteratorChild;
        @Override
        public void doInitBody() throws JspException {
            super.doInitBody();
            System.out.println("TestIterator: doInitBody");
            List list = Arrays.asList(new String[] { "one", "two", "three" });
            testIteratorChild = list.iterator();
        @Override
        public int doAfterBody() throws JspException {
            int result = BodyTag.SKIP_BODY;
            System.out.println("TestIterator: doAfterBody");
            if (testIteratorChild.hasNext()) {
                pageContext.setAttribute("child", testIteratorChild.next());
                result = BodyTag.EVAL_BODY_AGAIN;
            return result;
    public class TestIteratorChild extends SimpleTagSupport {
        @Override
        public void doTag() throws JspException, IOException {
            super.doTag();
            System.out.println(getJspContext().getAttribute("child"));
            System.out.println("TestIteratorChild: doTag");
    }The Iterator is the parent tag, the Child shall be shown in each iteration. My taglib.tld looks like the following:
    <?xml version="1.0" encoding="UTF-8"?>
    <taglib
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web-jsptaglibrary_2_1.xsd"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1">
         <tlib-version>1.0</tlib-version>
         <short-name>cms-taglib</short-name>
         <uri>http://www.pgoetz.de/taglibs/cms</uri>
         <tag>
              <name>test-iterator</name>
              <tag-class>de.pgoetz.cms.taglib.TestIterator</tag-class>
              <body-content>tagdependent</body-content>
         </tag>
         <tag>
              <name>test-iterator-child</name>
              <tag-class>de.pgoetz.cms.taglib.TestIteratorChild</tag-class>
              <body-content>empty</body-content>
         </tag>
    </taglib>And the snippet of my jsp is as follows:
         <!-- TestIterator -->
         <cms:test-iterator>
              <cms:test-iterator-child />
         </cms:test-iterator>The result is that on my console I get the following output:
    09:28:01,656 INFO [STDOUT] TestIterator: doInitBody
    09:28:01,656 INFO [STDOUT] TestIterator: doAfterBody
    09:28:01,656 INFO [STDOUT] TestIterator: doAfterBody
    09:28:01,656 INFO [STDOUT] TestIterator: doAfterBody
    09:28:01,656 INFO [STDOUT] TestIterator: doAfterBody
    So the child is never executed.
    It would be a great help if anybody could tell me what's going wrong here.
    Thanks and greetings from germany!
    Peter
    Message was edited by:
    Peter_Goetz

  • Help with nesting tags (STRUTS)

    Hi,
    I'm having a few problems with the following nested tag:
    <input name="indicator_target_<bean:write name='indicators' property='indicator_id'/>" size="10" value="<bean:write name="TargetValuesActionForm" property="indicator_target_<bean:write name='indicators' property='indicator_id'/>"/>"/>
    The page returns no getter method for "indicator_target_", but i'm not trying to get the "indicator_target_" value i'm trying to get the "indicator_target_ + id" (i.e. indicator_target_23) value. For some reason the nested _<bean:write name='indicators' property='indicator_id'/> tag which is part of the input 'value' param is being ignored?
    anyone know how I can resolve this?

    One of the first rules of JSP custom tags - you cannot use a tag as an attribute to another tag. For dynamic attributes you have to use a runtime expression. - either <%= expr %> or in a JSP2.0 container ${expr} as well.
    Your "input" tag is plain template html. So you can use custom tags for the values of the attributes.
    The one that is failing is
    <bean:write name="TargetValuesActionForm" property="indicator_target_<bean:write name='indicators' property='indicator_id'/>"/>
    I am presuming you are in a logic:iterate loop, or equivalent.
    Something like this might work:
    <bean:define id="currentId"  name='indicators' property='indicator_id'/>
    <bean:write name="TargetValuesActionForm" property="<%= "indicator_target_" + currentId %>"/>However all of this is very nasty.
    And struts can do at least part of this for you with indexed properties. You might want to take a look at them.
    Hope this helps,
    evnafets

  • How to use nested tag in Struts

    Hi..
    Can any one guide me how to use nested tag in Struts. So far i already tried bean tag with no error but when i try to use nested tag i got error like
    javax.servlet.ServletException: Cannot find bean: "" in any scope
    Below are my class:
    action class
    session.setAttribute ("MyDetailList", detailList);
    JSP page
    <logic:iterate id="list" name="MyDetailList">
    Company ID : <bean:write name="list" property="companyID" />
    </logic:iterate>
    For bean tag, i got no error at all and below are my code for nested tag
    action class
    session.setAttribute ("MyDetailList", detailList);
    JSP Page
    <nested:nest property="MyDetailList">
    Make : <nested:text property="make"/>
    Car ID : <nested:text property="carID"/>
    </nested:nest>
    When i run the code, i got error message
    javax.servlet.ServletException: Cannot find bean: "" in any scope
    Any body can help me?
    zul

    what am I doing wrong?You will notice above that I mentioned
    YOU CAN'T USE CUSTOM TAGS AS ATTRIBUTES TO OTHER CUSTOM TAGS
    (was that loud enough for you to notice this time)?
    Try
    <html:text styleId="instruction" styleClass="text" size="50" name="instruction" property="value"/>
    //or
    <html:text styleId="instruction" styleClass="text" size="50" property="instruction" value="<%= instruction.getValue() %>"/>
    better alternative: populate your formbean with your action and just have:
    <html:text styleId="instruction" styleClass="text" size="50" property="instruction"/>
    If you set the "instruction" property of your formBean in the action, the value will be automagically reflected here.
    Cheers,
    evnafets

  • Import XML  Nested tags

    Hi all
    Here is my XML file structure
    <book>
    <section title="My Life">
    <p>
    <ol>
    <li>item 1</li>
    <li>item 2</li>
    <li>item 3</li>
    <li>item 4
        <ol>
            <li>item 1</li>
            <li>item 2</li>
            <li>item 3</li>
        </ol>
    </li>
    </ol>
    </p>
    </section>
    </book>
    I need to do two things from my XML file
    one
    I have a problem with importing my xml file. I have nested tags in my xml file. list inside list. While I am mapping tags to styles I am hang I can’t map different styles to my nested list 2nd level list. I am working with IDCS3. Is there any way to map my nested tag?
    in short
    list level One > Item 1
    TagName: <li>
    Paragraph style>ListIndentOne
    list level Two > Item 1
    TagName: <li>
    Paragraph style>ListIndentTwo
    two
    The next problem is I need to pint the value of my tag variables into indesign document is this is possible?
    <section title="My Life">
    I need to print the value of the variable value "My Life" as title style in my document.
    thanks in advance
    reagrds
    a r u l

    Hi all
    Here is my XML file structure
    <book>
    <section title="My Life">
    <p>
    <ol>
    <li>item 1</li>
    <li>item 2</li>
    <li>item 3</li>
    <li>item 4
        <ol>
            <li>item 1</li>
            <li>item 2</li>
            <li>item 3</li>
        </ol>
    </li>
    </ol>
    </p>
    </section>
    </book>
    I need to do two things from my XML file
    one
    I have a problem with importing my xml file. I have nested tags in my xml file. list inside list. While I am mapping tags to styles I am hang I can’t map different styles to my nested list 2nd level list. I am working with IDCS3. Is there any way to map my nested tag?
    in short
    list level One > Item 1
    TagName: <li>
    Paragraph style>ListIndentOne
    list level Two > Item 1
    TagName: <li>
    Paragraph style>ListIndentTwo
    two
    The next problem is I need to pint the value of my tag variables into indesign document is this is possible?
    <section title="My Life">
    I need to print the value of the variable value "My Life" as title style in my document.
    thanks in advance
    reagrds
    a r u l

  • SOAP Help Building Request With Nested Tags

    I have been struggling with Apache SOAP to try and build a request. Specifically, I don't understand how to embed these elements into the Header and Body sections. More specifically, how to do this nested tags.
    Thanks for any advice you can provide.
    Below, is a sample of the request I need to send to the server.
    <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <SOAP-ENV:Header>
              <ContinueHeader xmlns="http://www.openuri.org/2002/04/soap/conversation/">
                   <uniqueID>111111111111111</uniqueID>
              </ContinueHeader>
         </SOAP-ENV:Header>
         <SOAP-ENV:Body>
              <subscribe xmlns="http://xxxx/xxxx/xxxx/service">
                   <comHdr>
                        <WSCredentials>
                             <UserName>xxxxxxx</UserName>
                             <Password>xxxxxxxx</Password>
                        </WSCredentials>
                   </comHdr>
              </subscribe>
         </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    I can add the <UserName>xxxxxxx</UserName> <Password>xxxxxxxx</Password> to the body of the request using:
    Vector parms = new Vector();
    parms.addElement(new Parameter("UserName", String.class, username, null));
    parms.addElement(new Parameter("Token", String.class, password, null));
    call.setParams(parms);I just don't know how to add those tags within the <comHdr> and <WSCredentials> tags.

  • Jsf  warn about nested tag

    hi I try to make a dynamic data table wtih jsf 1.2; When I run my pr�ject on the server I have gor this warn in my server log.�s there ther e somebody who know this problem.
    My datatable code:
    <h:column id="column11" >
    <f:facet name="header" > </f:facet>
    <h:commandButton action="#{RefKayit. detaysil} " rendered="#{ RefKayit. edit1}" image="img/x. gif" id="s"></h:commandB utton>
    <h:commandButton action="#{RefKayit. detaysil1} " rendered="#{ RefKayit. edit}" image="img/x. gif" id="ss"></h: commandButton>
    </h:column>
    warn on the server log:
    23519: 09:21:18,551 WARN [HtmlResponseWriter Impl] HTML nesting warning on closing td: element input rendered by component : {Component-Path : [Class: javax.faces. component. UIViewRoot, ViewId: /TestReferansTanim. jsp][Class: javax.faces. component. html.HtmlForm, Id: tref][Class: javax.faces. component. html.HtmlDataTab le,Id: update][Class: javax.faces. component. html.HtmlColumn, Id: column11][Class: javax.faces. component. html.HtmlCommand Button,Id: ss]} not explicitly closed
    thanks
    how can � solve this warn?

    My guess is that you're not resetting state in the parent tag handlers (e.g., data set by the nested tag handlers) correctly for them to work with tag handler pooling. For some more info on this, see an article I wrote for ONJava.com a while back (the "Tag handler life cycle and instance reuse" section):
    http://www.onjava.com/pub/a/onjava/2001/11/07/jsp12.html?page=2
    or my JavaServer Pages book (O'Reilly), plug plug :-)
    http://www.thejspbook.com/
    Tomcat 4.1.x uses tag handler pooling by default, but LiteWebServer (which is my company's product, BTW) disables pooling by default. Not sure about Jetty, but it's likely that it also disables pooling. For Tomcat 4.x and LiteWebServer, you control pooling through an init parameter to the JSP servlet in the conf/web.xml file:
        <servlet>
            <servlet-name>jsp</servlet-name>
            <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
            <init-param>
                <param-name>enablePooling</param-name>
                <param-value>false</param-value>
            </init-param>
        </servlet>I suggest that you disable pooling in Tomcat first and see if that helps. If so, you know what the problem is and can use the hints in my article to fix it.
    Hans Bergsten (JSP and JSF EG member)

  • ALV tree using Objects

    Hi,
    I am making an ALV tree using objects and the code is crashing due to an error in the Screen 100 ( which I am using ). I tried to implement the example provided at http://www.sapdevelopment.co.uk/reporting/alv/alvtree.htm but that is not working.
    Can anyone please tell me a working example or a brief tutorial so that I can correct the logical errors in my code.
    Thanks,
    Gaurav

    Hi,
    Check whether u have uncommented the PAI and PBO modules.
    Try this one.
    REPORT ZZZTEST_3
           NO STANDARD PAGE HEADING
           MESSAGE-ID zcs_cs_001.
    1/ Report Name: ZZZ_ALV_TREE_DEMO
    The definition and implementation of the event reciever class
    include <icon>.
    Predefine a local class for event handling to allow the
    declaration of a reference variable before the class is defined.
    class lcl_event_receiver definition deferred.
    data :
         Alv Containers
         tree definition
           o_tree type ref to cl_gui_simple_tree,
         Event Handler
           o_eventreceiver     type ref to lcl_event_receiver,
           o_dockingcontainer TYPE REF TO cl_gui_docking_container.
    data :
        node structures for tree building
          i_nodes type table of abdemonode, " node table def create bespoke
          w_nodes like line of i_nodes,     " work area
          i_tree_event type cntl_simple_events, " Itab for Tree Events
          w_tree_event type cntl_simple_event.   " Work area for Tree Events
    data:
           v_ratio1            type i,     "docking container screen area
    container screen area
           v_action(12)        type c.
    Internal Tables Used for Object ALV Display.
    data:
          i_toolbar           type table of stb_button,  "Tool bar for Grid1
          i_exclude1          type ui_functions,
          i_exclude2          type ui_functions,
          i_groups            type lvc_t_sgrp,  " Group Definitions
          i_selected_rows     type lvc_t_row.   " Select row type
    constants: c_x(1)    type c value 'X',             "Checked
               c_a(1)    type c value 'A'.             "All Layouts
          CLASS lcl_event_receiver DEFINITION
    class lcl_event_receiver definition.
      event receiver definitions for ALV actions
      public section.
        class-methods:
    Status bar
           handle_user_command
            for event user_command of cl_gui_alv_grid
                importing e_ucomm,
    Tree Actions
          handle_node_double_click
            for event node_double_click of cl_gui_simple_tree
            importing node_key,
    Row Double click for dirll down.
           handle_double_click
             for event double_click of cl_gui_alv_grid
                importing e_row
                          e_column
                          es_row_no.
    endclass.
    Implementation
    Every event handler that is specified below should also be set after
    the object has been created.  This is done in the PBO processing.
    with the following command
    SET HANDLER oEventreceiver->handle_toolbar FOR o_Alvgrid.
    class lcl_event_receiver implementation.
      method handle_user_command.
    In event handler method for event USER_COMMAND: Query your
      function codes defined in step 2 and react accordingly.
      endmethod.
    *&      Method handle_double_click
    This method is called when the user double clicks on a line to drill
    down.
    The following are exported from the ALV
    LVC_S_ROW
    LVC_S_COL
    LVC_S_ROID
      method handle_double_click.
    The double click drill down processing should be
    coded in the form below.
      endmethod.
    *&      Method handle_node_double_click
    This method handles the node double click event of the tree
    LVC_S_ROW
    LVC_S_COL
    LVC_S_ROID
      method handle_node_double_click.
       perform f9903_handle_node_double_click using node_key.
      endmethod.
    endclass.
    INITIALIZATION
    INITIALIZATION.
    PERFORM f050_initialize_values.
    FORM f050_initialize_values.
      v_ratio1 = 30.  "tree size
    ENDFORM.                    "  f050_initialize_values
    START-OF-SELECTION
    START-OF-SELECTION.
    END-OF-SELECTION
    END-OF-SELECTION.
      CALL SCREEN 9001.
    *Data Selection
    FORM f9000_objects_create USING    value(pobject)
                                 pparent
                                 value(pratio)
                                 value(prows)
                                 value(pcolumns).
      CASE pobject.
        WHEN  'o_dockingcontainer'.
          IF o_dockingcontainer IS INITIAL.
            CREATE OBJECT o_dockingcontainer
              EXPORTING
               side                        = v_dock_side1
                ratio                       = pratio  "amount of screen
              EXCEPTIONS
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5
                others                      = 6.
            PERFORM f9800_error_handle USING text-e06.
          ENDIF.
          WHEN 'o_tree'.
          IF o_tree IS INITIAL.
            CREATE OBJECT o_tree
             EXPORTING
            LIFETIME                    =
               parent                      = pparent
            SHELLSTYLE                  =
               node_selection_mode         = o_tree->node_sel_mode_single
            HIDE_SELECTION              =
              name                        = 'Transactions'
             EXCEPTIONS
               lifetime_error              = 1
               cntl_system_error           = 2
               create_error                = 3
                failed                     = 4
               illegal_node_selection_mode = 5
               others                      = 6.
            PERFORM f9800_error_handle USING text-e06.
          ENDIF.
        WHEN 'o_eventreceiver'.
          IF o_eventreceiver IS INITIAL.
            CREATE OBJECT o_eventreceiver.
            PERFORM f9800_error_handle USING text-e08.
          ENDIF.
        WHEN OTHERS.
       do nothing
      ENDCASE.
    ENDFORM.                    " f9000_objects_create
    *&      Form  f9100_create_tree
          Create the Tree
         -->P_O_TREE  tree data
    FORM f9100_create_tree USING p_o_tree TYPE REF TO cl_gui_simple_tree.
      REFRESH: i_nodes.
      CLEAR: w_nodes.
    Header Tree Folder
      w_nodes-node_key = 'ROOT'.
      w_nodes-isfolder = c_x.
      w_nodes-expander = c_x.
      w_nodes-text = 'Transactions'.
      APPEND w_nodes TO i_nodes.
    Adding Root Nodes for the tree.
    Key:
    NODE_KEY, RELATKEY, RELATSHIP, HIDDEN, DISABLED, ISFOLDER, N_IMAGE,
    EXP_IMAGE, STYLE, LAST_HITEM, NO_BRANCH, EXPANDER, DRAGDROPID, TEXT
      PERFORM f9101_node_list USING: '1' 'ROOT' '' '' '' c_x '' '' '' '' ''
                              c_x '' 'Sales Orders'.
    Adding subitems for the root node.
      PERFORM f9101_node_list USING:
                            Material Details
                              'VA01' '1' '' '' '' '' '@15@' '' '' '' '' ''
                              '' 'Create Sales Orders',
                            Document Details
                              'VA02' '1' '' '' '' '' '@15@' '' '' '' '' ''
                               '' 'Change Sales Orders'.
      PERFORM f9101_node_list USING: '2' 'ROOT' '' '' '' c_x '' '' '' '' ''
                              c_x '' 'Deliveries'.
    Adding subitems for the root node.
      PERFORM f9101_node_list USING:
                            Material Details
                              'VL01' '2' '' '' '' '' '@15@' '' '' '' '' ''
                              '' 'Create Outbound Delivery',
                            Document Details
                              'VL02' '2' '' '' '' '' '@15@' '' '' '' '' ''
                              '' 'Change Outbound Delivery'.
    add the nodes to the tree object,
      PERFORM f9102_add_treenodes TABLES i_nodes
                                 USING 'ABDEMONODE'  "node definition
                                        p_o_tree.       "tree declaration
    enabling event handlers for the tree
      PERFORM f9103_tree_event_handle USING p_o_tree.
    ENDFORM.                    " f9100_create_tree
    *&      Form  f9101_node_list
          Adding Nodes in a TREE
    FORM f9101_node_list USING    value(pnodekey)
                                 value(prelatkey)
                                 value(prelatship)
                                 value(phidden)
                                 value(pdisabled)
                                 value(pisfolder)
                                 value(pimage)
                                 value(pexpimage)
                                 value(pstyle)
                                 value(plastitem)
                                 value(pnobranch)
                                 value(pexpander)
                                 value(pdragdropid)
                                 value(ptext).
      w_nodes-node_key   = pnodekey.
      w_nodes-relatkey   = prelatkey.
      w_nodes-relatship  = prelatship. "Natural number
      w_nodes-hidden     = phidden.
      w_nodes-disabled   = pdisabled.
      w_nodes-isfolder   = pisfolder.
      w_nodes-n_image    =  pimage.  "Icons / embedded bitmap
      w_nodes-exp_image  = pexpimage. "Icons / embedded bitmap
      w_nodes-style      = pstyle.
      w_nodes-last_hitem = plastitem. "Tree Control: Column Name / Item
      "Name
      w_nodes-no_branch  = pnobranch.
      w_nodes-expander   = pexpander.
      w_nodes-dragdropid = pdragdropid.
      w_nodes-text       = ptext.
      APPEND w_nodes TO i_nodes.
    ENDFORM.                    " f9101_node_list
    *&      Form  f9102_add_treenodes
          Adding the Nodes to the Tree
         -->PI_NODES  Table containg the Nodes
         -->PTABLE    Name of the Table structure name
         -->PO_TREE   tree object
    FORM f9102_add_treenodes TABLES pi_nodes TYPE STANDARD TABLE
                            USING  value(ptable)
                                   po_tree TYPE REF TO cl_gui_simple_tree.
      CALL METHOD po_tree->add_nodes
        EXPORTING
          table_structure_name           = ptable    "may need to change
          node_table                     = pi_nodes[]
        EXCEPTIONS
          error_in_node_table            = 1
          failed                         = 2
          dp_error                       = 3
          table_structure_name_not_found = 4
          OTHERS                         = 5
      PERFORM f9800_error_handle USING text-e10.
    ENDFORM.                    " f9102_add_treenodes
    *&      Form  f9103_tree_event_handle
          Event Handling for Tree.
         -->P_P_O_TREE  text
    FORM f9103_tree_event_handle USING
                                p_o_tree TYPE REF TO cl_gui_simple_tree.
      w_tree_event-eventid = cl_gui_simple_tree=>eventid_node_double_click.
      w_tree_event-appl_event = ' '. " process PAI if event occurs
      APPEND w_tree_event TO i_tree_event.
      CALL METHOD p_o_tree->set_registered_events
          EXPORTING
            events = i_tree_event
          EXCEPTIONS
            cntl_error                = 1
            cntl_system_error         = 2
            illegal_event_combination = 3.
      IF sy-subrc <> 0.
       MESSAGE A000.
      ENDIF.
      IF o_eventreceiver IS INITIAL.
        CREATE OBJECT o_eventreceiver.
      ENDIF.
      SET HANDLER o_eventreceiver->handle_node_double_click FOR p_o_tree.
    ENDFORM.                    " f9103_tree_event_handle
         -->P_IEXCLUDE  text
         -->P_1150   text
    FORM f9200_exclude_functions USING   pexclude LIKE i_exclude1
                                   value(pfunction).
      DATA: l_exclude TYPE ui_func.
      l_exclude = pfunction.
      APPEND l_exclude TO pexclude.
    ENDFORM.                    " f9200_exclude_functions
    *&      Form  f9903_handle_node_double_click
          This form is used to handle the double click event for the tree
         -->P_NODE_KEY  Node clicked.
    FORM f9903_handle_node_double_click USING  p_node_key.
      CASE p_node_key.
        WHEN 'VA01'.
         SUBMIT ZZZ_TEST AND RETURN.
         CALL TRANSACTION 'VA01'. " and skip first screen.
        WHEN 'VA02'.
          CALL TRANSACTION 'VA02'. " and skip first screen.
        WHEN 'VL01'.
          CALL TRANSACTION 'VL01'. " and skip first screen.
        WHEN 'VL02'.
          CALL TRANSACTION 'VL02'. " and skip first screen.
        WHEN OTHERS.
        do nothning.
      ENDCASE.
    ENDFORM.                    " f9903_handle_node_double_click
    *&      Form  f9700_free_objects
    This form handles the freeing of the following objects
    ALV
    Docking Container
         -->P_O_ALVGRID  text
         -->P_0020   text
         -->P_0021   text
    FORM f9700_free_objects USING pobject
                        value(ptype)
                        value(ptext).
    Need to type the field symbol or it does not work
      CASE ptype.
        WHEN 'DOCKING'.
          DATA: l_odock TYPE REF TO cl_gui_docking_container.
          l_odock = pobject.
          IF NOT ( l_odock IS INITIAL ).
            CALL METHOD l_odock->free
              EXCEPTIONS
                cntl_error        = 1
               cntl_system_error = 2
                OTHERS            = 3.
            CLEAR: pobject, l_odock.
            PERFORM f9800_error_handle USING ptext.
          ENDIF.
        WHEN 'TREE'.
          DATA: l_otree TYPE REF TO cl_gui_simple_tree.
          l_otree = pobject.
          IF NOT ( l_otree IS INITIAL ).
            CALL METHOD l_otree->free
              EXCEPTIONS
                cntl_error        = 1
               cntl_system_error  = 2
                OTHERS            = 3.
            CLEAR: pobject, l_otree.
            PERFORM f9800_error_handle USING ptext.
          ENDIF.
        WHEN OTHERS.
       do something.
      ENDCASE.
    ENDFORM.                    " f9700_free_objects
    *&      Form  f9800_error_handle
          Handles Errors
         -->P_PTEXT  text
    FORM f9800_error_handle USING    value(ptext).
      IF sy-subrc NE 0.
    add your handling, for example
        CALL FUNCTION 'POPUP_TO_INFORM'
             EXPORTING
                  titel = text-e01
                  txt2  = sy-subrc
                  txt1  = ptext.
      ENDIF.
    ENDFORM.                    " f9800_error_handle
    *PBO & PAI Modules
    *&      Module  STATUS_9001  OUTPUT
          text
    module status_9001 output.
    Set the Status Bar
      set pf-status 'Z_STATUS'.
    Set the Title
      set titlebar 'Z_TITLE'.
      perform f9000_objects_create using:
                create docking container
                  'o_dockingcontainer' '' v_ratio1 '' '',
                create a tree
                  'o_tree' o_dockingcontainer '' '' '',
                Create the event reciever
                  'o_eventreceiver' '' '' '' ''.
    Create the Tree View.
      perform f9100_create_tree using o_tree.
    endmodule.                 " STATUS_9001  OUTPUT
    *&      Module  USER_COMMAND_9001  INPUT
          text
    module user_command_9001 input.
      case sy-ucomm.
        when 'EXIT' or  'CANC'.
          perform f9700_free_objects using:
                        o_tree 'TREE' text-E03,
                        o_dockingcontainer 'DOCKING' text-E05,
                        o_eventreceiver 'EVENT' text-e09.
    leave program.
          leave.    " to SCREEN 0.
        when 'BACK'.
          perform f9700_free_objects using:
                        o_tree 'TREE' text-E03,
                        o_dockingcontainer 'DOCKING' text-e05,
                        o_eventreceiver 'EVENT' text-E09.
          set screen '0'.
          leave screen.
        when others.
      endcase.
    endmodule.                 " USER_COMMAND_9001  INPUT
    Get back to me if u have any queries. Give me ur mail id, i will send one more sample code for ALV tree. This sample program will display only Tree not grid u can add ALV grid too.
    Thanks & Regards,
    Judith.

  • Nested (tag library) tags

    hi,
    here is the problem that I am facing. I have downloaded the jakarta-input.tld and placed the concerned jar file in the lib folder of web-inf.
    in my jsp page I have the page directive to the tld and the mapping of the tld with the class is in the web.xml file.
    now I created another (my) tld file and have followed the same process.
    In my jsp I am using a tag called shuttle which is in my tld. In the doStartTag() I am printing out a complete html constructed as a string. In this html string there is another tag which belongs to the jakarta-input.tld.
    When the html is spit put by the JspWriter the browser is not recongizing a tag called <input:select> which corresponds to a tag defined in jakarta-input.tld.
    Other html elements are showing up properly except for this tag and its contents.
    Can there be nested tags?? I believe so because when the browser encounters the start of a specific tag it calls the corresponding class and so no matter what, even in this particular situation, when the browser encounters the <input:select> tag, it should look for the corresponding class with the mappings in the web.xml???
    please guide me if I am understanding it wrong. I would appreciate any kind of help.
    regards.
    f

    here are my doStartTag() and doEndTag()....
    String htmlString = "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" height=\"116\" ><tr><td><a href=\"javascript:orderModule(0,'imageId_l');\" ><img src=\"cabo/images/sru.gif\" width=\"11\" height=\"11\" border=\"0\" alt=\"Up\" vspace=\"20\"/></a></td><td rowspan=\"2\"><input:select name=\"imageId_l\" attributes=\"<%= att %>\" optionLabels=\"<%= list1 %>\" optionValues=\"<%= vals %>\"></input:select>";
      htmlString+= "</td></tr><tr><td><a href=\"javascript:orderModule(1,'imageId_l');\"><img src=\"cabo/images/srd.gif\" width=\"11\" height=\"11\" border=\"0\" alt=\"Down\" vspace=\"20\"/></a></td></tr></table></td><td><table border=\"0\" cellspacing=\"2\" cellpadding=\"0\"><tr><td><a href=\"javascript:moveModule('imageId_l','imageId_r');\"><img src=\"cabo/images/smv.gif\" alt=\"Move Right\" width=\"18\" height=\"18\" border=\"0\" vspace=\"30\" />";
      htmlString+= "</a></td></tr><tr><td><a href=\"javascript:moveModule('imageId_r','imageId_l');\"><img src=\"cabo/images/srmv.gif\" alt=\"Move Left\" width=\"18\" height=\"18\" border=\"0\" vspace=\"20\"/></a></td></tr></table></td><td class=\"table\"><table><tr class=\"shuttle\"><td width=\"3\"></td><td>Selected</td></tr></table><table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" width=\"100%\" height=\"115\"><tr><td rowspan=\"2\">";
      htmlString+= "<input:select name=\"imageId_r\" attributes=\"<%= att %>\" optionLabels=\"<%= list2 %>\"></input:select></td><td><a href=\"javascript:orderModule(0,'imageId_r');\"><img src=\"cabo/images/sru.gif\" width=\"12\" height=\"12\" border=\"0\" alt=\"Up\" vspace=\"20\"/></a></td></tr><tr><td><a href=\"javascript:orderModule(1,'imageId_r');\"><img src=\"cabo/images/srd.gif\" width=\"12\" height=\"12\" border=\"0\" alt=\"Down\" vspace=\"20\"/></a></td></tr>";
      public int doStartTag() throws JspException {
          try {
            JspWriter out = pageContext.getOut();
            out.print(htmlString);
          } catch (Exception ioException) {
          return EVAL_BODY_INCLUDE;
       public int doEndTag() throws JspException {
         try {
           pageContext.getOut().print("</table>");
         } catch (Exception ioException) {
         return EVAL_PAGE;
       }here is the output from the writer in the page
    <table border="0" cellspacing="2" cellpadding="0" height="116">
      <tr>
        <td>
          <a href="javascript:orderModule(0,'imageId_l');">
            <img src="cabo/images/sru.gif" width="11" height="11" border="0"
                 alt="Up" vspace="20"/>
          </a>
        </td>
        <td rowspan="2">
          <input:select name="imageId_l" attributes="<%= att %>"
                        optionLabels="<%= list1 %>" optionValues="<%= vals %>">
          </input:select>
        </td>
      </tr>
      <tr>
        <td>
          <a href="javascript:orderModule(1,'imageId_l');">
            <img src="cabo/images/srd.gif" width="11" height="11" border="0"
                 alt="Down" vspace="20"/>
          </a>
        </td>
      </tr>
    </table>
    </td>
    <td>
      <table border="0" cellspacing="2" cellpadding="0">
        <tr>
          <td>
            <a href="javascript:moveModule('imageId_l','imageId_r');">
              <img src="cabo/images/smv.gif" alt="Move Right" width="18" height="18"
                   border="0" vspace="30"/>
            </a>
          </td>
        </tr>
        <tr>
          <td>
            <a href="javascript:moveModule('imageId_r','imageId_l');">
              <img src="cabo/images/srmv.gif" alt="Move Left" width="18" height="18"
                   border="0" vspace="20"/>
            </a>
          </td>
        </tr>
      </table>
    </td>
    <td class="table">
      <table>
        <tr class="shuttle">
          <td width="3">
          </td>
          <td>Selected</td>
        </tr>
      </table>
      <table border="0" cellspacing="2" cellpadding="0" width="100%" height="115">
        <tr>
          <td rowspan="2">
            <input:select name="imageId_r" attributes="<%= att %>"
                          optionLabels="<%= list2 %>">
            </input:select>
          </td>
          <td>
            <a href="javascript:orderModule(0,'imageId_r');">
              <img src="cabo/images/sru.gif" width="12" height="12" border="0"
                   alt="Up" vspace="20"/>
            </a>
          </td>
        </tr>
        <tr>
          <td>
            <a href="javascript:orderModule(1,'imageId_r');">
              <img src="cabo/images/srd.gif" width="12" height="12" border="0"
                   alt="Down" vspace="20"/>
            </a>
          </td>
        </tr>
      </table>my form name is multForm
    All this code is spit into jsp when I use just <shuttle></shuttle> tag .
    The code above has a <input:select > tag which is not getting recognized! and so in my javascript, when a function calls for "imageId_l" which is one of the names of the <input:select> it is throwing error saying "document.multiForm[..].selectedIndex is null"
    id the code thats spit out not evaluated??
    regards,
    f

  • Loading an XML with multiple nested tags

    I've got some problems dealing with loading a nested tags XML file.
    Let's suppose I have such a very simple myxml.xml file:
    <ROWDATA>
    <ROW>
      <EMPNO>7369</EMPNO>
      <ENAME>SMITH</ENAME>
       </ROW>
    <ROW>
      <EMPNO>7902</EMPNO>
      <ENAME>FORD</ENAME>
    </ROW>
    </ROWDATA>
    I can create the following table:
    create table EMP
    empno NUMBER(4) not null,
    ename VARCHAR2(10),
    and then inserting the XML file in this way:
    insert into EMP
        (empno, ename)
      select extractvalue (column_value, '/ROW/EMPNO'),
          extractvalue (column_value, '/ROW/ENAME'),
      from   table
               (xmlsequence
              (extract
               (xmltype
                 (bfilename ('MY_DIR', 'myxml.xml'),
                   nls_charset_id ('AL32UTF8')),
                 '/ROWDATA/ROW')))
    so as to get inserted two rows into my table:
    EMPNO   ENAME
    7369         SMITH
    7902         FORD
    Now, and this is my question, let's suppose I have such a “more difficult” XML:
    <ROWDATA>
    <ROW>
      <COMPANY>
        <EMPNO>7369</EMPNO>
        <ENAME>SMITH</ENAME>
        <EMPNO>1111</EMPNO>
        <ENAME>TAYLOR</ENAME>
      </COMPANY>
    </ROW>
    <ROW>
      <COMPANY>
       <EMPNO>7902</EMPNO>
       <ENAME>FORD</ENAME>
      </COMPANY>
    </ROW>
    <ROW>
      <COMPANY>
      </COMPANY>
    </ROW>
    </ROWDATA>
    In this case it seems to me things look harder 'cause for every row that I should insert into my table, I don't know how many “empno” and “ename” I'll find for each /ROW/COMPANY and so how could I define a table since the number of empno and ename columns are “unknown”?
    According to you, in that case should I load the whole XML file in an unique XMLType column and than “managing” its content by using EXTRACT and EXTRACTVALUE built-in funcions? But this looks a very difficult job.
    My Oracle version is 10gR2 Express Edition
    Thanks in advance!

    Here's a possible solution using a single pass through the XML data :
    with sample_data as (
      select xmltype(
        '<ROWDATA>
        <ROW>
          <COMPANY>
            <EMPNO>7369</EMPNO>
            <ENAME>SMITH</ENAME>
            <EMPNO>1111</EMPNO>
            <ENAME>TAYLOR</ENAME>
          </COMPANY>
        </ROW>
        <ROW>
          <COMPANY>
           <EMPNO>7902</EMPNO>
           <ENAME>FORD</ENAME>
          </COMPANY>
        </ROW> 
      </ROWDATA>'
      ) doc
      from dual
    select min(case when node_name = 'EMPNO' then node_value end) as empno
         , min(case when node_name = 'ENAME' then node_value end) as ename
    from (
      select trunc((rownum-1)/2) as rn
           , extractvalue(value(x), '.') as node_value
           , value(x).getrootelement() as node_name
      from sample_data t
         , table(
             xmlsequence(extract(t.doc, '/ROWDATA/ROW/COMPANY/*'))
           ) x
    group by rn ;
    I would be cautious with this approach though, as I'm not sure the ROWNUM projection is entirely deterministic.
    As Jason said, it's probably safer to first apply a transformation in order to get a more friendly format.
    For example :
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="node()|@*">
        <xsl:copy>
          <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
      </xsl:template>
      <xsl:template match="COMPANY">
        <xsl:apply-templates select="EMPNO"/>
      </xsl:template>
      <xsl:template match="EMPNO">
        <EMP>
          <xsl:copy-of select="."/>
          <xsl:copy-of select="following-sibling::ENAME[1]"/>
        </EMP>
      </xsl:template>
    </xsl:stylesheet>

  • Nested tags vs standard tags

    can any one explain the difference b/w nested tags and standard tags.
    what is the difference b/w nested: write and bean:write

    well,why don't you check the struts documentation to know the difference
    http://struts.apache.org/1.x/struts-taglib/tlddoc/bean/write.html
    http://struts.apache.org/1.x/struts-taglib/tlddoc/nested/tld-summary.html

  • Nested Tags and Body content

    Hi
    I am working with a set of nested tags to display error messages, but when i try to get the parent class always return null.
    I add comments in the code to "debug" the tags, and the body wrote in the jsp is displayed after the comments added in the doEndTag().
    May be this is way i can't get the parent class, but i can't find how to write the code in the jsp inside the body of the tag.
    Please give me suggestions.
    Thanks in advance

    What does your code look like? Are you catching exceptions?

  • Nesting tags?

    Hi!
    I got a problem nestings html tags in swing components like JTextPane or JEditorPane.
    As far as i know there are 2 common ways of inserting html in those components, I tried both, first:
    htmlKit.insertHTML(htmlDoc,tempPos,"<font>test</font>",0,0,javax.swing.text.html.HTML.Tag.FONT);
    ...second...
    ActionEvent actionEvent = new ActionEvent(jtpMain, 0, "insertFont");
              new HTMLEditorKit.InsertHTMLTextAction("insertFont", "<font>test</font>", HTML.Tag.A, HTML.Tag.FONT, HTML.Tag.P, HTML.Tag.FONT).actionPerformed(actionEvent);
    Doesn't matter which method i use, the html code is inserted but the created node in html documents is identified as "content", not as "font". When inserting a <br> it is identified properly as a br-node.
    Since content-nodes can not contain subnodes it is not possible to nest tags this way e.g. inserting a font-tag inside an a-tag. So when inserting tags this way all tags are written behind each other instead of being nested if i want them to.
    Well I guess i am doing something wrong....
    Can someone please post some ideas or some sample code. SOmeone probably did this before.
    Thanks!

    No one out there who did this before or had the same problem?

Maybe you are looking for