myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob Korherr <jakob.korh...@gmail.com>
Subject Re: Trinidad TreeTable
Date Fri, 18 Dec 2009 12:32:39 GMT
Hi,

Try to create the TreeModel only once by multiple calls to getTree(), for
example

private TreeModel tree;

private TreeModel getTree()
{
    if (tree == null) {
        // create tree
    }
    return tree;
}

I did that in my example case.

Regards,
Jakob

2009/12/18 omaji7 <omaji7@gmail.com>

>
> Hi
> Jakob, i have done it as u said, but the problem is, it get null at this
> condition in the getSelectedRowKeys() method.
>
> if (getTree().getRowKey() != null) {
>                System.out.println("called 4");
>                List<Integer> l = (List<Integer>) getTree().getRowKey();
>                if (l.size() == 2 && l.get(0) == 0 && l.get(1) == 1) {
>                    selectedRowKeys.add();
>                }
>            }
> even though, we have created and declared RowKeys before this condition,
> and
> it is working fine, but why it is found null for getTree().getRowKey() ?
>
>
>
> Jakob Korherr wrote:
> >
> > Hi,
> >
> > You need to adapt this
> >
> > if (l.size() == 2 && l.get(0) == 0 && l.get(1) == 1) {
> >     selectedRowKeys.add();
> > }
> >
> > to fit your selection.
> >
> > Regards,
> > Jakob
> >
> > 2009/12/18 omaji7 <omaji7@gmail.com>
> >
> >>
> >> Thanks Jakob for your suggested solution, i have tried your suggestion,
> >> but
> >> still unable to initial selected nodes in the treetable.
> >>
> >> My code look like this now :
> >>
> >> public TreeModel getTree() throws Exception {
> >>         HttpSession session = (HttpSession)
> >>
> FacesContext.getCurrentInstance().getExternalContext().getSession(false);
> >>        Long userRoleId = (Long) session.getAttribute("userRoleID");
> >>        Application[] applications =
> dbops.getAllApplications(userRoleId);
> >>        //selectedRowKeys = R
> >>         List<Node1> empty1 = Collections.emptyList();
> >>        List<Node1> root1 = new ArrayList<Node1>();
> >>        List<Node1> apps = new ArrayList<Node1>();
> >>        for (Application application : applications) {
> >>             //System.out.println("application is : " +
> >> application.getApplicationName());
> >>             Set<ApplicationPage> appPages =
> >> application.getApplicationPage();
> >>            List<Node1> pages = new ArrayList<Node1>();
> >>            for (ApplicationPage applicationPage : appPages) {
> >>                pages.add(new Node1(applicationPage.getPageName(),
> >> String.valueOf(applicationPage.getPageID()), empty1));
> >>            }
> >>            apps.add(new Node1(application.getApplicationName(),
> >> String.valueOf(application.getHomePage().getPageID()), pages));
> >>
> >>        }
> >>        root1.add(new Node1("Applications", "0", apps));
> >>        tree = new ChildPropertyTreeModel(root1, "children");
> >>        return tree;
> >>    }
> >>
> >> public RowKeySet getSelectedRowKeys() {
> >>         try {
> >>            System.out.println("called 1 ");
> >>            if (selectedRowKeys == null) {
> >>                System.out.println("called 2");
> >>                selectedRowKeys = new RowKeySetTreeImpl();
> >>                selectedRowKeys.setCollectionModel(getTree());
> >>            }
> >>            else {
> >>                System.out.println("called 3");
> >>            }
> >>            if (getTree().getRowKey() != null) {
> >>                System.out.println("called 4");
> >>                List<Integer> l = (List<Integer>) getTree().getRowKey();
> >>                 if (l.size() == 2 && l.get(0) == 0 && l.get(1)
== 1) {
> >>                     selectedRowKeys.add();
> >>                }
> >>            }
> >>            else {
> >>                System.out.println("called 5");
> >>            }
> >>        } catch (Exception e) {
> >>            e.printStackTrace();
> >>         }
> >>        return selectedRowKeys;
> >>    }
> >>
> >>    public void setSelectedRowKeys(RowKeySet selectedRowKeys) {
> >>        this.selectedRowKeys = selectedRowKeys;
> >>    }
> >>
> >> The TreeTable tag is still the same as in the previous code version.
> >>
> >> Can you pls do me a favor to solve this problem, i m really stuck in it
> >> from
> >> last 4 days. :-(
> >>
> >> Appriciate in Advance.
> >>
> >> Majid.
> >>
> >>
> >> Jakob Korherr wrote:
> >> >
> >> > Hi,
> >> >
> >> > I wasn't familiar with tr:tree, but I tried a few scenarios and I came
> >> up
> >> > with this solution:
> >> >
> >> >     public RowKeySetTreeImpl getRowKeySet()
> >> >     {
> >> >         if (rowKeySet == null)
> >> >         {
> >> >             rowKeySet = new RowKeySetTreeImpl();
> >> >             rowKeySet.setCollectionModel(getTreeModel());
> >> >         }
> >> >
> >> >         if (getTreeModel().getRowKey() != null)
> >> >         {
> >> >             List<Integer> l = (List<Integer>)
> >> getTreeModel().getRowKey();
> >> >             if (l.size() == 2 && l.get(0) == 0 && l.get(1)
== 1)
> >> >             {
> >> >                 rowKeySet.add();
> >> >             }
> >> >         }
> >> >
> >> >         return rowKeySet;
> >> >     }
> >> >
> >> > This selects the second child of the first node in the tree. However,
> I
> >> > don't know if there is an easier way to do this.
> >> >
> >> > Regards,
> >> > Jakob Korherr
> >> >
> >> > 2009/12/18 omaji7 <omaji7@gmail.com>
> >> >
> >> >>
> >> >> Hi,
> >> >>
> >> >> My project is build in JSF, Hibernate and Faclets. i m using trinidad
> >> >> treetable tag to build a tree with multiselection nodes. Now i m
> >> facing
> >> a
> >> >> problem to initially selection of the nodes when page is loaded at
> the
> >> >> first
> >> >> time. i have tried alot to accomplish this task, but still unable to
> >> >> retain
> >> >> it. There is an attribute of "selectedRowKeys" in TreeTable which
> >> takes
> >> >> the
> >> >> object of "RowKeySet", but when i am building the tree in my bean,
i
> >> >> don't
> >> >> know the RowKeys generated, so how do i get my desired RowKeys to be
> >> >> selected in the tree?
> >> >>
> >> >> i am trying to provide the code below
> >> >>
> >> >> myTree.xhtml
> >> >>
> >> >> <tr:treeTable id="testTreeTable"
> >> >>                                  value="#{RoleManageBean.tree}"
> >> >>                                  var="node"
> >> >>                                  rowSelection="multiple"
> >> >>                                  initiallyExpanded="true"
> >> >>                                  rowBandingInterval="1"
> >> >>                                  horizontalGridVisible="true"
> >> >>                                  verticalGridVisible="true"
> >> >>
> >> >> selectedRowKeys="#{RoleManageBean.selectedRowKeys}">
> >> >>                        <f:facet name="actions">
> >> >>                            <tr:commandButton
> >> id="treeTableSelectButton"
> >> >> text="Submit Sel." action="#{RoleManageBean.treeTableSelect}" />
> >> >>                        </f:facet>
> >> >>                        <f:facet name="nodeStamp">
> >> >>                            <tr:column headerText="Name">
> >> >>                                <tr:outputText value="#{node.name}"/>
> >> >>                            </tr:column>
> >> >>                        </f:facet>
> >> >>                        <f:facet name="pathStamp">
> >> >>                            <tr:outputText value="#{node.name}"/>
> >> >>                        </f:facet>
> >> >>                    </tr:treeTable>
> >> >>
> >> >>
> >> >> MyBean.java
> >> >>
> >> >> public class RoleManageBean implements Serializable {
> >> >>
> >> >>    private TreeModel tree;
> >> >>    private RowKeySet selectedRowKeys = null;
> >> >>
> >> >> public TreeModel getTree() throws Exception {
> >> >>        Application[] applications = dbops.getAllApplications();
> >> >>        List<Node1> empty1 = Collections.emptyList();
> >> >>        List<Node1> root1 = new ArrayList<Node1>();
> >> >>        List<Node1> apps = new ArrayList<Node1>();
> >> >>        for (Application application : applications) {
> >> >>            Set<ApplicationPage> appPages =
> >> >> application.getApplicationPage();
> >> >>            List<Node1> pages = new ArrayList<Node1>();
> >> >>            for (ApplicationPage applicationPage : appPages) {
> >> >>                pages.add(new Node1(applicationPage.getPageName(),
> >> >> String.valueOf(applicationPage.getPageID()), empty1));
> >> >>            }
> >> >>            apps.add(new Node1(application.getApplicationName(),
> >> >> String.valueOf(application.getHomePage().getPageID()), pages));
> >> >>
> >> >>        }
> >> >>        root1.add(new Node1("Applications", "0", apps));
> >> >>        tree = new ChildPropertyTreeModel(root1, "children");
> >> >>
> >> >>        return tree;
> >> >>    }
> >> >>
> >> >> public RowKeySet getSelectedRowKeys() {
> >> >>        selectedRowKeys = new RowKeySetImpl();
> >> >>        selectedRowKeys.add(String.valueOf("1,0"));
> >> >>        System.out.println("called");
> >> >>        return selectedRowKeys;
> >> >>    }
> >> >>
> >> >>    public void setSelectedRowKeys(RowKeySet selectedRowKeys) {
> >> >>        this.selectedRowKeys = selectedRowKeys;
> >> >>    }
> >> >>
> >> >>
> >> >> Any guideline will be appriciated. Thanks in Advance
> >> >>
> >> >> Majid.
> >> >>
> >> >> Naresh Bhatia wrote:
> >> >> >
> >> >> > I am trying to learn the Trinidad TreeTable component. I created
a
> >> >> > standalone JSF application and copied the TreeTable example source
> >> from
> >> >> > the demo war, along with other necessary infrastructure. I have
the
> >> >> > TreeTable up and running. The only problem is that the text nodes
> >> are
> >> >> > showing the  html tags around it - for example:
> >> >> > text:node_0 - the text is not bolded. Any idea what the problem
> >> >> > might be? I am sure I am missing some sort of configuration.
> >> >> >
> >> >> > Thanks.
> >> >> > Naresh
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >> http://old.nabble.com/Trinidad-TreeTable-tp6311331p26841512.html
> >> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://old.nabble.com/Trinidad-TreeTable-tp6311331p26842477.html
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/Trinidad-TreeTable-tp6311331p26842673.html
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message