Tree, select leaf

I use a xml-file in a Tree-component. The xml-files has
nodes, and each node has some properties (type, id, label). I can
use the code below to read the selected item in the tree.
var xmlStr:String = myTree.selectedItem.toString();
var xmlDoc:XMLDocument = new XMLDocument(xmlStr);
var decoder:SimpleXMLDecoder = new SimpleXMLDecoder(true);
var resultObj:Object = decoder.decodeXML(xmlDoc);
id = resultObj.node.id;
This works unless I am selecting an item at the end of the
tree (the leaf). Then the object is empty.

Please create a test case using local XML data and file a bug
at bugs.adobe.com/jira in the Flex project

Similar Messages

  • A function for generate a actual tree select

    hi,
    i tried to write a function that generate a actual tree select and i think this is very helpful
    Create Or Replace Function Generate_Tree_Fun(p_Path Varchar2,
    p_Delimiter Varchar2,
    p_Level Integer,
    p_Tbl_Name Varchar2,
    p_Parent_Field Varchar2,
    p_Child_Filed Varchar2)
    Return Varchar2 Is
    v_Txt Varchar2(5000) := '';
    v_Row_Num Number;
    v_Max_Count Number;
    v_Child Varchar2(100);
    v_Parent Varchar2(100);
    v_Level Number := p_Level;
    Begin
    If (v_Level = 1) Then
    Return '';
    End If;
    If (v_Level > 1) Then
    v_Txt := '|' || Lpad('_', 6, '_');
    End If;
    If (v_Level > 2) Then
    For i In 1 .. p_Level - 2 Loop
    v_Level := v_Level - 1;
    v_Child := Ltrim(Regexp_Replace(p_Path,
    Ltrim(Replace(p_Path,
    p_Delimiter,
    ')(' || p_Delimiter) || ')',
    '\' || v_Level),
    p_Delimiter);
    Execute Immediate 'Select t.' || p_Parent_Field || '
    From ' || p_Tbl_Name || ' t
    Where t.' || p_Child_Filed || ' = :1'
    Into v_Parent
    Using v_Child;
    Execute Immediate 'Select a, b From (Select Row_Number() Over(Order By t.' ||
    p_Child_Filed ||
    ') a,Count(1) Over(Partition By t.' ||
    p_Parent_Field || ') b,t.' || p_Child_Filed ||
    ',t.' || p_Parent_Field || ' From ' || p_Tbl_Name ||
    ' t Where t.' || p_Parent_Field ||
    ' = :1 Order By t.' || p_Child_Filed || ') Where ' ||
    p_Child_Filed || ' = :2 '
    Into v_Row_Num, v_Max_Count
    Using v_Parent, v_Child;
    If (v_Row_Num <> v_Max_Count) Then
    v_Txt := Rpad('|', 20, ' ') || v_Txt;
    Else
    v_Txt := Rpad(' ', 20, ' ') || v_Txt;
    End If;
    End Loop;
    End If;
    Return v_Txt;
    End;
    select Generate_Tree_Fun(sys_connect_by_path(e.empno,','),',',level,'emp','mgr','empno') || e.ename
    from emp e
    start with mgr is null
    connect by e.mgr=prior e.empno
    enjoy it

    Arash wrote:
    hi,
    i tried to write a function that generate a actual tree select and i think this is very helpful
    We are so proud of you!

  • Tree selection event in jtree

    hi
    i'm using a jtree in my gui but im facing a problem
    jTree1.addTreeSelectionListener(new TreeSelectionListener() {
                   public void valueChanged(TreeSelectionEvent e)
                        jTree1_valueChange(e);
    as you can see that whenever i click on a particular node in the tree the tree selection event occurs which calls the valuechanged method and it does as required but if i click again on the same selection as before the tree selection event does not occur and it does not call the method so say that the node i'm selecting is supposed to be dynamic and has to be refreshed if i click on it again it will not update itself through the value changed method. can somebody please tell me a way to be able to get the valuechanged method even if i click on the same selection.
    im a bot new to java swing programing so please if you could be a little more explanatory it could help
    thanks

    You problem is talked about (and a solution proposed) in the JavaDoc.
    See the code sample in the doc header from http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTree.html

  • Tree selection bug?

    Hi,
    I don't know if this is a bug or not. When using XML as the
    data provider for the Tree component and multiple nodes have the
    same label, selecting anyone of the nodes will cause all of them to
    be selected. The problem stems from the fact that XML comparison is
    done by value. The comparison is dibe at line 6345 of ListBase. Is
    this a bug? If not, is there a known workaround?
    I attached code that reproduces the problem. Selecting the
    first node, selects the first, second and last node because, by
    value, they are all the same.
    Thanks!
    JPB

    Switch to using a strongly typed object that implements IUID,
    or just make
    sure your XML has other identifying information to it. It's
    not really that
    helpful to have 19 "foos" in your list unless there is
    something else
    different about them.
    So, something like
    <mx:XMLList id="treeData">
    <node label="Test entry 1" id="1"/>
    <node label="Test entry 1" id="2"/>
    <node label="Test entry 2" id="3"/>
    <node label="Test entry 1" id="4"/>
    </mx:XMLList>
    HTH;
    Amy
    "jpbouchard" <[email protected]> wrote in
    message
    news:g941f3$1u8$[email protected]..
    > Hi,
    >
    > I don't know if this is a bug or not. When using XML as
    the data provider
    > for
    > the Tree component and multiple nodes have the same
    label, selecting
    > anyone of
    > the nodes will cause all of them to be selected. The
    problem stems from
    > the
    > fact that XML comparison is done by value. The
    comparison is dibe at line
    > 6345
    > of ListBase. Is this a bug? If not, is there a known
    workaround?
    >
    > I attached code that reproduces the problem. Selecting
    the first node,
    > selects
    > the first, second and last node because, by value, they
    are all the same.
    >
    > Thanks!
    > JPB
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="100%"
    > height="100%">
    > <mx:Script>
    > <![CDATA[
    > import mx.controls.Tree;
    >
    > private function selectFirst(): void {
    > myTree.selectedItem = treeData[0];
    > }
    >
    > ]]>
    > </mx:Script>
    >
    > <mx:XMLList id="treeData">
    > <node label="Test entry 1"/>
    > <node label="Test entry 1"/>
    > <node label="Test entry 2"/>
    > <node label="Test entry 1"/>
    > </mx:XMLList>
    >
    > <mx:Panel title="Tree Selection Bug" height="100%"
    width="100%"
    > paddingTop="10" paddingLeft="10" paddingRight="10"
    paddingBottom="10">
    > <mx:Button label="Select First"
    click="selectFirst()"/>
    > <mx:Tree id="myTree" width="100%" height="100%"
    labelField="@label"
    > showRoot="true" dataProvider="{treeData}"/>
    > </mx:Panel>
    >
    > </mx:VBox>
    >

  • Tree selection by user or programmatically

    Hallow All!
    How can I know if tree selection mode by user or programmatically?
    I want to listen - tree selection and do some operation only if the selection made by user (mouse or keyboard) and do nothing if the selection made programmtically!
    I tried to use isFocusOwner methos:
    addTreeSelectionListener(new TreeSelectionListener() {
                   public void valueChanged(TreeSelectionEvent e) {
                        if(!TopologyTree.this.isFocusOwner()){
                             return;
    }but is doesn't work, if some text field in another panel has the focus then the tree gain the focus only after the tree selection event performed
    any help will be most appreciated!
    Eran.

    Create a substitution rule in which user name from the header is substituted to any of the fields in vendor line item. (assignment, text etc). After this you can use this for APP.
    Tarun

  • Count values for tree root leaf

    Hi,
    I have a problem finding a solution for the following situation:
    I have a tree looking like that
    table categories (c_id, c_parent_id)
    1
    |--2
       |--21
       |--22
    |--3
       |--31
       |--32
    |--4
       |--41
       |--42
    A table products with x rows each connected to one tree leaf
    table products (p_id, p_c_id, p_name)
    1,2,test1
    2,21,test2
    3,21,test3
    3,3,test4
    4,31,test5
    5,32,test6
    4,4,42,test7
    result of select should look like:
    2,3
    3,3
    4,1To all these tree leaf have "1 to 1/n" values in table products. I want to calculate the count of rows for the LEVEL 1 leafs + there sub leafs (2,3,4).
    I can't get it to work...
    Thanks ahead.
    Regards,
    Tobias

    Hi,
    I'm not sure I understand the problem.
    It would hlep if you could post the CREATE TABLE and INSERT statements to re-create your data.
    Be careful to use terms correctly. A "leaf" is a node that has no children, so it's not clear what you mean by "sub-leaf". "LEVEL 1" refers to nodes that have no parents. When you say "I want to calculate the count of rows for the LEVEL 1 leafs ", I think you don't really mean "LEVEL 1 leafs": I think you mean "LEVEL 2 nodes", whether they are leafs or not.
    If I guessed correctly, this is a simple GROUP BY problem. The only complicated part is finding the LEVEL 2 node to GROUP BY:
    WITH       tree           AS
         SELECT  c_id
         ,     REGEXP_SUBSTR ( SYS_CONNECT_BY_PATH (c.c_id, ',')
                         , '[^,]+'
                         , 1
                         , 2
                         )     AS grp_id
         FROM     categories     c
         WHERE     LEVEL     > 1
         START WITH     c_parent_id     IS NULL
         CONNECT BY     c_parent_id     = PRIOR c_id
    SELECT       grp_id
    ,       COUNT (*)     AS cnt
    FROM       tree          t
    JOIN       products     p     ON t.c_id     = p.p_c_id
    GROUP BY  grp_id;

  • Issue with creation of ADF Table from ADF Tree selection

    Hi,
    Following is the usecase.
    I've created ParentVO & ChildVO from a single table with view criteria to filter the nodes.And then created two View links ParentToChild & ChildToChild.
    Added VOs & corresponding ViewLinks to ApplicationModule. It's got created hierarchy as Parent1->Child1->Chiled2 in Data model section of AM.So Iam done with tree creation process in Model.
    As VC can't be applied for sub levels. In order to set the VCs for sublevels, followed the below approach.
    Created a bind variable for tree. I've set the VC for both parent & child VOs in managed bean before setting the tree variable in setTree method. So now Iam able to display the required tree in UI with applying VCs.
    Now , I can select the required nodes from tree and then click on command button to display the selection list as a table.
    In order to achieve this, I tried below two options.
    1) Created separate Child VO instance (Child3) from Child VO and applied same view which applied initially. and the dragged the Child3 from Datacontrol to UI(jsff) as a table. When I run the application,it's displaying all the records from the DB table without applying VCs.
    2) Dragged the Child2 as a table on UI. When I run the application, it's displaying first record from the table without applying VC.
    But no luck in getting the required functionality.
    I've Following queries.
    a) If we update any transient attribute value for an VO instance, will it effect at VO level or only for that particular instance?
    Why because, I've created new instance of same VO. But the changes are not effecting for transient attributes in the new instance of VO.
    b) Can some one suggest on my usecase to display the selected nodes from a tree in table format?
    I tried my level best to explain the usecase. But let me know,if you have any queries on my usecase.
    Thanks in advance,
    Samba.

    This is my code:
    <af:column id="c1" headerText="Sponsor Status">
    <af:selectOneChoice label="Label 2" id="soc1" value="#{row1.sponsorStatusDesc}"
    validator="#{backingBeanScope.EditSponsorDetails.OnSponsorStatusChange}"
    valuePassThru="true">
    <f:selectItems value="#{pageFlowScope.confLists.spStatus}"
    id="si1"/>
    </af:selectOneChoice>
    </af:column>
    and this i what HTML code says..
    <select id="confSponsor:r2:0:tbIEEEsp:0:soc1::content" class="x2h" name="confSponsor:r2:0:tbIEEEsp:0:soc1">
    <option _adftmpopt="t" value="" title=""></option>
    <option value="4" title="Approved">Approved</option>
    <option value="3" title="Declined">Declined</option>
    <option value="6" title="New">New</option>
    <option value="2" title="Not Valid">Not Valid</option>
    <option value="5" title="On Hold">On Hold</option>
    <option value="1" title="Pending Approval">Pending Approval</option>
    <option value="7" title="Unidentified">Unidentified</option>
    </select>
    Stll i cannot see any value populated in SelectOneChoice

  • Navigate from tree selection to parameterized report on same page

    I have a simple tree showing the departments and roles within our organization.
    I have a simple report showing the skills required for each node in the tree, sometimes general skills that apply to whole department, sometimes specialized skills for the roles within a department.
    I've created a page that has two regions. I managed to get the tree on the left and report on the right by including the two regions in the same display point and changing the column of the report to "2".
    When I click a node in the tree, I want the ID behind the selection to be passed to the simple report. The report will show the skills mapped to the selected node in the tree.
    But since the report is on the same page, I imagine this might be a bit tricky. When the user clicks a node, the whole page would have to be refreshed, preserving the tree expanded to the point where the user clicked, and running the report with the now filled ID.
    In order to do this, I guessed I'd need an application item that preserved state. I created item F1000_OU_ID.
    The SQL for the tree is :
    select "OU_ID" id,
    "PARENT_OU_ID" pid,
    "OU_NM" name,
    'f?p=&APP_ID.:1:&SESSION.::NO::F1000_OU_ID:'||"OU_ID" link,
    null a1,
    null a2
    from "#OWNER#"."TR_OU"
    order by seq_num
    The SQL for the report is:
    SELECT s.skill_type,
    s.skill_nm
    FROM tr_skill s,
    tr_ou_skill os
    WHERE s.skill_id = os.skill_id
    AND os.ou_id = :F1000_OU_ID
    Under the report region, I gave it a conditional display directive to not display until F1000_OU_ID was not null.
    That's as far as I've gotten. The page runs. The regions display where I want them. But when I click nodes in the tree, the page blinks and nothing happens to the report. What am I missing Aces?
    bc

    200 views and 1 reply? Come, come, Aces, you can do better than that!
    Leo, thanks for taking the time to look at it. As I understand it, the "bind" or "host variable" syntax of preceding colon, e.g. ":F1000_OU_ID" is used when referring to application or page items from a SQL Query. The "substitution" syntax of preceding ampersand and following period, e.g. "&F1000_OU_ID." is used when referring to application or page items from things like HTML text.
    To verify this, I used one of the blank pages in my app, page 5. I created two regions, one HTML text, one a report based on a SQL Query.
    For the HTML text, I typed in
    Here is the application item value &F1000_OU_ID..
    For the report's SQL query, I typed in
    SELECT 'OU_ID selected is ['||:F1000_OU_ID||']' text
    FROM dual
    These both work as expected. After I have clicked on a node in Page 1's tree, the F1000_OU_ID is set to a value and that value then appears on page 5 in the two test regions mentioned above.
    So I have no trouble passing stateful values between different pages. My problem, perhaps poorly worded in the original post, is how to "pass" the selected value to the same page, since clicking a link in the tree refreshes the page it is on, in order to pass the value to the report region on the same page.
    If anyone has done this before, please chip in or point me to the thread. Various searches in the forum were just coming up with too many non-relevant results, so I thought I'd ask the experts. Thanks in advance!
    bc

  • Tree Select BUG?

    Came across a little problem, don't know if I'm doing something wrong or if it is a genuine bug.
    Here's what I'm seeing:
    1) I run a program that at the beginning deletes all tags in a tree using the Delete Items Invoke Node with an empty string constant and a True constant for the Delete Children part.
    2) I select all the items in the tree, and display all the tags from the tree using the All Tags Property Node, and display the selected tags directly from the output of the tree icon.
    3) I rerun the program, which deletes all the tags as mentioned before, use a different data set, select all those items, and when it displays All Tags it only has the tags from that run, BUT the Selected Tags has all the selected tags from the current run AND all the tags from the previous run.
    The solution of course is to simply create a local variable of the tree and at startupwire an empty string arrary to it. This shouldn't be necessary if the Delete Items deletes all the tags.
    Attached is a VI showing the BUG
    Michael
    Additional NOTE: If you continue running the VI, the selected tags will pile up UNTIL you manually right click on the tree and hit "Delete All Items"
    Message Edited by miguelc on 03-02-2007 10:46 AM
    Attachments:
    TreeSelectBUG.vi ‏23 KB

    No problem
    >>What is a CAR?
    CAR stands for Corrective Action Request - it's a formal bug report to R&D.
    >>Can anyone search these CARs before posting a supposed bug like I just did? Can you find them online, if so where?
    We post the CAR IDs online so that customers can follow up with them if they'd like, and easily refer to them.  The LabVIEW Champions maintain a monthly bug thread where you'll find pretty much everything BUG that's been posted online - if you search the forum for "monthly bug" (quotes not necessary) you'll see a slew of monthly bug threads returned.  You can also search the forum in general for keywords related to your bug, to see if anyone else has reported it.  Of course there is also a bug list/database which is maintained internally at NI, but the public doesn't have access to that.
    I hope this helps!
    Best Regards,
    JLS
    Message Edited by JLS on 03-08-2007 11:35 AM
    Best,
    JLS
    Sixclear

  • Can't get child node in tree selection listener

    I am making a fusion web application using JDeveloper 11G (11.1.1.2.0).
    I have created two view objects linked together. Let's call them VoDepartments and VoEmployees, linked on DepartmentId.
    I hava made a tree with a af:switcher
    <af:switcher id="s1" facetName="#{node.hierType.structureDefName}">
    <f:facet name="view.VoDepartments">
      <af:outputText value="#{node}" id="ot1"/>
    </f:facet>
    <f:facet name="view.VoEmployees">
      <af:outputText value="#{node}" id="ot2"/>
    </f:facet>
    </af:switcher>I made a selection listener based on a guide by Frank Nimphius
    RichTree tree1 = (RichTree) selectionEvent.getSource();
    RowKeySet rks2 = selectionEvent.getAddedSet();
    Iterator rksIterator = rks2.iterator();
    if (rksIterator.hasNext()){
      List key = (List)rksIterator.next();
      JUCtrlHierBinding treeBinding = null;
      treeBinding = (JUCtrlHierBinding) ((CollectionModel)tree1.getValue()).getWrappedData();
      JUCtrlHierNodeBinding nodeBinding = nodeBinding = treeBinding.findNodeByKeyPath(key);
      String nodeStuctureDefname = nodeBinding.getHierTypeBinding().getStructureDefName(); //Here is the nullpointerexception for employees
      String employees = "view.VoEmployees";
      String departments = "view.VoDepartments";
      if (nodeStuctureDefname.equalsIgnoreCase(departments)){
       String dept = (String) nodeBinding.getAttribute("Department_name");  
       System.out.println("Department = "+dept);
      else if (nodeStuctureDefname.equalsIgnoreCase(employees)){
       String emp = (String) nodeBinding.getAttribute("First_name");  
       System.out.println("Employee = "+emp);
      else{
       //what the heck did the user click on? Ask him ;-)
    }Pagedef:
    Executables:
    <iterator Binds="VoDepartments2" RangeSize="25" DataControl="AppMainDataControl" id="VoDepartments2Iterator"/>
    Bindings:
    <tree IterBinding="VoDepartments2Iterator" id="VoDepartments2">
    <nodeDefinition DefName="view.VoDepartments" Name="VoDepartments20">
      <AttrNames>
       <Item Value="DepartmentId"/>
      </AttrNames>
      <Accessors>
       <Item Value="VoEmployees"/>
      </Accessors>
    </nodeDefinition>
    <nodeDefinition DefName="view.VoEmployees2" Name="VoDepartments21">
      <AttrNames>
       <Item Value="First_name"/>
       <Item Value="Last_name"/>
      </AttrNames>
    </nodeDefinition>
    </tree>The tree works just fine and list all it should list. I can click the department and my selection listener print the departments name in the console.
    I can expand a department and list all employees. The problems is when I click an employee, I get null pointer exception.
    I have found out that the selectin listener can't find nodeBiding for employees. So nodeBinding.getHierTypeBinding().getStructureDefName(); throw NullpointerException.
    Anyone have an idea of what's wrong? Please help.
    -Thomas
    Edited by: Thomas H on Mar 22, 2010 8:21 AM

    Hi,
    if you open the tree binding editor, it has an entry "Target Data Source" for each of the node levels that you can use and point to an iterator binding representing the node. Not sure if this solves the issue, but chaces are.
    1. create an iterator for a child VO (using the not dependent child VO instance)
    2. Edit Target Data Source for the binding to e.g. ${bindings.EmployeesView1Iterator}
    Frank

  • Removal of Group Tree selection results in Highlighting

    Hello all,
    I'm using CR for VS2010 SP1
    I was just wondering how I can remove the highlighting when I select a Group Tree item.
    For example, when I select an item in the Group Tree, the report returns with the selected item "highlighted".
    Is there a way to remove the highlight?
    Thanks for any help with this.
    JohnMc
    Edited by: JohnMc3 on Jun 1, 2011 3:49 PM

    Hi John,
    Sorry I got ahead of myself. What I was suggesting is if you click anywhere else in the viewer the highlight is removed. I was looking/thinking if an event could be triggered to set focus somewhere else the highlight would be removed.
    Other than that I don't see any other way. Odd your users don't want to see what they clicked on... What ever you are used to I guess....
    No option directly. If you want add your request to Idea Place and the PM's will look into it.
    Just thought of something else, Hide the Group Tree and create your own, then you have full control over what it looks like. Lots of work for a minor appearance preference though...
    Thanks
    Don
    Edited by: Don Williams on Jun 2, 2011 6:42 AM

  • Dynamic tree selected node property id issue...

    hi -
    I'm successfully building a two-tier tree dynamically, but when a node is selected, it isn't consistently giving the correct property id for that node... sometimes it's correct, sometimes it's null, sometimes I have to select the node twice to get a value, or it shows the value from the previous selected node...
    I've tried tree1.getSelected() and tree1.getCookieSelectedTreeNode() but it's still the same result... it acts as though the cookie isn't getting updated each time... I've tried it with and without setting 'immediate' with the same result... below is the relevant part of my code... does anyone see why it's not getting the selected property id each time? help and suggestions welcome... Thanks
    try {
    java.util.List newNodeChildren = newNode.getChildren();
    while (srs.next()){
    TreeNode newNode2 = new TreeNode();
    newNode2.setTarget("_blank");
    newNode2.setText(srs.getString( "issue_title"));
    newNode2.setId("x" + issue_id);
    //Setup action event
    Hyperlink nodelink = new Hyperlink();
    nodelink.setText(newNode2.getText());
    nodelink.setId(newNode2.getId());
    Class[] signatures = {ActionEvent.class};
    MethodBinding mb1 = FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{Page2.treeNodeActionListener}", signatures);
    nodelink.setActionListener(mb1);
    newNode2.getFacets().put(newNode2.CONTENT_FACET_KEY, nodelink);
    newNodeChildren.add(newNode2);
    srs.release();
    } catch(SQLException ex) {
    / error("SQL Error StatusTree Retrieval: " + ex);
    public void treeNodeActionListener(ActionEvent event) {
    String id = tree1.getCookieSelectedTreeNode();
    String actualId = id.substring(id.lastIndexOf(":")+2);
    info("treeNodeActionListener actualId = " + actualId);
    }

    Hi,
    1 I dropped Tree component from Palette. I deleted TreeNode1.
    <ui:tree binding="#{Navigator.tree1}" expandOnSelect="false" id="tree1" immediate="true" style="left: 0px; top: 0px; position: absolute" text="Sometext"/>
    2 In the init() method I called paintTree()
    It works fine.
    I use action method because I need only the id of selected node but I tested also listener method and it works
    Here is my code
    public void paintTree(){
    ArrayList conturi=new ArrayList();
    TreeNode nodN1 = new TreeNode();
    TreeNode nodN2 = new TreeNode();
    TreeNode nodN3 = new TreeNode();
    TreeNode nodN9 = new TreeNode();
    String Id;
    int lga=0;
    int lgc=0;
    try {
    conturi=getSessionBean1().getSes01FacadeRemoteClient1().getMyEjbMethod();
    } catch (Exception ex) {
    log(".....", ex);
    Iterator iterator=conturi.iterator();
    while (iterator.hasNext()) {
    detalii.Conturi cont=(detalii.Conturi)iterator.next();
    lgc=cont.getConts().length();
    if (lga < lgc) {
    if (lgc == 1) {
    nodN1=new TreeNode();
    Id= "Node_"+cont.getId();
    nodN1.setId(Id);
    nodN1.setText(cont.getDenumire());
    tree1.getChildren().add(nodN1);
    if (lgc == 2){
    nodN2=new TreeNode();
    Id= "Node_"+cont.getId();
    nodN2.setId(Id);
    nodN2.setText(cont.getConts()+"-"+cont.getDenumire());
    nodN2.setStyleClass("leftAligned");
    nodN1.getChildren().add(nodN2);
    if (lgc == 3){
    nodN3=new TreeNode();
    Id= "Node_"+cont.getId();
    nodN3.setId(Id);
    nodN3.setText(cont.getConts());
    nodN3.setStyleClass("leftAligned");
    FacesContext context=FacesContext.getCurrentInstance();
    MethodBinding mb1 = context.getApplication().createMethodBinding("#{Navigator.treeNode_action}", null);
    nodN3.setAction(mb1);
    nodN2.getChildren().add(nodN3);
    } //end-if
    } //end while
    public String treeNode_action() {
    try {
    clientId=tree1.getCookieSelectedTreeNode();
    String id =clientId.substring(clientId.lastIndexOf("_")+1);
    getSessionBean1().setContId(id);
    info("clientId = "+ clientId);
    } catch (Exception ex) {
    log("Error Description", ex);
    return null;
    }

  • Loading Tree Node/Leaf causing numerous errors

    I am loading a tree with UNSPSC codes using an application engine program with code borrowed from a delivered app engine program. The code loads most of the codes, however I receive numerous errors as follows:
    Node not Found (92,3209) - I get this a lot but the data still loads in both PSTREENODE and PSTREELEAF
    Return: 805 - ORA-00001: unique constraint (FS.PS_PSTREELEAF) violated
    Failed SQL stmt:UPDATE PSTREELEAF SET TREE_NODE_NUM = :1, OLD_TREE_NODE_NUM = 'N' WHERE SETID = :2 AND SETCNTRLVALUE = :3 AND TREE_NAME = :4 AND EFFDT = TO_DATE(:5,'YYYY-MM-DD') AND OLD_TREE_NODE_NUM = 'Y' AND TREE_NODE_NUM = :6
    Tree Save error (92,3061)
    -- This error will rollback my changes to my last commit point, which, because of this error, I am committing after every value (saving tree, closing tree, and reopening the tree).
    Node index error (0,0)
    Node insert error (0,0)
    -- These errors still allow me to enter the data.
    A node without a parent was detected: %1 (25,22)
    -- This error causes an abend.
    The code used to update the tree is very simple (this code was copied verbatim from PV_CP_LOAD along with additional functions):
    REM ****************************************************************************************;
    Function AddToTree(&CAT_ID, &CAT_ID_PAR, &CAT_NAME, &ACCOUNT, &SIBLING)
    REM ****************************************************************************************;
    rem Add child to parent;
    If &CAT_ID <> &FIRST_NODE Then
    &MYNODE = &MS_TREE.FindNode(&CAT_ID, "");
    If None(&MYNODE) Then
    &MYNODE = &MS_TREE.FindNode(&CAT_ID_PAR, "");
    If All(&MYNODE) Then
    &NEWNODE = &MYNODE.InsertChildNode(&CAT_ID);
    If All(&NEWNODE) Then
    &NEWLEAF = &NEWNODE.INSERTDYNCHILDLEAF();
    &NodeCount = &NodeCount + 1;
    End-If;
    End-If;
    Else
    rem in case tree node is already there, but category isn't;
    rem addcategories(&CAT_ID, &CAT_NAME, &ACCOUNT, &CATEGORY_REC);
    End-If;
    End-If;
    End-Function;
    I am getting roughly 50% failure rate.
    Is there a database issue? Configuration of my Tree?

    What I discovered is that Node API method INSERTDYNCHILDLEAF tries to re-number all the leafs inserted each time it is called. However, it doesn't check to see if the TREE_NODE_NUM already exists. Since the TREE_NODE_NUM column is a key, it causes a unique constraint error.
    I pointed this out to Oracle, however, since I was using this function in a custom app engine program, they would not look at the problem. My app engine trace clearly showed the problem.
    I ended up re-writing the program to insert directly into the PSTREENODE and PSTREELEAF tables, controlling the TREE_NODE_NUM and PARENT_NODE_NUM columns myself. The result was a tree with 20499 rows with 0 audit errors.

  • Af:tree selected item

    I want to display the selected item from a tree (and to store this into a variable). I tried with selection_listener, but I don't know exactly what to write in the bean. The disclosed_row_keys is used to expand all nodes.
    <af:tree value="#{bindings.ConfigTreeParent2.treeModel}"
    var="node"
    rowSelection="single" id="tree1"
    selectionListener="#{left_tree.selection_listener}"
    disclosedRowKeys="#{left_tree.disclosed_row_keys}">
    <f:facet name="nodeStamp">
    <af:outputText value="#{node}"/>
    </f:facet>
    </af:tree>
    Thanks,
    vio

    Hi vio,
    The method signature for selectionListener is
    public void someMethodName(SelectionEvent ev);
    The selection event contains the selected row keys (well actually it contains the delta which should be improved imho like oldSelection and newSelection, but in the case of single selection, you can simply use the added list more or less), you can then extract the data associated with each row keys. So, in your case, I suggest you inject the TreeModel in your bean. Here's an example:
    In the code:
    public class MyTreeController
        private TreeModel model;
        private MySelectionManager selectionManager;
        public TreeModel getTreeModel()
            return model;
        public void setTreeModel(TreeModel model)
            this.model = model;
        public MySelectionManager getSelectionManager()
            return selectionManager;
        public void setSelectionManager(MySelectionManager manager)
            this.selectionManager = manager;
        public void selectionPerformed(SelectionEvent ev)
            Object selected = getFirstRowKey(ev.getAddedSet());
            if (selected == null)
                Object unselected = getFirstRowKey(ev.getRemovedSet());
                if (selectionManager.isSelected(getRowData(unselected)))
                    selectionManager.setSelection(null);
            else
                selectionManager.setSelection(getRowData(selected));
        private Object getFirstRowKey(RowKeySet set)
            for (Object key : set)
                return key;
            return null;
        private Object getRowData(Object rowKey)
            TreeModel model = getTreeModel();
            Object oldRowKey = model.getRowKey();
            try
                model.setRowKey(rowKey);
                return model.getRowData();
            finally
                model.setRowKey(oldRowKey); // Always restore the state
    public class MySelectionManager
        private Object selection; // Or another more precise type
        public Object getSelection()
            return selection;
        public boolean isSelected(Object data)
            return selection != null && selection.equals(data);
        public void setSelection(Object selection)
            this.selection = selection;
    }In the faces-config.xml
    <managed-bean>
      <managed-bean-name>selectionManager</managed-bean-name>
      <managed-bean-class>MySelectionManager</managed-bean-class>
      <managed-bean-scope>pageFlow</managed-bean-scope> <!-- That one can be persistent across requests -->
    </managed-bean>
    <managed-bean>
      <managed-bean-name>treeController</managed-bean-name>
      <managed-bean-class>MyTreeController</managed-bean-class>
      <managed-bean-scope>request</managed-bean-scope>
    <!-- request scope is important here since we don't know the exact lifespan of bindings.ConfigTreeParent2.treeModel -->
      <managed-property>
        <property-name>selectionManager</property-name>
        <property-class>MySelectionManager</property-class>
        <value>#{selectionManager}</value>
      </managed-property>
      <managed-property>
        <property-name>treeModel</property-name>
        <property-class>org.apache.myfaces.trinidad.model.TreeModel</property-class>
        <value>#{bindings.ConfigTreeParent2.treeModel}</value>
      </managed-property>
    </managed-bean>In your page:
    <af:tree value="#{treeController.treeModel}"
             var="node"
             id="tree1"
             rowSelection="single"
             selectionListener="#{treeController.selectionPerformed}"
             disclosedRowKeys="#{left_tree.disclosed_row_keys}">
      <f:facet name="nodeStamp">
        <af:outputText value="#{node}"/>
      </f:facet>
    </af:tree>Note that I preferred to use the tree model from the bean rather than using directly the databindings here. I did so to improve reusability and declarativity of the page as you could now simply alter the injected tree model within the faces-config to have your page point on a completely different data source.
    Regards,
    ~ Simon

  • Howto: display dynamic form on tree selection (jdev 11gR1)

    Heya,
    another question by myself, hoping for an advice.
    I finally made a tree including different types of "objects" into one tree (based on ADF BC). Simple example use case used in this post: displaying employee hierarchy PLUS assigned projects per employee.
    So my current problem is: what is the "way to go" to change the form in the "content" facet (made a simple splitter layout with tree in left facet and "content" in right facet) AND binding the data to it? Clicking on an employee would open the employee form and load data for selected employee into it, but clicking on a project would open the project form and loading data for selected project into it. I have all data available in the tree application module and the decision "what to display" is based on one of the attributes.
    All tutorials I found so far for master/detail are kinda "static" (linking employee tree to employee form) and I can't figure out how to do want I want to do.
    Is this possible going the declarative way? If yes, how? Or do I have to code something? If yes, how? No need for actual code, just need a hint what to look for.. feeling lost atm.
    Any help is highly appreciated. :)

    Hi,
    here's how you do it
    1. Create a iterator binding for the project ViewObject (choose a ViewObject instance that is not dependent to the employees ViewObject you use as the tree top level)
    2. In the binding editor, expand the Data Source entry (below the rule attribute configuration) and create an EL expression that references the iterator bindingyou created
    This ensures that selecting an emplloyee is synchronized with the Employee iterator used to build the top level nodes and the selected project is synchronized with the project iterator node.
    3. Add a switcher component to switch between the employee and the project edit form
    4. Create a facet in the af:switcher that has the name of the full employee view object e.g. adf.mysample.EmployeesView
    5. Create a facet in the af:switcher for the full name of the Project VO
    6. Drag and drop the EmployeeView entry from the data Controls palette as a form into the Employees facet
    7. Do the same for the Projects (make sure you use the Projects VO that is not depedent)
    Set the default value of the switcher too point to the facet that should be shown by default. The value of the switcher set to an EL that points to a managed bean method or memory attribute. Upon selecting a node (you can use the tree node selection listener) you access the selected tree node. The selection listener code woud look as shown below
      //tree reference can be obtained from the selectionListener event (Source) or from a JSF component binding property reference
      //example uses the latter
      RichTree tree = this.getTree1();
      //get selected row keys. This could be a single entry or
      //multiple entries dependent on whether the tree is
      //configured for multi row selection or single row selection
      RowKeySet rks = tree.getSelectedRowKeys();
      Iterator rksIterator = rks.iterator();
      //assuming single select use case. Otherwise, this is where you
      //need to add iteration over the entries in the multi select use case
      if (rksIterator.hasNext()){
        //a key is a list object that containe the node path information for the
        //selected node
        List key = (List)rksIterator.next();
        //determine the selected node. Note that the tree binding is an instance of
        //JUCtrlHierBinding
        JUCtrlHierBinding treeBinding = null;
        //We can get the binding information without using EL in our Java, which you always should
        //try to do. Using EL in Java is good to use, but only second best as a solution
        treeBinding = (JUCtrlHierBinding) ((CollectionModel)tree.getValue()).getWrappedData();
        //the row data is represented by the JUCtrlHierNodeBinding class at runtime. We get the node value
        //from the tree binding at runtime     
        JUCtrlHierNodeBinding nodeBinding = treeBinding.findNodeByKeyPath(key);
            //the JUCtrlHierNodeBinding object allows you to access the row data, so if all you want is to
        //get the selected row data, then you are done already. However, in many cases you need to further
        //distinguish the node, which is what we can do using the HierTypeBinding
        String nodeStuctureDefname = nodeBinding.getHierTypeBinding().getStructureDefName();
       //determine the selected node by the ViewObject name and package
       String employeesDef = "adf.mysample.EmployeesView";
       String projectDef = "adf.mysample.ProjectsView";
      if (nodeStuctureDefname.equalsIgnoreCase(empoyeesDef)){
         // change value reference used in af:switcher and partially refresh the af:switcher component to show the edit form
         // e.g. change the value of the refrenced memory attribute or managed bean variable
       else if (nodeStuctureDefname.equalsIgnoreCase(projectDefDef)){
         // change value reference used in af:switcher and partially refresh the af:switcher component to show the edit form
         // e.g. change the value of the refrenced memory attribute or managed bean variable
       else{
        //what the heck did the user click on? Ask him ;-)
       }Frank

Maybe you are looking for

  • ALV tree help required

    Hello All, I need a help on ALV tree My requirement is! i need to edit some fields in ALV tree. In order to do this. I have written the below code           gs_layout_node-fieldname = 'ZMENGE1'.           gs_layout_node-editable = 'X'.           APPE

  • ESS - Application Career & Job*** Data Overview

    Dear experts- I have a doubt with the service Data Overview , that show a form PDF, however not information of Telephone and  address of the employee. My question is: 1. What is the name of form used for this and where is configured? 2. I am checking

  • Dynamically change region sequence/column

    I have a page that has many regions on it (ie. dashboard). The regions are all set to customize so the user can hide/show any of them. I have them all set with Display Point Page Template Body (3) and in columns 1-3 (see below): Region 1 Region 2 Reg

  • WiFi is not enabling

    I have Dell Studio laptop. WiFi on my device is not enabling. It was working good but when I installed new anti-virus software it disabled my WiFi. I discussed with the representative of the anti-virus company and they said that they have released a

  • IPhoto pictures go black after import

    when I import to iphoto the pictures often go black or disappear from my event