8 Replies Latest reply on May 25, 2010 6:23 AM by Nick Belaevski

    How to user nodeface and type in treenode using .xml confinguration

    ajaykumar kadiyala Novice

      Hi Richfacess user,

       

      How to add a nodeface and type values using .xml configuration. Please suggeted to me  for .xml and tree.xthml .

       

      Thanks

       

      private TreeNode treeData;
      public TreeNode getTreeData()
      {return treeData;}

      public void setTreeData(TreeNode treeData)
      {    this.treeData = treeData }
      ...........
      FacesContext context = FacesContext.getCurrentInstance();
      treeData = XmlTreeDataBuilder.build(new InputSource(getClass().getResourceAsStream("/Stations.xml")));
      .............

      Stations.xml
      <?xml version="1.0"?>
      <station name="KickRadio" type="stationname">
        <feed date="today" type="date">
         <song time="07:00" type="time">Hall  Oates - Kiss On My List</song>
         <song time="07:03" type="time">David Bowie - Lets Dance </song>
         <song time="07:06" type="time">Lyn Collins - Think (About It)</song>
         <song time="07:10" type="time">Kim Carnes - Bette Davis Eyes</song>
         <song time="07:15" type="time">KC  the Sunshine Band - Give It Up</song>
        </feed>
      </station>


      Tree.xtml

      <rich:tree id="treeXML" value="#{stations.treeData}" var="vardata" nodeFace="{vardata.type}">

      <rich:treeNode type="stationname">//not displaying correct
        <h:outputText value="#{vardata.attributes['name']}" />
      </rich:treeNode>

      <rich:treeNode type="date">
        <h:outputText value="#{vardata.attributes['date']}" />
      </rich:treeNode>

      <rich:treeNode type="time">
        <h:outputText value="#{vardata.attributes['time']}" />
        <h:outputText value=" #{vardata.text}" />
      </rich:treeNode>

      </rich:tree>

        • 1. Re: How to user nodeface and type in treenode using .xml confinguration
          Nick Belaevski Master

          Hi,

           

          Use nodeFace="#{vardata.attributes['type']}".

          • 2. Re: How to user nodeface and type in treenode using .xml confinguration
            ajaykumar kadiyala Novice

            HI Nick Belaevski/Richface users,

             

            Thanks you support ,as per yours suggestions is worked fine.

            But I have one more problem. I added a checkbox to leaf node,if you clicked on submit button . I am not able to get the selected keys of leaf node.

             

             

            --------------Tree.xthml--

             

             

             

            <h:commandButton action="#{library.getSelectedMenus}" value="submit" />

             

             

            <rich:tree id="treeXML" value="#{library.treeData}" var="vardata" nodeFace="#{vardata.attributes['type']}" switchType="ajax">

             

             

                 <rich:treeNode type=

             

            "stationName">

             

             

             

                      <h:outputText value="#{vardata.attributes['name']}" />

             

             

                 </rich:treeNode>

             

             

                 <rich:treeNode type="date">

             

             

             

             

                      <h:outputText value="#{vardata.attributes['date']}" />

             

             

             

             

             

                  </rich:treeNode>

             

             

             

             

             

             

                 <rich:treeNode type="time">

                      <h:selectManyCheckbox value="#{library.menus}"> // Selected leaf nodes by  user

             

             

             

             

             

             

             

                           <f:selectItem itemValue=

             

             

             

             

             

             

             

             

            "#{vardata.attributes['key']}" />

                      </h:selectManyCheckbox>

                          <h:outputText value="#{vardata.attributes['time']}" />

                  </rich:treeNode>

            </rich:tree>

             

             

            -----------------------Stations.xml
            <?xml version="1.0"?>
            <station name="RichRadioStation" type="stationName">
            <feed date="yesterday" type="date">
               <song time="09:00" type="time" key="RichRadioStation_yesterday_09:00"> AAAAAAAAAAAA</song>
               <song time="10:03" type="time" key="RichRadioStation_yesterday_10:03"> BBBBBBBBBBBB</song>
               <song time="11:06" type="time" key="RichRadioStation_yesterday_11:06"> CCCCCCCCCC</song>
               <song time="12:10" type="time" key="RichRadioStation_yesterday_12:10"> DDDDDDDDDDDD</song>
               <song time="01:15" type="time" key="RichRadioStation_yesterday_01:15"> EEEEEEEEEEEEEE</song>
              </feed>
              <feed date="today" type="date">
               <song time="07:00" type="time" key="KickRadio_today_07:00"> Hall  Oates - Kiss On My List</song>
               <song time="07:03" type="time" key="KickRadio_today_07:03"> David Bowie - Let's Dance</song>
               <song time="07:06" type="time" key="KickRadio_today_07:06"> Lyn Collins - Think (About It)</song>
               <song time="07:10" type="time" key="KickRadio_today_07:10"> Kim Carnes - Bette Davis Eyes</song>
               <song time="07:15" type="time" key="KickRadio_today_07:15"> KC  the Sunshine Band - Give It Up</song>
              </feed>
            </station>

             

             

            --------------------Libray.java----------------
            public class Library {
            private TreeNode treeData;
            private List menus=null;
            public Library()throws Exception
              {
               menus=new ArrayList(); 
               FacesContext context = FacesContext.getCurrentInstance();
               treeData = XmlTreeDataBuilder.build(new InputSource(getClass().getResourceAsStream("/Stations.xml")));
              }

             

            public TreeNode getTreeData() {
              return treeData;
            }
            public void setTreeData(TreeNode treeData) {
              this.treeData = treeData;
            }
            public List getMenus() {
              return menus;
            }
            public void setMenus(List menus) {
              this.menus = menus;
            }

             

             

             

             

            public

             

             

             

             

             

             

            void

            getSelectedMenus()

            {

            System.

             

            out.println("--------menus "+menus);

            // Getting null or getting Last leaf node selected  key values,request you to please provided a solutions

            );

            }

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

            please see the image  for more clarity

             

             

             

            • 3. Re: How to user nodeface and type in treenode using .xml confinguration
              Ilya Shaikovsky Master

              you using the same menus object for all selexcts component - that's why you getting always the same last object selection there. map it to model instead like

               

               

               <h:selectManyCheckbox value="#{vardata.attributes['selection']}">
              
              
              • 4. Re: How to user nodeface and type in treenode using .xml confinguration
                ajaykumar kadiyala Novice

                Hi Ilya Shaikovsky and richfaces user,

                 

                Thanks for you quick reply. I was included the same.

                 

                <h:selectManyCheckbox value="#{vardata.attributes['selection']}">

                 

                <f:selectItem itemValue="#{vardata.attributes['key']}" />

                 

                </h:selectManyCheckbox>

                 

                How to get/caputured  the left node seleted values, when command button clicked  by user,please suggest to me.

                 

                 

                <h:commandButton action="#{library.getSelectedMenus}" value="submit" />

                 

                 

                 

                 

                 

                public

                 

                 

                void

                getSelectedMenus()

                {

                          // suggested to me

                 

                );

                • 5. Re: How to user nodeface and type in treenode using .xml confinguration
                  Ilya Shaikovsky Master

                  selection already populated to the model when action fired. So you could get the model and check the new states. Also you could define valuChangeListener directly at select tag.. maybe that will be even easier.

                  • 6. Re: How to user nodeface and type in treenode using .xml confinguration
                    ajaykumar kadiyala Novice

                    Hi Ilya Shaikovsky,

                     

                    Thanks a lot.
                    if selection already populated to the model when action fired. So how  to get the model and of  checked the new states.
                    without using valuChangeListener at tag level.

                     

                    or you can give me alternative one is also fine for me.

                    Using <h:selectManyCheckbox value="#{vardata.attributes['selection']}">, I need to selected the all checkboxes in the initial construtor of the bean class.

                     

                    example

                    Library() //Constructor

                    {

                     

                    //it's initial selection of the check box

                    vardata.attributes.selection("---key1---);

                    vardata.attributes.selection("---key2---);

                    vardata.attributes.selection("---keyn---);

                    yoursuggestedcode.attribute.selection("key");

                     

                    //I need your suggestion code.

                    }

                    • 7. Re: How to user nodeface and type in treenode using .xml confinguration
                      ajaykumar kadiyala Novice

                      Hi All Richfaces Developer and Jboss commity,

                       

                      Please do the needful help,since I am facing a big issue.it's urgent.

                      • 8. Re: How to user nodeface and type in treenode using .xml confinguration
                        Nick Belaevski Master

                        Hi,

                         

                        <h:selectManyCheckbox value="#{vardata.attributes['selection']}">, I need to selected the all checkboxes in the initial construtor of the bean class.

                        Yes, or create your own implementation of Map that will return true for initial state.