An extra column of a query in an ADF Faces Table?

Hi to all OTN Community...
I use ADF Faces, Toplink and EJB 3.0 in JDevelooper 10.1.3.1.0, and i have a question...
I need to show in an adf faces table, the result of a query like this
SELECT COLUMN1, COLUMN2, COUNT(*)
FROM TABLEX
GROUP BY COLUMN1, COLUMN2
I do this query in the TableX named queryes...and then i have acces to this named query in the dataControl, but, when i drag and drop the dataControl to a jsf page, this only shows the columns of the tableX. Then, i want to know, ¿How can i show the count(*) column in the page in a dataControl?
PD: i want to show in the adf faces table the same result if i execute that query in an sql client.
Thanx in advance...
Darklorddany

Darklorddany,
The solution to this is to add an additional method on your EJB 3.0 session-bean that exposes an dynamic TopLink report (projection) query.
The TopLink code within the method would leverage your existing TopLink mappings to do the query like:
        ReportQuery rq = new ReportQuery(Employee.class, new ExpressionBuilder());
        rq.addAttribute("firstName");
        rq.addAttribute("lastName");
        rq.addCount();
        rq.addGrouping("firstName");
        rq.addGrouping("lastName");
        List<ReportQueryResult> results = (List<ReportQueryResult>)session.executeQuery(rq);The ReportQueryResult objects are very generic map/row type containers that will not work well in your ADF binding layer. With JPA you can specify and ad-hoc Java class to contain such projection results that make them a little easier to use in clients. This functionality will be available in the next release of TopLink. Until then you will need to write some code to convert to your own result class for this query.
In my case I'll create a simple POJO like:
    public class EmployeeNameCount {
        private String firstName;
        private String lastName;
        private int count;
        public EmployeeNameCount(String firstName, String lastName, int count) {
            this.firstName = firstName;
            this.lastName = lastName;
            this.count = count;
        public String getFirstName() {
            return this.firstName;
        public String getLastName() {
            return this.lastName;
        public int getCount() {
            return this.count;
    }Now I combine the previous report query code into an EJB 3.0 session bean method:
    @TransactionAttribute(TransactionAttributeType.SUPPORTS)
    public List<EmployeeNameCount> findEmployeeNamesWithCount() {
        Session session = getSessionFactory().acquireSession();
        ReportQuery rq = new ReportQuery(Employee.class, new ExpressionBuilder());
        rq.addAttribute("firstName");
        rq.addAttribute("lastName");
        rq.addCount();
        rq.addGrouping("firstName");
        rq.addGrouping("lastName");
        List<ReportQueryResult> results = (List<ReportQueryResult>)session.executeQuery(rq);
        session.release();
        List<EmployeeNameCount> empNameCounts = new ArrayList<EmployeeNameCount>(results.size());
        for (ReportQueryResult rqr: results) {
            String fname = (String)rqr.getByIndex(0);
            String lname = (String)rqr.getByIndex(1);
            int count = ((Number) rqr.getByIndex(2)).intValue();
            empNameCounts.add(new EmployeeNameCount(fname, lname, count));   
        return empNameCounts;
    }You will also need to make sure the method exists on your EJB 3.0 session bean's interface as well. Then regenerate the data control for your session bean and you should have access to drag and drop this query with its results into your JSF pages.
As mentioned this use case will be much simpler and declarative in the next release.
Doug

Similar Messages

  • Dynamically reordering columns in ADF Faces Table

    The Rich UI components (see ADF Faces Rich Client Components - Marrying JSF and AJAX together) that the ADF Faces library will contain with the JDeveloper 11g release - and hopefully before that moment - will allow end-users to do all sorts of manipulations with Tables. They will be able to resize columns an drag & drop columns to change the order - much like you can do in Spreadsheet applications like Excel. However, those components are not yet available to us. Yesterday my customer asked me if he could have offer the option to re-order columns in a table to his end users. That means that in any table component, the user can decide which column should be displayed first, which one second and which one last. It happened to be the same customer who was after the feature to show/hide columns at run-time, a challenge easily resolved in a previous article: Having the end-user hide and display columns in a JSF Table Component (http://technology.amis.nl/blog/?p=1331).
    I have written an article that shows how we can implement this feature: have the end-user specify the order of the columns in the table. I have used ADF Faces for this demonstration, but any JSF implementation will do. See: http://technology.amis.nl/blog/?p=1334 for the article.
    best regards,
    Lucas

    Well issue is that
    I have a list of values that can be chnaged any time during application execution sya its list of Fav Fruits..
    and in an other page i need a data table having these fruits as coulmns and their details as rows...
    how to achieve this..
    we can not guess the number of columns before time.. so can make the estimate and hide them.

  • Extra column in BW query data?

    I'm getting an extra blank column in my BW query data that does not show in data preview mode.  I'm expecting data, based on the preview to look like this:
    CCtr   Yr    Amt   Qty
    375   2010   10     10
    But getting instead:
    CCtr   Yr    Blank    Amt   Qty
    375   2010              10      10
    I'm sure there is probably a workaround for this, but it seems like a bug.  Anyone else experiencing this with the "direct" connection to BW query?
    I'm on Xcelsius 5.3.4.0, Build 12,3,4,1038.  BW 7.01 SP6.
    Thanks,
    Brian Aldrich

    Thanks all-
    Turns out that this was an issue caused by a scaling factor in one of the columns in the BW query.  I had the amount scaled to thousands and the query relusts were putting a "*1000" every so many rows in the data...in the column that was (mostly) blank.  It placed that text every 6 or so rows.  This did not show in the query in BW or the data preview feature in Xcelsius.  Since my initial data retrieval was 5 rows, I didn't see this, but when I brought in a larger number of rows, it showed up.
    I turned the scaling factor off in the query to resolve the issue.
    Cheers,
    Brian
    P.S.  Someone in another thread suggested adding a spreadsheet table to the canvas to help with data preview...this was a huge help in finding the issue.  Highly recommended!

  • Using SAP Tokens & showing extra columns to choose

    I have a Crystal Report where I have a SAP token parameter to select a budget scenario to run the report based on.
    My token is selecting the 3 columns I need to display inorder to select the correct scenario - AbsID, Name & FinancYear.
    Budget@Select AbsID, Name,FinancYear  from OBGS order by 3
    When I preview in SAP my drop down box only gives me AbsID and name - which is of course a list diplaying "Main Budget" repeated for the number of financial year I have in the database.
    As these Main Budgets can (and have) been created in any order, it is impossible toexpect the users to select the correct budget from the displayed data.
    As there is no direct join from OBGS to OFPR on financial year, I can't work out how to either display the additional column in the choose from list, or filter my selection statement so it will only give scenarios that relate to the financial year for the period I have selected
    Any sensible suggestions welomed!

    Hi Julie,
    Remember that combo box controls in SAP can only display two values, a code and description, or in the case of report tokens the first two columns you specify in the token query. Seeing as you need the third column to distinguish between the first two sets of values a combo box is no use to you on it's own.
    The following is off the top of my head and untested but what about either replacing the combo box with a CFL that shows as many columns as you need (and by nice coincidence the first column in that table is the value you want selected, AbsID), OR, created two report parameters the first displays the Financial Year and the second displays the AbsID and Name values for the selected FinYr?
    Remember I'm writing this free hand so you'll need to test to make sure it's ok.
    Replace Cbo with CFL
    Budget@Select * From OBGS order by 3
    This should display a CFL where you can add any extra columns needed from the form settings.
    Two Cbo Parameters
    FinYr@ SELECT F_RefDate FROM OFPR
    Budget@Select AbsID, Name from OBGS WHERE FinancYear = ('FinYr@') order by 3
    So you can reference one parameter name inside another to limit the results displayed by the second parameter.
    One of the above or some variation should get you what you need.
    Regards,
    Andrew.

  • Af:table. How to add extra column.

    Hi,
    On my page I have a table that is generated from a view object. The attributes from the VO are coming from a entity object.
    table looks fine on my page. But now I need to add a extra column on the table and the value for that is coming from a other table then of the entity object.
    How can I make tis?
    Is it possible to have a entity object for more then 1 table?
    Should I make a VO that is filled with a query instead of a entity object?
    The VO is used on many pages, so can't change to much on that.
    Hope you have some good suggestions.
    thanks in advance.

    Hi:
    You can have VO with more one entity.
    I recomended to add attribute from entities and use which need.

  • Extra column in Crosstab report

    Hi Experts,
    We are designing a cross tab report (using CR 2008) and got stuck at one point. If we want to add an extra column in cross tab, what is the way to insert the same?
    Currently our cross tab is designed using 3 elements: Country, Month and Sales. We would like to add an extra column u201Clast year salesu201D before Month data. This element is present in database.
    Any help / suggestions would be appreciated.
    Regards,
    Chinmay

    Right click Cross tab - -> Cross tab expert
    Drag field into columns and the position with up/down arrows
    Ian

  • Extra columns in ALV report

    Hi there,
    I added a column to an existing alv report which uses method 'set_table_for_first_display' to display the output.
    The method is called via:
    grid1              TYPE REF TO cl_gui_alv_grid,
        CALL METHOD grid1->set_table_for_first_display
              EXPORTING
                        i_structure_name     = 'MAT_DATA'
                        is_layout            = lt_layout
                        is_variant           = lt_variant
                        i_default            = lt_default
                        i_save               = 'A'
                        it_toolbar_excluding = lt_exclude[]
               CHANGING it_outtab            = mat_data[]
                        it_fieldcatalog      = w_fieldcat[]
             EXCEPTIONS
                        program_error        = 1.
    The extra columns are in the field catalog and mat_data.
    The lt_variant-report field has the report name in it.
    When I run the report the new column does NOT appear.
    I cleared out the lt_variant-report value and now the new column DOES appear.
    Any idea why this is happening?
    Is there some way I can leave the report name in there and see the new columns?
    Thanks.

    thanks.
    no_out is initial.
    But, in this case, I am not passing any variant.
    It works if I don't pass the report name in the
    is_variant-report
    field.The columns will not display if I pass the report name.

  • Multiple Key figure in a single column of a query

    Hi,
    Is it possible to use muliple key figure like Amount and Qty field together in a column of a query?
    Please advise,
    Best Regards,
    UR

    Hi,
    You will be able to do it with the help of cell definitions.
    Say,you have a structure in Rows :
    A
    B
    For A ..in corresponding column cell,use cell definition with KF1
    For B.....in corresponding column cell,use cell definition with KF2
    this way,you will be able to see both in one column
    I m not sure how much it is relavant to your requirement.But this is one way of gettin it

  • R12 Payment Process Request Status Report adding extra columns to XML data.

    In 11i, we had modified the Preliminary Payment Report to include extra columns ( invoice distributions). In r12 , that report is obsolete and Oracle introduced a new report "Payment Process Request Status Report". This request uses BI Publisher to generate the final report output. I am unable to modify the template since the XML output of the report does not
    contain the invoice distribution account data. We need to know how can we modify the XML data to include the extra columns.
    For Funds Disbursement Process ( Payment Instruction File) , Oracle provides IBY_FD_EXTRACT_EXT_PUB extensibility package to construct custom XML element structure that can be added to the payment XML extract generated by Oracle Payments. Do we have something similar for this report ? Are there any other options available ?
    Thanks

    Hi
    The same package "IBY_FD_EXTRACT_EXT_PUB" works for payment process request status report also. Please add the logic to get the distribution data in this package and you will see the new XML tags in this report also.
    Hope this helps.
    Vinit

  • Deleting an extra column in the resultset of genericsearch page

    Hello E-Commerce Experts,
    we have a requirement where we need to delete a column in the resultset of the quicksearch trasactions in the genericsearch page.
    In order to hide this column we placed a condition in the action class from where we are getting the contents in the column.
    Now, we are unable to see the contents in the column but we are getting an empty column.
    As the genericsearch page gets genereted dynamically,we are unable to place any condition on that extra column.
    Can anyone suggest how to prevent this column from appearing on the screen. Do we need to set any parameters or anything.
    Thanks and regards,
    venkatesh Saini.

    Hi Venkatesh,
    You do not need to modify Action class for just hiding Trash column.
    Put below lines of code as I have suggested in *genericsearch.jsp* file you will able to hide *Trash* column without modifying Action class.
    You need to do 2 things to achieve your goal.
    First remove Header cell for Trash column and then remove trash icon cell from each row.
    First Search *<%-- // +++++++++++++++ RESULT LIST START +++++++++++++ --%>* comment.
    1) First Hide cell from Header Row.
    <% if ( ! "hidden".equals(listheader.getType())) { %>
         <% if ( listheader.getWriteUnderProperty() == null  ||  listheader.getWriteUnderProperty().length() <= 0  || baseui.isAccessible) { %>
              <% if ( ! firstPty) { %>
                 </th>
              <% }
                  firstPty = false;
              %>
         <%  //Custom Line
              if (!(ui.writeResultListHeader(listheader) == "" || ui.writeResultListHeader(listheader) == null)){  //Custom line
         %>  //custom Line
          <th scope="col" <%=ui.getTabIndex(true)%>>
                   <%=ui.writeResultListHeader(listheader)%>
         <% }%>     //Custom Line
    <% } else { %>
         <br /><%=ui.writeResultListHeader(listheader)%>
    <% } %>
    <% } %>
    2) Now Remove Trash cell from row. Below code with close <TD> tag properly
    <% if ( (! isWriteUnderProperty)) { %>
       <% if((iconPath == null) || (iconPath == "")){%> // Custom line
         <td <%=ui.writeResultTitlePerTD(rowfields)%> <%=ui.getTabIndex(true)%> <%=(iconPath !=null && iconPath.length() > 0 ? "style=\"text-align: center\"": "")%>>
      <% } else {%> // Custom Line
          </td>
      <%}%> //Custom Line
    <% } else { %>
          <br />
    <% } %>
    3) Now hide Cell with Trash icon.
    <% if (iconPath != null && iconPath.length() > 0) { %>
      <% if((iconPath == null) || (iconPath == "")){%> //Custom Line 
    < imge src="<%=iconPath%>"  alt="<%=outField.getString("ICONTITLE")%>"  border="<%=outField.getString("ICONBORDER")%>" width="<%=outField.getString("ICONWIDTH")%>" height="<%=outField.getString("ICONHIGHT")%>" />
      <% } %> //Custom Line
    <% } else { %>
         <%=ui.writeResultlistValue(rowfields , fieldValue)%>
    <% } %>
    I have written //Custom Line where I have added it in standard code.
    I have tested on my local and working fine.
    Let me know if you face any problem.
    eCommerce Developer

  • Comment column in a query

    Hello,
    In a BW query, I need to add a column of text comments (for example, the description of a calculation, the unit used, ...). These texts are static, the queries will only be used as static reports (download scheduler), in excel and web, so we can not use any VB script.
    Is it a way to add some text in a cell of a column, as in the following example (columns 2 and 3) ?
    KF1    |    Comment for KF1    |    Euros    |    12
    KF2    |    Comment for KF2    |    %          |    47
    Thanks in advance
    Michaë

    Hi guys,
    finally how you fix this problem?, I need to show a comment in a query column and i don't know if this is posible ¿?, I have a query inside of a wad and I want to show a comment in the columns  of the query with the formula details.
    Please let me know if you this is possible.
    Thanks!, Kinds Regards

  • How to Load data for extra columns exist in the dest schema....

    Hi Experts,
    Please help me.
    I need to replicate data from SchemaA to SchemaB.
    SchemaB has 3 extra columns. Two are varchar2 type and other is Integer type.
    I need to replicate the data from SchemaA to SchemaB in the same database.
    When ever i inserted the data in SchemaA, The extra columns should be populated with some default data.
    And if we did any update on SchemaA then the extra columns on SchemaB should be populated with other Data.
    I wrote some DML_HANDLER but it always populating same data.
    I dont know ow to handle this type of situation.
    my Handler is:
    CREATE OR REPLACE PROCEDURE dml_handler(in_any in sys.anydata)
    IS
    lcr SYS.LCR$_ROW_RECORD;
    rc PLS_INTEGER;
    object_owner VARCHAR2(30);
    BEGIN
    rc := in_any.GETOBJECT(lcr);
    object_owner := lcr.GET_OBJECT_OWNER();
    IF lcr.get_object_owner() = 'SchemaB' THEN
    lcr.add_column('new','SHIP_DATE',sys.anydata.convertvarcahr2('N'));
    lcr.add_column('new','SHIP_ZONE',sys.anydata.convertvarchar2('N'));
    lcr.add_column('new','SHIP_REACH_BY_DATE',sys.anydata.convertnumber(1));
    lcr.EXECUTE(TRUE);
    END IF;
    END;
    BEGIN
    DBMS_APPLY_ADM.SET_DML_HANDLER
    (object_name => 'SchemaB.TAB_TEST',
    object_type => 'TABLE',
    operation_name => 'INSERT',
    error_handler => FALSE,
    user_procedure => 'STRMADMIN.DML_HANDLER');
    END;
    On extra columns in SChemaB
    if its a first insert then the default values are (N,N,1).
    If we did any update the values should be (Y,Y,2)
    Post any script or give me some idea.
    Thanks,
    Ray
    Edited by: user7423698 on Mar 3, 2009 6:12 PM

    CREATE OR REPLACE PROCEDURE dml_handler (
    in_any IN SYS.ANYDATA
    IS
    lcr sys.lcr$_row_record;
    rc PLS_INTEGER;
    cmd_type VARCHAR2 (30);
    BEGIN
    rc := in_any.getobject (lcr);
    cmd_type := lcr.get_command_type;
    IF cmd_type = 'INSERT'
    THEN
    lcr.set_values ('new', lcr.get_values ('new', 'N'));
    lcr.add_column ('new', 'type', sys.anydata.convertchar ('I'));
    lcr.set_values ('old', NULL);
    lcr.add_column ('new', 'time', sys.anydata.converttimestamp (systimestamp));
    lcr.execute (TRUE);
    END IF;
    END;
    Set the DML handler for INSERT and write a similar one for UPDATE.

  • Creating an empty column in a query

    Is there a way to place an empty column in  a query? I would like to put acolumn with no information into the middle of a query. The reason is that the information that goes in that column is not available on any tables in my SQL databases.
    SELECT
    hier.dir_name 
    ,hier.am_name 
    ,hier.fm_name     INSERT BLANK COLUMN HERE
    ,hier.tech_name
    hier.tech_id

    Hi
    "no information" in database is usually NULL value. Is this what you are looking for?
    SELECT
    hier.dir_name
    ,hier.am_name
    ,NULL as fm_name
    --,hier.fm_name INSERT BLANK COLUMN HERE
    ,hier.tech_name
    hier.tech_id
    [Personal Site] [Blog] [Facebook]

  • Access Summary column in a query

    Hi All,
    I am new to oracle reports. I am using report builder 10.1.2.0.2.
    I have a summary column in my report. I would like to use this summary column in another query.
    if is use this column directly in the query, i am getting the below error:
    "Field 'F1' references column '<summary column name>' at a frequency below its group. "
    Both these fields are in the same frame. In the object navigator, both are displayed under the same group name.
    please let me know if there any way to access summary columns in another query.
    Thanks.

    You can use a field from one query in another query as parameter, i.e. preceded by colon. To do this first create link of "Group to Query" type between the first query's group where the summary column is, and the second query.

  • Set Column width in query (not using SQL*Plus)

    How can I Set Column width in query
    I understand you can set column width using
    column col1 FORMAT A5
    select col1 from table1;But this only works in SQL*Plus
    I want to be able to do this in a regular SQL query window (not in SQL*Plus), how can I do it.....
    I am using a 'SQL window' in PL/SQL Developer IDE
    and when I use this syntax it says:
    ORA-00900: Invalid SQL statement
    Any suggestions are appreciated...
    thanks,
    M.

    Did you try using RPAD or LPAD functions? They fill the unfilled part of a string with character you provide... either on right or left side depending on what function you use.
    e.g.
    SELECT RPAD('Smith', 10, ' ') Name FROM dual;http://www.adp-gmbh.ch/ora/sql/rpad.html
    Edited by: Zaafran Ahmed on Nov 10, 2010 11:50 AM

Maybe you are looking for