1 Reply Latest reply on Sep 6, 2010 10:47 AM by Ilya Shaikovsky

    Editable tree?

    Mats Ekström Newbie

      Hi!

       

      Is there a way to get an editable tree?

       

      I'm using code below to create an TreeNodeImpl to view an object hierarchy as a tree (where Transmission is the root class):

       

      {code}

       

      StringWriter writer = new StringWriter();

      try {

        // Generate XML representation of an transmission

        JAXBContext  context = JAXBContext.newInstance(Transmission.class);

        Marshaller m = context.createMarshaller();

        m.marshal(transmission, writer);

        // Generate a tree

        logTreeNode = XmlTreeDataBuilder.build(new InputSource(new StringReader(writer.toString())));

      } catch (Exception e) {

        log.log(Level.WARNING, "Could not create XML from transmission.", e);

      }

      {code}

       

      {code:xml}

      <rich:tree switchType="client" value="#{logTreeNode}" var="log"

        stateAdvisor="#{treeDemoStateAdvisor}">

        <rich:treeNode>

          <h:outputText value="#{log}" />

        </rich:treeNode>

      </rich:tree>

      {code}

       

       

       

               // Generates XML representation of an trans

                  StringWriter writer = new StringWriter();
                  JAXBContext context;
                  try {
                      context = JAXBContext.newInstance(Trans.class);
                      Marshaller m = context.createMarshaller();
                      m.marshal(transmission, writer);
                      logTreeNode = XmlTreeDataBuilder.build(new InputSource(new StringReader(writer.toString())));
                  } catch (Exception e) {
                      log.log(Level.WARNING, "Could not create XML from transmission.", e);
                  }


      And that works as expected, but how can I get the end nodes as input fields (as h:inputText or checkbox..) and also get the xml or data model updated?