JSF How to iterate over the list of a panelForm's child elements.

Hi all
My users have asked me to create a "clear all" button that initializes all input values of a search form's fields to null.
To do this I created a managed bean and added the following code
public String ClearFieldsBtn_action()
String[] fieldIDs = {
"Material",
"Description",
"Length",
"Width",
"Thickness",
for (int i = 0; i < fieldIDs.length; i++ )
try {       
AttributeBinding attr = (AttributeBinding)getBindings().getControlBinding(fieldIDs);
attr.setInputValue( null);
} catch (Exception e) {
System.out.println(e.toString());
return null;
I wonder if there any other more elegant way to iterate over the fields contained inside the JSF panelForm that contains all these "Material", "Description", etc fields and thus be able to easily transport the same functionality in more that one page?
Thanks in advance
Thanassis

Thanassis,
I use some code like this (where "target" is a variable in the managed bean representing the parent component - the panelForm in your case):
    List children;
    int  i, cnt;
    children = target.getChildren();
    cnt = target.getChildCount();
    for (i=0; i< cnt; i++)
      // do whatever you need here, such as clearing fields
    }This doesn't operate on the model, just on the UI components themselves. I do use something like this in a superclass backing bean for when I need to iterate over a bunch of UI components.
John

Similar Messages

  • How to iterate over the attributes of a single entity?

    I am working on a logical model transformation script. I take a list of all entities:
         var entities = model.getEntitySet().toArray();
    iterate over the entities:
         for (var e = 0; e < entities.length; e++) {
            var entity = entities[e];
    and try to get a list of all attributes for the current entity:
            var attributes = entity.getAttributeSet().toArray();
    After that I try to iterate over the attributes:
            for (var a = 0; a < attributes.length; a++) {
                var attribute = attributes[a];
    While iterating over the attributes I realized that the list is always the same. I get always a list of all attributes probably of the whole model even for entities without any attribute.
    How can I get a list of the attributes for one single entity?

    Hi,
    Use entity.getAttributes()

  • How can I iterate over the columns of a REF CURSOR?

    I have the following situation:
    DECLARE
       text   VARCHAR2 (100) := '';
       TYPE gen_cursor is ref cursor;
       c_gen gen_cursor;
       CURSOR c_tmp
       IS
            SELECT   *
              FROM   CROSS_TBL
          ORDER BY   sn;
    BEGIN
       FOR tmp IN c_tmp
       LOOP
          text := 'select * from ' || tmp.table_name || ' where seqnum = ' || tmp.sn;
          OPEN c_gen FOR text;
          -- here I want to iterate over the columns of c_gen
          -- c_gen will have different number of columns every time,
          --        because we select from a different table
          -- I have more than 500 tables, so I cannot define strong REF CURSOR types!
          -- I need something like
          l := c_gen.columns.length;
          for c in c_gen.columns[1]..c_gen.columns[l]
          LOOP
              -- do something with the column value
          END LOOP;
       END LOOP;
    END;As you can see from the comments in the code, I couln'd find any examples on the internet with weak REF CURSORS and selecting from many tables.
    What I found was:
    CREATE PACKAGE admin_data AS
       TYPE gencurtyp IS REF CURSOR;
       PROCEDURE open_cv (generic_cv IN OUT gencurtyp, choice INT);
    END admin_data;
    CREATE PACKAGE BODY admin_data AS
       PROCEDURE open_cv (generic_cv IN OUT gencurtyp, choice INT) IS
       BEGIN
          IF choice = 1 THEN
             OPEN generic_cv FOR SELECT * FROM employees;
          ELSIF choice = 2 THEN
             OPEN generic_cv FOR SELECT * FROM departments;
          ELSIF choice = 3 THEN
             OPEN generic_cv FOR SELECT * FROM jobs;
          END IF;
       END;
    END admin_data;
    /But they have only 3 tables here and I have like 500. What can I do here?
    Thanks in advance for any help!

    The issue here is that you don't know your columns at design time (which is generally considered bad design practice anyway).
    In 10g or before, you would have to use the DBMS_SQL package to be able to iterate over each of the columns that are parsed from the query... e.g.
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2) IS
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_rowcount  NUMBER := 0;
    BEGIN
      -- create a cursor
      c := DBMS_SQL.OPEN_CURSOR;
      -- parse the SQL statement into the cursor
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      -- execute the cursor
      d := DBMS_SQL.EXECUTE(c);
      -- Describe the columns returned by the SQL statement
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      -- Bind local return variables to the various columns based on their types
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Varchar2
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);      -- Number
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);     -- Date
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);  -- Any other type return as varchar2
        END CASE;
      END LOOP;
      -- Display what columns are being returned...
      DBMS_OUTPUT.PUT_LINE('-- Columns --');
      FOR j in 1..col_cnt
      LOOP
        DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' - '||case rec_tab(j).col_type when 1 then 'VARCHAR2'
                                                                                  when 2 then 'NUMBER'
                                                                                  when 12 then 'DATE'
                                                         else 'Other' end);
      END LOOP;
      DBMS_OUTPUT.PUT_LINE('-------------');
      -- This part outputs the DATA
      LOOP
        -- Fetch a row of data through the cursor
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        -- Exit when no more rows
        EXIT WHEN v_ret = 0;
        v_rowcount := v_rowcount + 1;
        DBMS_OUTPUT.PUT_LINE('Row: '||v_rowcount);
        DBMS_OUTPUT.PUT_LINE('--------------');
        -- Fetch the value of each column from the row
        FOR j in 1..col_cnt
        LOOP
          -- Fetch each column into the correct data type based on the description of the column
          CASE rec_tab(j).col_type
            WHEN 1  THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
            WHEN 2  THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_n_val);
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'));
          ELSE
            DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
            DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
          END CASE;
        END LOOP;
        DBMS_OUTPUT.PUT_LINE('--------------');
      END LOOP;
      -- Close the cursor now we have finished with it
      DBMS_SQL.CLOSE_CURSOR(c);
    END;
    SQL> exec run_query('select empno, ename, deptno, sal from emp where deptno = 10');
    -- Columns --
    EMPNO - NUMBER
    ENAME - VARCHAR2
    DEPTNO - NUMBER
    SAL - NUMBER
    Row: 1
    EMPNO : 7782
    ENAME : CLARK
    DEPTNO : 10
    SAL : 2450
    Row: 2
    EMPNO : 7839
    ENAME : KING
    DEPTNO : 10
    SAL : 5000
    Row: 3
    EMPNO : 7934
    ENAME : MILLER
    DEPTNO : 10
    SAL : 1300
    PL/SQL procedure successfully completed.
    SQL> exec run_query('select * from emp where deptno = 10');
    -- Columns --
    EMPNO - NUMBER
    ENAME - VARCHAR2
    JOB - VARCHAR2
    MGR - NUMBER
    HIREDATE - DATE
    SAL - NUMBER
    COMM - NUMBER
    DEPTNO - NUMBER
    Row: 1
    EMPNO : 7782
    ENAME : CLARK
    JOB : MANAGER
    MGR : 7839
    HIREDATE : 09/06/1981 00:00:00
    SAL : 2450
    COMM :
    DEPTNO : 10
    Row: 2
    EMPNO : 7839
    ENAME : KING
    JOB : PRESIDENT
    MGR :
    HIREDATE : 17/11/1981 00:00:00
    SAL : 5000
    COMM :
    DEPTNO : 10
    Row: 3
    EMPNO : 7934
    ENAME : MILLER
    JOB : CLERK
    MGR : 7782
    HIREDATE : 23/01/1982 00:00:00
    SAL : 1300
    COMM :
    DEPTNO : 10
    PL/SQL procedure successfully completed.
    SQL> exec run_query('select * from dept where deptno = 10');
    -- Columns --
    DEPTNO - NUMBER
    DNAME - VARCHAR2
    LOC - VARCHAR2
    Row: 1
    DEPTNO : 10
    DNAME : ACCOUNTING
    LOC : NEW YORK
    PL/SQL procedure successfully completed.
    SQL>From 11g onwards, you can create your query as a REF_CURSOR, but then you would still have to use the DBMS_SQL package with it's new functions to turn the refcursor into a dbms_sql cursor so that you can then describe the columns in the same way.
    http://technology.amis.nl/blog/2332/oracle-11g-describing-a-refcursor
    Welcome to the issues that are common when you start to attempt to create dynamic code. If your design isn't specific then your code can't be either and you end up creating more work in the coding whilst reducing the work in the design. ;)

  • Session Problems: "Don't know how to iterate over supplied "items""

    Hi, I am developing my first application using Struts and JSP. The Action Form loads an object called reportGrid into session and I am trying to display it on a JSP page. Displaying simple variables works fine, but I can display an object. The error I receive is: Don't know how to iterate over supplied "items"
    My object is made up of a group of ArrayLists looks similar to this this:
            private List affiliateID;
         private List affiliateName;
         private List product1;
         private List product2;
         //etc for about 10 listsThe object is filled with data from a result set and placed into session like:
         HttpSession session = request.getSession();
         session.setAttribute("grid", reportGrid);The goal is to display each list in its own column in a HTML table.
    <table>
    <tr>
    <c:forEach var="affiliateName" items="${grid}">
              <td>
                   <c:out value="${affiliateName}" />
              </td>     
         </c:forEach>
         <c:forEach var="product1" items="${grid}">
              <td>
                   <c:out value="${product1}" />
              </td>     
         </c:forEach>
         <c:forEach var="product2" items="${grid}">
              <td>
                   <c:out value="${product2}" />
              </td>     
         </c:forEach>
    </tr>
    </table>I'm sure this has been asked before but I could not find any examples in the forums. I can place an ArrayList directly into session and iterate through using <c:forEach tags but when I try to do the same with an object it gives me the error " Don't know how to iterate over supplied "items" ".
    Does anyone have any examples of pulling and displaying an object in session which contains ArrayLists? I have been stuck on this same error for a while and any help will be greatly apreciated.
    James.          

    What is the type of grid?

  • How can i get the list of all users present in the LDAP

    Hi Experts,
    How can i get the list of all users present in the LDAP ?
    Is there any API or function Code to get all user list??
    Please help me out!!!
    Help will be rewarded

    Well it will depend on exactly where your UME configuration points to in the LDAP tree but yes, it is possible to get all users.  Something like the following should do it:
    import com.sap.security.api.*;
    import com.sapportals.portal.prt.component.*;
    IUserFactory iuf;
    ISearchResult isr;
    IUser user
    String userid;
    iuf = UMFactory.getUserFactory();
    isr = iuf.getUniqueIDs();
    you will need to iterate the ISearchResult object but you can get IUser objects by
    userid = (String)isr.next();
    user = iuf.getUser(userid);
    then you can imanipulate / identify / or whatever you need with the user object
    Haydn

  • Don't know how to iterate over supplied "items" in forEach&gt

    I try the following
    I have form , bean , servlet and JSTL
    in bean I have constructor like
    public MyForm(String a_item) {
    this.a_item = a_item;
    in servlet
    MYForm uf = new MyForm(a_item);
    userSession.setAttribute("underform", uf);
    in jstl
    I have
    <c:forEach items="${sessionScope.underform}" var="found">
    <table cellspacing="0" cellpadding="0" width="100%" border="0">
    <tr><td align="left" valign="top">
    <c:if test="${found.a_item=='on' }">
    <li> <input type="checkbox" name="a_item" checked></li>
    </c:if>
    </td>
    </tr>
    </table>
    I GET THE ERR Don't know how to iterate over supplied "items" in &lt;forEach&gt;
    HOW CAN I Persisting data by the request by as an object ??
    thank you!

    so you suggest the method oneConsidering that I said exactly the opposite, it is a mystery to me how you could possibly have drawn that conclusion. I don't intend to keep repeating myself or to keep clarifying statements that are already perfectly clear. If you don't understand something, please say so. But don't put words into my mouth thanks.
    that means all logical will be handle on bean and not servlet is needed?Once again I have no idea what you mean by this question.
    what is the role for the servlet in MVC?And I have no idea what you mean by this question either, or how it relates to this thread. A JSP is a servlet in case you didn't know.

  • How to find out the list of DCs changed in the MSS 600 Support PackageXX

    Hi
    We are trying to instal patches from "MSS 600 support package 07" to "MSS 600 support package 17"  at the same time we have 4 custom DCs in place.
    Our custom DCs have dependencies in MSS standard DCs.
    Question is how do we know the list ot DC changed/modified in suport package XX ?
    Is there a description of DCs changed in the support package? Or is there a description on SC level so we could trace it
    GRANT POINTS!!!
    Thanks
    Denis

    Papaden- Please use metadata comparision tool to find the changes in webdynpro DCs.
    http://help.sap.com/saphelp_nw70/helpdata/en/6e/0e184188b4f16fe10000000a1550b0/frameset.htm
    Thanks,
    Raj

  • How do i backup the list of load images automatically exceptions under Options- Content. I want to transfer to another comp without re-adding one at a time

    How do i backup the list of load images automatically exceptions under Options->Content. I want to transfer to another comp without re-adding one at a time. EVen if there is no way to backup, what is the system file for Firefox that stores these, so i can transfer this file or open it in an XML or similar editor to copy them out?

    The permissions.sqlite file stores 'allow' and 'block' exceptions for cookies, images, pop-up windows, and extensions (software) installation.
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    You can use this button to go to the Firefox profile folder:
    *Help > Troubleshooting Information > Profile Directory: Show Folder
    See also:
    *https://support.mozilla.org/kb/Recovering+important+data+from+an+old+profile
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox

  • If I wish to print Contacts as a list how do I get the list to be alphabetized.  All my contacts print but they are not in alpha order.

    Sign out

    If I wish to print Contacts as a list how do I get the list to be alphabetized.  All my contacts print but they are not in alpha order.-cannot find an answer other than use iCloud which did not work.Tried Safari and Firefox.
    What to try?

  • How can i get the list of all users present in the UME ?

    Hi Experts,
    How can i get the list of all users present in the UME ?
    Is there any API or function Code to get all user list??
    Please help me out!!!
    Help will be rewarded
    -pankaj chouhan

    Hi Pankaj,
    find the official NetWeaver security javadocs (including access to UME) <a href="http://help.sap.com/javadocs/NW04S/current/se/index.html">here</a>. Look for classs UMFactory and proceed from there.
    Best regards,
    Martin

  • How can we display the list of Report Names in Dashboard Prompt?

    How can we display the list of Report Names in Dashboard Prompt?

    Hi,
    No its not possible to display list of reports in dashboard prompts.
    Can do this using SQl results in prompt(we write query checking out report names manualy),but its not easy thing if you are having many report names to be displayed.
    Assign points and close your threads if answered.
    Refer : http://forums.oracle.com/forums/ann.jspa?annID=939
    Regards,
    Srikanth

  • How can I control the list of cipher suites offered in the SSL Client Hello message? I want to forbid MD5 and RC4.

    How can I control the list of cipher suites offered in the SSL Client Hello message?
    I want to limit my browser to negotiating strong cipher suites. I'd like to forbid DES, MD5 and RC4.

    Set the related SSL3 prefs to false on the about:config page (Filter: security.ssl3.).
    *http://kb.mozillazine.org/about:config

  • How can i get the list of DB02's Table spaces-overview?

    Dear Experts,
           Could you help me about how can i get the list of DB02's Table spaces-overview? which function module can do it?
    Thanks a lot

    Hi,
    Execute this FM DB02_ORA_FILL_TD110
    U will get all the details of table spaces in the importing parameter TD110 of that FM.
    Reward if helpful
    Regards
    Vodka.

  • How can i get the list of all tcode used by user of particular module

    Hi,
    How can i get the list of all tcode used by user of particular module (e.g FI , MM ,PP) within year .
    Regards
    Vikram

    Login to your SAP System
    Run TCode SE16
    Type Table Name : TSTCT
    Press F7 Key (Table Contents )
    Go to Settings in menu bar
    Select User Parameters
    Under Keyword select Field Label and press green check mark
    Select your criteria in Data Browser and execute
    You will see all t codes in there
    Regards,
    Yogesh

  • By API action, how can I get the list of user IDs within a specific group  (which is created by API) ?

    By API action, how can I get the list of user IDs within a
    specific group (which is created by API) ?
    or How can I get the group (which is I create by API) ID to
    which a specific user belong by API action?
    Thanks
    Alex

    The poster already posted at the Acrobat Users Community, Interactive Forms that sums up a client order from catalog. The sample form posted to Acrobat.com was a revision of the sample form that came with Acrobat 4.0. There are some fairly advance scripts, templates, and document level functions involved with this form.

Maybe you are looking for