Recursion with af:iterators

I need to iterate through a hierarchy-type model coming from a bean and build the page based on this hierarchy (the depth is not known before runtime).
I want each node to have a component that surrounds its children. Is it possible to build a page by iterating through a hierarchy and if so how can it be done?
eg. Node1(
Node2( Node 4)
Node 3 (Node 5, Node 6)
thanks in advance,
David

Hi,
there is no recursive iteration component ADF Faces or JSF, so that you would need to know the hierarchy level upfront unless you can use a tree component (which then however poses a limitation to the layout you can build). If you can use a tree component then you build a tree model for the component based on your bean, which then can go as deep as you want.
Another approach to take is to dynamically create UI components from a managed bean. So e.g. starting from a reference to a parent container - say RichPanelGroupLayout - you create new UI components and add them as child component of a predecessor component
Frank

Similar Messages

  • Recursive WITH (Recursive Subquery Factoring) Never Returns

    11.2.0.2 database on Windows, SQL Developer Version 3.2.20.09, build MAIN-09.87 (Database and SQL Developer are on the same machine. I have also tried connecting to a Linux 11.2 database and have the same results.)
    I've been doing some simple testing with recursive WITH (Recursive Subquery Factoring) and when I run this following statement in SQL*Plus it returns instantly. However when running in SQL Developer it never returns, I've let it run for quite a long time (172 seconds) and gotten nothing, I finally kill the statement. Once I ran it and even killing the job didn't come back. I can get an explain plan but if I try to run it, run as script or autotrace it never returns. I have only one plan in the plan_table for this test, and it's only 4 lines long. No errors, no messages.
    WITH get_plan (query_plan, id, planlevel) as
    select ' '||operation||' '||options||' '||object_name query_plan, id, 1 planlevel
    from plan_table
    where id = 0
    union all
    select lpad(' ',2*planlevel)||p.operation||' '||p.options||' '||p.object_name query_plan, p.id, planlevel+1
    from get_plan g, plan_table p
    where g.id = p.parent_id
    SELECT QUERY_PLAN FROM GET_PLAN ORDER BY PLANLEVEL;

    Hi Jeff, using either give the same results. The query is "running", as is the little graphic with the bouncing gray bar is moving back and forth saying either "Query Results" or "Scriptrunner Task" as appropriate.
    OK this is odd. I run a count(*) on plan_table in SQL*Plus and get 4, in SQL Developer I get 487. Hun? That makes no sense I'm connect as the same user in each. Where are all these other entries coming from and why can't I see them in SQL Plus? Does SQL Developer have it's own PLAN_TABLE?
    **EDIT --- Yes that seems to be the case. The PLAN_ID I see in SQL Plus doesn't even exist in the SQL Deveropler version of the table. OK that's good to know. I assume the plan_table for SQL Developer is local to it somehow? It's not in the database as best I can see.
    Edited by: Ric Van Dyke on Feb 7, 2013 5:19 PM

  • To use "analytic function" at "recursive with clause"

    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10002.htm#i2077142
    The recursive member cannot contain any of the following elements:
    ・An aggregate function. However, analytic functions are permitted in the select list.
    OK I will use analytic function at The recursive member :-)
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    SQL> with rec(Val,TotalRecCnt) as(
      2  select 1,1 from dual
      3  union all
      4  select Val+1,count(*) over()
      5    from rec
      6   where Val+1 <= 5)
      7  select * from rec;
    select * from rec
    ERROR at line 7:
    ORA-32486: unsupported operation in recursive branch of recursive WITH clauseWhy ORA-32486 happen ?:|

    Hi Aketi,
    It works in 11.2.0.2, so it is probably a bug:
    select * from v$version
    BANNER                                                                          
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production    
    PL/SQL Release 11.2.0.2.0 - Production                                          
    CORE     11.2.0.2.0     Production                                                        
    TNS for IBM/AIX RISC System/6000: Version 11.2.0.2.0 - Production               
    NLSRTL Version 11.2.0.2.0 - Production                                          
    with rec(Val,TotalRecCnt) as(
    select 1,1 from dual
    union all
    select Val+1,count(*) over()
    from rec
    where Val+1 <= 5)
    select * from rec
    VAL                    TOTALRECCNT           
    1                      1                     
    2                      1                     
    3                      1                     
    4                      1                     
    5                      1                      Regards,
    Bob

  • Let us discussion "non recursive with clause" usage

    I think there are 3 "non recursive with clause" usage.
    My question is do you know more "non recursive with clause" usage ?

    Another option is to use it to materialize remote data on the fly. Especially in combination with the materialize hint.
    I think I used this tecnique once, but can't find the proper example anymore. Very simplified it could looked like this:
    with fetchData as (Select /*+materialize */ * from myremoteTable@databaselink where status = 'CURRENT')
    select *
    from fetchdata r
    full outer join localData l on r.id = r.id
    where l.status = 'CURRENT'
    ;From 11g onwards: use the with clause to create better column names in larger select from dual combinations.
    Not sure with that results in a suitable use case.
    So instead of
    with orders as
    (select 1 id , 173 order#, 'John' customer, 'America' region from dual union all
      select 2 id , 170 order#, 'Paul' customer, 'UK' region from dual union all
      select 3 id , 240 order#, 'Hans' customer, 'Europe' region from dual union all
      select 4 id , 241 order#, 'Francois' customer, 'Europe' region from dual )
    select * from orders;you can now write
    with
    orders (id, order#, customer,region) as
    (select 1 , 173 , 'John' , 'America' from dual union all
      select 2 , 170 , 'Paul' , 'UK' from dual union all
      select 3 , 240 , 'Hans' , 'Europe' from dual union all
      select 4 , 241 , 'Francois' , 'Europe' from dual )
    select * from orders;THis makes it a little easier to create tase data useing some excel sheet I guess.

  • Recursive with clause

    Hi All,
    I am using oracle 11.2.0.4
    I m using this for learning purpose
    Below is my table and insert statement
    CREATE TABLE NUMBERS(NUM NUMBER);
    INSERT INTO NUMBERS VALUES(1);
    INSERT INTO NUMBERS VALUES(2);
    INSERT INTO NUMBERS VALUES(3);
    INSERT INTO NUMBERS VALUES(4);
    WITH RSFC(ITERATION,RUNNING_FACTORIAL) AS
    (SELECT NUM AS ITERATION,
    1 AS RUNNING_FACTORIAL
    FROM NUMBERS
    WHERE NUM=1
    UNION ALL
    SELECT R.ITERATION+1,
            R.RUNNING_FACTORIAL * B.NUM
            FROM RSFC R INNER JOIN NUMBERS B
            ON (R.ITERATION+1) + B.NUM    
            SELECT ITERATION,RUNNING_FACTORIAL
            FROM RSFC
    I am learning recursive with clause
    when I am trying to execute the query I am getting
    ORA-00920 : invalid realtional operator
    what is wrong in this query,please help me
    Thanks and Regrds,
    Subho

    Hi,
    2937991 wrote:
    Hi All,
    I am using oracle 11.2.0.4
    I m using this for learning purpose
    Below is my table and insert statement
    CREATE TABLE NUMBERS(NUM NUMBER);
    INSERT INTO NUMBERS VALUES(1);
    INSERT INTO NUMBERS VALUES(2);
    INSERT INTO NUMBERS VALUES(3);
    INSERT INTO NUMBERS VALUES(4);
    WITH RSFC(ITERATION,RUNNING_FACTORIAL) AS
    (SELECT NUM AS ITERATION,
    1 AS RUNNING_FACTORIAL
    FROM NUMBERS
    WHERE NUM=1
    UNION ALL
    SELECT R.ITERATION+1,
            R.RUNNING_FACTORIAL * B.NUM
            FROM RSFC R INNER JOIN NUMBERS B
            ON (R.ITERATION+1) + B.NUM   
            SELECT ITERATION,RUNNING_FACTORIAL
            FROM RSFC
    I am learning recursive with clause
    when I am trying to execute the query I am getting
    ORA-00920 : invalid realtional operator
    what is wrong in this query,please help me
    Thanks and Regrds,
    Subho
    The error actually has nothing to do with the WITH clause.
    Join conditions (that is, the conditions following the ON keyword) must be expressions that evaluate to TRUE or FALSE.  The join condition you posted, however
    (R.ITERATION+1) + B.NUM   
    evaluates to a NUMBER.  The following would be a valid join condition:
    (R.ITERATION+1) = B.NUM  
    but I have no idea if that's what you wanted or not.

  • Since Oracle11gR2,"recursive with clause" is supported.

    http://download.oracle.com/docs/cd/E11882_01/server.112/e16579/aggreg.htm#i1007241
    <i>Note that Oracle Database does not support recursive use of the WITH clause</i>
    This is wrong.
    Since Oracle11gR2 recursive with clause is supported.
    Please fix this wrong statement of document.
    I like recursive with clause 8-)

    I'm the writer for this doc, and you are correct. This sentence was not removed when the 11.2 doc was updated, and it should have been. I have removed it for the 12g doc.

  • How to use recursion with images

    Ok, for this program I'm trying to recursively repeat an image 3 times with varying widths and heights, and I don't know how to do that with images. With rectangles and other shape objects it's easy because all I had to do was override the draw method, but with images I'm not sure what to override to allow me to repeat the drawing of it with a different height and width. Any help would be greatly appreciated.

    Would I be able to work that in with recursion? Currently I have a JPanel with the paintComponent method being overridden, and I've tried setting up the paintComponent method to call itself to repaint the image, but I've realized everytime I resize the application's window paintComponent gets called again making the images go out of site. Is there a way to override the drawImage method to allow me to change the width and height of the image without causing the panel to repaint itself?

  • Recursion with Return instruction without parameter

    Please I have a doubt about following code:
    public void solveTowers( int disks, int sourcePeg, int destinationPeg,
    int tempPeg )
    if ( disks == 1 )
    System.out.printf( "\n%d --> %d", sourcePeg, destinationPeg );
    return;
    solveTowers( disks - 1, sourcePeg, tempPeg, destinationPeg );
    System.out.printf( "\n%d --> %d", sourcePeg, destinationPeg );
    If I enter witch amount variable DISK = 3
    I'd like to known: Why ouput after perform the code is
    1--->3
    2--->3
    1--->3 ?
    I didn't get it about the mechanism logical of RETURN instruction !!!
    Please, some could me help and explain about with mechanism
    OBS: An draw or design it will be helpfull for me understant
    A lot of thanks
    Gmourad

    You didn't mention other parameters of your recursive method, so I am not guessing but here is an easier example.
    public class Test{
         public void resursive(int num) {
              if (num == 1) {
                   System.out.println(num);
                   return;
              resursive(--num);
              System.out.println(num);
        public static void main(String[] args) {
              int num = 3;
              Test myTest = new Test();
              a.resursive(num);
    1
    1
    2
    recursive(3) -> recursive(2)                                          // print 2
                    recursive(2) -> recursive(1)              // print 1
                                    recursive(1) -> // print 1It would print the last one first because the upper one would call itself first before print out the value.

  • Importing a package recursively (with subpackages)

    Hello everyone,
    I'm a 1st-year CS major and am new to Java. I had a question about importing packages. As I understand it, when you use a wildcard when importing, it will import the classes within the package specified before the asterisk, but none of the subpackages in the specified package.
    Sort of like in Linux when you have to pass the -R (recursive) argument to list files contained deeper within the directory hierarchy.
    My question is, is there a way to include all classes and subpackages with a single line, instead of doing:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    I understand that it doesn't actually cause any bloat in your bytecode, so if it can be done, would there be any disadvantage?
    Thanks!

    jverd wrote:
    E_Rutherford_Jollyworth wrote:
    Hello everyone,
    I'm a 1st-year CS major and am new to Java. I had a question about importing packages. As I understand it, when you use a wildcard when importing, it will import the classes within the package specified before the asterisk, but none of the subpackages in the specified package. Correct. There aren't really "subpakcages." The JLS actually uses that term, but I don't know why. There's no real hierarchy, other than the one on the filesystem and the logical one implied by the names. As far as Java is concerned, the packages have no relation to each other.
    YET.
    There are plans (I think approved by the JCP) to enable importing of class hierarchies in JDK 7. Not my favourite idea, but others seem to think differently.
    I understand that it doesn't actually cause any bloat in your bytecode, so if it can be done, would there be any disadvantage?If it could be done, the disadvantage would be the same as that of using the *** wildcard to import all the classes at a single level. Namely, it's not clear which class comes from which package.Worse than that. If you have identically named classes in deeper packages which one is going to be used? You just can't tell, which hopefully will generate a compiler error.
    For example you import com.acme.dummy recursively, which has com.acme.dummy.one.SomeClass and com.acme.dummy.two.SomeClass.
    Now use SomeClass in your code without specifying the package name with it and you're in trouble.

  • Recursion with array

    hi
    i got this question , int values[] int index int amount i need to check if there is sum of elementv in values that equal to amount
    example
    values[]={5,22,13,5,7,-4}
    amount=31
    22+13+(-4)=31
    return true
    the signature fo function call in recursion is:
    cover (int[] values,int i,int amount)

    henvertis, you hijack someone else's thread to post your "question". I suggest you to create a thread of your own and tell you that it might be a good idea to post the code you're working on because just posting a description of the problem might result into other forum members assuming you just want someone to do it for you (some call this cheating).
    You then create a new thread, but (again) just with the problem description. I respond to that thread but you never got back to me, and now you're back again with another new thread and again just the problem description!
    What's wrong with you?

  • Recursion with binary numbers

    I need to print out a list of all possiblle binary numbers with as many digits as an int k. For example, if k = 3, it would need to print out 000,001,010,011,100,101,110,111. for k = 2 it is only 00, 01, 10, 11. It is pretty clear that for any k, a recursive technique can be used to solve this problem, but I'm having trouble finding the solution. Please help. Thanks

    You don't need recursion:for (int i = 0, max = 1 << (k - 1); i < max; ++i) {
      print binary i to k digits
    }But a recursive approach would be void increment (int[] data, int digit) {
    if (digit > 0) {
    --digit;
    for (int i = 0; i < 2; ++i) {
      data[digit] = i;
      increment(data, digit);
    } else {
    print contents of data array
    start (int k) { increment(new int[k], k); }Neither code tested.
    Pete

  • Recursion with reentrant vi's

    Hi all,
    I have some problems with creating recursively function:
    For example, I have 5 VI's that call each other in chain VI1->VI2->VI3->VI4->VI5->VI1->VI2...
    At First , I made each VI as VIT and called them dynamically, it worked fine. But, calling VIT dynamically is very slow, so I've changed each VI to a reentrant and called them as is (not dynamically), and the recursion didn't worked.  Only if some VI's is VIT and some are reentrant, the recursion works.
    I thought that calling VIT and reentrant VI works the same, can someone explain what is the difference between calling a reentrant and calling a VIT dynamically?
    Nadav Chernin

    Hi tbd,
    yes I'm still around
    I'm using 8.2, but I missed one thing in my screenshot that the VI options should be 0x8 (listed as action 7)
    Another thing you can try is not using the VI name but the VI path to open it?
    Ton
    EDIT:
    quicly build an example that runs on my LV OK:
    Message Edited by TonP on 01-20-2007 02:15 PM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    recursive.png ‏7 KB
    recursive.vi ‏12 KB
    recursive.png ‏7 KB
    recursive.vi ‏12 KB
    recursive.png ‏7 KB
    recursive.vi ‏12 KB

  • Recursion with arrays

    Hi,
    I am having trouble with creating a recursive method to sum all
    elements in an array. I am new to recursion and am getting
    confused.
    Here is a method I am working with:
    I am trying to sum all the sides of a triangle whose sides
    are stored in the array sides [ ], but can't seem to add
    more than the sides[2] and sides[1] elements.
    Any ideas? One of the requirements is that 0<= index < size or array.
    Thanks,
    int perimeter() {
    return perim(0);
    int perim(int index) {
    if (index == sides.length-1)
    return sides[index];
    else{
    int sidesTotal = perim(index+1);
    return sidesTotal + sides[index-1];
    }

    > I am having trouble with creating a recursive method
    to sum all elements in an array. 
    class ReallyBadUseOfRecursionDemo {
        public static int recursiveSum(int[] array) {
            if (array == null || array.length == 0) return 0;
            if (array.length == 1) return array[0];
            return array[0] + recursiveSum(java.util.Arrays.copyOfRange(array, 1, array.length));
        public static void main(String[] args) {
            assert 0 == recursiveSum(null);
            assert 0 == recursiveSum(new int[0]);
            assert 42 == recursiveSum(new int[] { 42 });
            assert 6 == recursiveSum(new int[] { 1, 2, 3 });
    }~

  • Recursion with strings

    Hallo,
    I have to write a method that get's two String type strings (s1, s2) and returns the length of the the biggest continuous sub matrix in the matrix s2 that's all it's digits are present in matrix s1.
    For example: if s1 is "xyz" and s2 is "abxyryxzycx" the method will return 4 because the length of sub matrix "yxzy" is 4 and it's the largest sub matrix of s2 that contains only digits from s1(the sub matrices are: "xy", "yxzy", "x").
    I have to write this method with recursion and I'm not allowed to use any strings.
    When I'm using the defined methods of the String class I can use only the following one's:
    public char charAt (int i)
    public int indexOf (int ch)
    public int length()
    public String substring (int i)
    I can's see right now how I use "if" conditions with the String methods I'm allowed to use and I can't see the process of solving the problem(should I use linear search?).
    Thank's to everybody that can help.
    Edited by: ArikG on Jan 26, 2009 10:38 AM

    I suppose I have to use linear search, but I can't use it here because I'm not allowed to use loops.
    My idea is that if the linear search in s2 a digit from s1 is found so I use the method: public char charAt(int i) and from this point I don't know what to do, and I don't know if it's possible to use linear search in recursion(I know how to do it with loops) and how to write everything here(I am familiar only with the String length methods because we weren't taught in the course about the other Sting methods)

  • Help me with Java iterators, please.

    I'm supposed to convert an algorithm that's working on a simple array to work on a linked list, but I have to keep it with the same complexity. I've tried using iterators to replicate the nested fors, but I'm running into an issue. For instance:
    ListIterator it = listname.listIterator();
    Listiterator it2 = it;
    System.out.println(it.next());
    System.out.println(it2.next());
    System.out.println(it.next());
    System.out.println(it2.next());With a list of [5, 4, 3, 2, 1], I'd get 5, 4, 3 and 2 instead of 5, 5, 4 and 4. The problem is that the iterators aren't moving idenpendently. I guess a shallow copy was created instead of a deep copy. This is pretty dumb from where I'm standing, because it's pointless to copy the iterator if they aren't going to be independant.
    Anyway, is there a way to make it so that I can copy a iterator while keeping him independant from its source? I can't create another iterator from scratch and traverse the list.
    I've also tried doing a new class implementing ListIterator and Cloneable, but this:
    IteratorClass it3 = listname.IteratorClassgave me an error. I did the class so it was abstract and I wouldn't have to implement methods that I wouldn't be using, so I'm not sure if that was the problem. I'm new to Java, so I'm pretty confused to be honest. I know cloneable is supposed to allow me to create a deep copy, but since I'm calling the ListIterator from the LinkedList, I'd have to implement my own kind of iterator with Cloneable and ListIterator and then create a subclass of LinkedList?
    Anyway, thanks in advance.

    BananaPow3 wrote:
    I'm supposed to convert an algorithm that's working on a simple array to work on a linked list, but I have to keep it with the same complexity. I've tried using iterators to replicate the nested fors, but I'm running into an issue. For instance:
    ListIterator it = listname.listIterator();
    Listiterator it2 = it;
    System.out.println(it.next());
    System.out.println(it2.next());
    System.out.println(it.next());
    System.out.println(it2.next());
    What's the point of it2? The above code is identical to
    ListIterator it = listname.listIterator();
    System.out.println(it.next());
    System.out.println(it.next());
    System.out.println(it.next());
    System.out.println(it.next());
    With a list of [5, 4, 3, 2, 1], I'd get 5, 4, 3 and 2 instead of 5, 5, 4 and 4. Because you're calling next on the same iterator each time. The = opeator never copies objects in Java, only references.
    Iterator it2 = it;All that line does is copy the value from variable it into variable it2. That value is a refrence. Both variables now refer to the same Iterator object.
    The problem is that the iterators aren't moving idenpendently. I guess a shallow copy was created instead of a deep copy. This is pretty dumb from where I'm standing, because it's pointless to copy the iterator if they aren't going to be independant.You didn't copy an Iterator. You copied a reference.
    If you want a second ListIterator over that list, then do ListIterator it2 = listname.listIterator();(By the way, why are you using ListIterators instead of just Iterators? Will you be going backward as well?
    Anyway, is there a way to make it so that I can copy a iterator while keeping him independant from its source? Nope.
    I can't create another iterator from scratch and traverse the list.Why not?
    Edited by: jverd on Aug 9, 2008 2:50 PM

Maybe you are looking for