JSP, DataWebBean: How to dynamically set the where clause of query and display record

Hi,
I am reposting this question as per suggestions made by Mr. Dwight.
I have used ViewCurrentRecord web bean to display records from EMP table. I have to use the Dept_Id_FK from the current
record of the EMP table to display corresponding records of Dept table. I have a view object called DeptView in my Business
Components which selects all the records from the Dept table.
How do I get the value of Dept_Id_FK and use it to display the required records of the Dept table?
I tried to declare a variable and get the value of Dept_Id_FK but it did not work. My code is as follows:
<%! String m_DeptId = null; %>
<jsp:useBean id="RowViewer" class="oracle.jbo.html.databeans.ViewCurrentRecord" scope="request">
<%
RowViewer.initialize(pageContext, "EMPApp_EMP_EMPAppModule.EMPView1");
RowViewer.setReleaseApplicationResources(false);
RowViewer.getRowSet().next();
m_DeptId = (String)RowViewer.getRowSet().getCurrentRow().getAttribute("DeptIdFk");
%>
</jsp:useBean>
Thanks.
null

First of all, Thank you very much for making use of the new topic format. It is very much appreciated.
As for your question, I think there are several different ways to accomplish what I think you want to do.
1. Create a view object that includes both Emp and Dept entities and join them there. In this case, your query would look something like this:
Select e.empno,e.name,...,d.dname,d.loc from emp e, dept d
where e.deptno = d.deptno
You should be able to create a JSP off of this view object that contains both the employee and department information. In this case, BC4J takes care of the foreign key to primary key coordination.
2. In order to set a dynamic where clause for a view, you need to do the following in your usebean tag:
rsn.initialize(application,session, request,response,out,"DeptView");
rsn.getRowSet().getViewObject().setWhereClause("deptno=" &#0124; &#0124; m_DeptId);
rsn.getRowSet().getViewObject().executeQuery();
rsn.getRowSet().first();
You will need to do this in a separate usebean tag from the EmpView, since the usebean can only initialize one view object.
In other words, you would have your ViewCurrentRecord bean tag for the EmpView, then a separate one for the DeptView where you use the above code to set the where clause to display just the information for the department you want.
Another option, but one I'm not sure would work as well, is to create a master-detail JSP to do this for you. Usually a master-detail is a one-to-many (one department to many employees). Your request appears to be the reverse, but might still be doable using the same mechanism.
You set up relationships between views in your BC4J project using View Links. If you used the BC4J project wizard and created default views, some of these links may have been created for you. They are created when BC4J detects a foreign key to primary key relationship in the database.
You can create your own View Links using the View Link wizard. Select your BC4J project node and choose Create View Link... from the context menu. You will be asked to select a source view (Emp), and a target view (Dept), then select the attribute in each view that related the two of them (deptno).
Next, you need to reflect this new relationship setting in your application module. Select your app module and choose Edit from the context menu. On the data model page, select the EmpView node in the Selected list. Now select the DeptView node in the available list and shuttle it over. You should see DeptView1 via yourlink appear indented under the EmpView node. Save and rebuild your BC4J project to reflect the changes.
In your JSP project, you can now have the wizard create a master-detail form for you based on DeptView1.
Let me know if the above answers your question, or if I have misunderstood what it is you wanted to do.
null

Similar Messages

  • JSP, Data Web Bean, BC4J: Setting the where clause of a View Object at run time

    Hi,
    I am trying to develop a data web bean in which the where clause of a View Object will be set at run time and the results of the query then displayed.
    My BC4J components are located in one project while the coding for the data web bean is in another project. I used the following code bu t it does not work. Could you please let me know what I am doing wrong?
    public void populateOSTable(int P_EmpId)
    String m_whereString = "EmpView.EMP_ID = " + P_EmpId;
    String m_OrderBy = "EmpView.EMP_NAME";
    oracle.jbo.ApplicationModule appModule = null;
    ViewObject vo = appModule.findApplicationModule("EMPBC.EMPAppModule").findViewObject("EMPBC.EMPView");
    vo.setWhereClause(m_whereString);
    vo.setOrderByClause(m_OrderBy);
    vo.executeQuery();
    vo.next();
    String empName numAttrs = vo.getAttribute(EmpName);
    System.out.println(empName);
    Thanks.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by JDev Team (Laura):
    Here is how I have usually done mine:
    1. In the JSP, use a RowsetNavigator bean to set the where clause and execute the query.
    2. Use a custom web bean to process the results of the query (print to HTML).
    for example:
    <jsp:useBean class="oracle.jbo.html.databeans.RowsetNavigator" id="rsn" scope="request" >
    <%
    // get the parameter from the find form
    String p = request.getParameter("p");
    String s = request.getParameter("s");
    // store the information for reference later
    session.putValue("p", p);
    session.putValue("s", s);
    // initialize the app module and view object
    rsn.initialize(application,session, request,response,out,"wt_bc_WT_bcModule.wtjoinView");
    // set the where clause string
    String theclause = "presname = '" + p + "' AND slideno=" + s;
    // set the where clause for the VO
    rsn.getRowSet().getViewObject().setWhereClause(theclause);
    rsn.getRowSet().getViewObject().executeQuery();
    rsn.getRowSet().first();
    %>
    </jsp:useBean>
    <jsp:useBean class="wt_bc.walkthruBean" id="wtb" scope="request" >
    <%
    // initialize the app module and VO
    wtb.initialize(application,session, request,response,out,"wt_bc_WT_bcModule.wtjoinView");
    wtb.render();
    %>
    In this case, the render method of my custom web bean mostly gets some session variables, and prints various content depending on the session variable values.
    Hope this helps.
    </jsp:useBean><HR></BLOCKQUOTE>
    Laura can you give the code of your walkthru bean? i wna't to initialize a viewobject, set the where clause and give that viewobject back to initialize my navigatorbar.
    Nathalie
    null

  • Regarding  dynamically assigning the where clause to select query

    hi,
      Please send the code regarding how to dynamically assign the where clause to select query.
    thanks in advance

    SELECT <fileds>
            INTO TABLE itab
            FROM dbase
            WHERE  condition.

  • Dynamically set ViewObject where clause dynamically from Java bean

    I have a requirement to display all of the records from a table when the JSP is first brought up, so my View Object looks like this:
    "select emp_name from emp"
    Then the users wants to ability to pass paramters to that View Object to refine the list so from by Java class I tried to do this:
    ViewObject vo = cpd.findViewObject("EmpViewObject");
    vo.setWhereClause("empName = :1");
    vo.setWhereClauseParam(1,varEmpName);
    vo.executeQuery();
    But I am getting JBO errors and I'm not sure what I'm doing wrong. Can anyone offer a hint as to how I can do this?

    this is exactly how the code is done -
    1. emp_name in the View Object
    2. emp_name in the where clause
    The two are identical. I have tried many variations of this - any time I set the where clause from my bean I get an error.
    When I take the SQL stmnt and run it in TOAD it returns expected rows when I run it in the SQL worksheet in JDev it gives an invalid Identifier - but if I hard code the where clause in the View Object it returns the same results as TOAD.

  • Not able to set the where clause params

    Hi,
    My version of apps is 12.1.3.
    I created a page with a searchRN and resultRN (LinesVO). (Not a query/view link) . I am passing the id from header to the VO to restrict the linesVO
    The controller correctly passes the id from searchRN to AM, but in AM, the where clause is not set and I am not getting the desired result:
    My AM Code:
        public void InvokeGo(String Hdrval)
                    LineVOImpl LineVO1 = getLineVO1();
                    LineVO1.setWhereClauseParams(null); // Always reset
                     System.out.println("AMIMPL:Hdrval = "+ Hdrval);
                    <prints the header_Value which is passed from CO>
                       if (Hdrval           == null        
                                            System.out.println("Inside Null If");  
                                            String message = "Please provide atleast one input to any of these search field";
                                            throw new OAException(message, OAException.ERROR);
                                    else   
                                        System.out.println("Not All Parameters are Null.Building Where Clause");
                                         < prints the line above>
                                        LineVO1.setWhereClause
                                        ("Header_name = :1");
                        System.out.println("Paremeter Set are: Header_name:"+Hdrval);
                        <prints the above line like :   Paremeter Set are: Header_name:Hdr_Name_1
                        LineVO1.setWhereClauseParam(0,Hdrval);
                        System.out.println("Inside MainAM invokeGO Method:"+LineVO1.getQuery());
                        < prints:Inside MainAM invokeGO Method:SELECT * FROM (select LINE_ID,hdr.HEADER_ID,LINE_NUMBER,LINE_NAME,Attach,hdr.header_name from xxtr_hdr hdr, xxtr_line line
    where hdr.header_id=line.header_id) QRSLT  WHERE (Header_name = :1)>
                        LineVO1.executeQuery();
    The issue is in the SQL build. I guess after setting the where clause, it should appear like :
    QRSLT  WHERE (Header_name = "Hdr_Name_1"
    Thanks

    Hu Sumit,
    I am doing that:
    LineVO1.setWhereClauseParam(0,Hdrval);
    before executequery. I even hard coded
    LineVO1.setWhereClauseParam(0,"XXXX");
    but still it din't work. I guess I am missing something small. because I have done this thing a lot of times earlier and it had worked.

  • How to dynamically set the name of the generated PDF file sent by email

    Hello,
    I am using Reports 10g and I managed to send PDF reports by email, specifying the recipient, subject, format etc, using the reports servlet URL.
    But there is one thing that I cannot find a way to do: I want to dynamically set the name of the attached file. It defaults to the name of the RDF file (eg monthly_sales.pdf). I would like it to be something more meaningful (eg monthly_sales_072010.pdf, where 072010 is the month and year passed by parameters).
    Is it possible to do it?
    Thanks
    Luis

    Use System.load(...) instead of System.loadLibrary(...).

  • Pass values dynamically to the WHERE clause in SFAPI

    Hi there
    We have a requirement to pass values dynamically (in the run-time of the interface) to the WHERE condition to our SFAPI query.
    Eg -
    SELECT person, personal_information, address_information, phone_information, email_information, employment_information, job_information, compensation_information, paycompensation_recurring, paycompensation_non_recurring, job_relation, accompanying_dependent,         global_assignment_information, direct_deposit, national_id_card, person_relation
              FROM CompoundEmployee
              WHERE last_modified_on &gt;= to_date('LAST_RUN_DATE')  AND
                           last_modified_on &lt;= to_date('CURRENT_RUN_TIME') 
    LAST_RUN_DATE is stored in a custom entity for which we execute another OData query. The custom entity is updated with the CURRENT_RUN_TIME once the interface has been executed successfully. So the next time the interface is run it picks up the LAST_RUN_DATE from the custom OData entity.
    SAP PO has the functionality to run a dynamic query for OData adapters. Refer to Note 2051137 - PI Successfactors adapter : Dynamic odata query and single synchronous sfapi query
    Eg - select fields from position (this is what you state in OData query path in the comms channel; this is static); and you have an advanced tab in comms channel where you mention dynamicquery and set it to true (this points to a XSD which has the keyword TOP, SKIP & FILTER in it).
    This gets the filter values passed from the BPM from another query (from a OData cust_table).
    So the whole query is - select fields from position filter field a = x field b = y etc. Field a field b are fields in position that are you passing values x and y in run time of the interface.
    SAP PO also has the advanced tab feature for SFAPI for dynamic query.
    Question is -
    how to use it?
    has anyone implemented this before?
    What does XSD will look like?
    How do we pass values to the fields to the Where clause for SFAPI.
    Any ideas are welcome!
    Regards
    Arijit Das

    After you have added a new where clause on the detail VO, try re-executing VO's query by DetailVO.executeQuery()
    If it doesn't work try re-executing the MasterVO's query after you have added the where clause on the detail

  • How do I modify the WHERE clause in my SQL query?

    This seems like such a straight-forward part of the report design, but I'm fairly new to Crystal Reports and I only have experience with modifying reports someone else has already written.  In this particular case, I just need to modify the WHERE clause of the SQL query.  I can select Show SQL Query and see what statement is being used to select data, but I can't find where to modify it since it's grayed out.  I see how to change the selection criteria, parameters, grouping, etc...just not the WHERE clause.  The report is linked to a database used for reporting with a table created and populated by a stored procedure.  I don't need to modify the stored procedure because the data I want to filter by is currently in the table--I just don't know how to filter by what I need.  Here's part of the query:
    SELECT "rpt_dist"."startdate", "rpt_dist"."transtype", "rpt_dist"."laborcode", "rpt_dist"."crewid", "rpt_dist"."regularhrs" FROM   "Reporting"."dbo"."rpt_dist" "rpt_dist"
    WHERE  (rpt_dist."transtype" <> 'WORK' AND rpt_dist."transtype" <> 'WMATL') AND rpt_dist."laborcode" LIKE 'S%' AND (rpt_dist."crewid" = 'HOUS' OR rpt_dist."crewid" = 'HOUS2' ...
    I would like to add another crewid to the WHERE clause.  Thanks for any input.

    1.Open the report in the crystal designer
    2.Go to the field explorer(if hidden go to view menu->field explorer)
    3.Rt. click on the database fields->choose database expert
    4.Now you will see 2 columns-Available DataSource  and Selected Tables
    5.Rt. click on the object(ex.command) available in the Selected Tables column->Choose Edit command
    6.A new Modify Command window will appear,here you can edit your SQL Query
    I get to step 4 and I see the two columns including my database and the report table, but there is no command object available.  If I right-click on my table, I can just view the Properties. ??
    As for the other tip to modify the record selection:  I don't see anywhere the other crewid values are set and if I add the one I'm missing, it doesn't modify the existing SQL Query and when I preview the report it throws off the results so that no data displays??
    I'm using Crystal Reports 11.5 if that makes a difference.  Thanks again.

  • Dynamically changing the WHERE clause in detail VO in Master Detail

    Hi, I want to develop a search functionality, results will be in a table, which will have an inline table displaying the details per row found.
    I have a MD defined trough viewlink. I do change the master VO at runtime (set the entire SQL), based on the criteria entered by the user.
    Is there a way to change the VO at the detail end of the link at runtime - that is what I haven't been able to do.
    I have read that the ADF framework creates internal VO for each master row, whenever accessed trough accessor (which is not I am trying to do). I haven't been able to find a way to get a hold of the REAL VO at the detail end and have its WHERE clause changed.
    Changes to the "VO instance in AM" (same one used as a definition in the detail end in the ViewLink def) does not seem to reflect the detail VO.
    I have a MasterView, DetailView, MasterDetailLink (MasterView->DetailView).
    MasterDetailLink is used to create a table with inline detail table. At runtime:
    1.get MasterView (from AM), change query trough setQuesry() - works.
    2.get DetailView (from AM), change query trough addWhereClause() - does not work (no exceptions) - the results I am getting DO NOT reflect the conditions of the where clause, I mean the clause have not been addedd.
    I 've looked at the logs (debug enabled) and it seems to me that there no "activities" related to the detail VO, even after the where clause of the VO from step 2 is changed.
    Looks like there is a separate VO which I would like to get a hold of :)
    Thanks, and sorry for the long explanation

    After you have added a new where clause on the detail VO, try re-executing VO's query by DetailVO.executeQuery()
    If it doesn't work try re-executing the MasterVO's query after you have added the where clause on the detail

  • How to set the where clause of a value set on the basis of a form field

    I am using a DFF(Descriptive FlexField), which needs to display the value of a certain column(say columnA) on the basis of the value of another column(say columnB).
    So i have created a value set which points to the table which has both these columns, and the DFF uses this value set. However, the problem is that I have not put any where clause in the value set, because of which i cannot handle the exact fetch returns more than one rows error.
    The query has to be as follows:
    select ColumnA from tbl where ColumnB = [ a form value ];
    What I want to know is how can i get the value of a certain field of a certain block of the form in the above query.
    Edited by: 981615 on Jan 14, 2013 12:48 AM
    Edited by: 981615 on Jan 14, 2013 12:48 AM

    Just have a look over these two statements if it solves your problem
    one time where clause
    Set_Block_Property('BLOCK_NAME',ONETIME_WHERE,your form item);
    dynamic where clause
    set_block_property('BLOCK_NAME'default_where, your form itme)
    you can where clause at run time from any procedure or some triggers

  • How to dynamically Set the list of flex contexts based on a condition

    Database is in 11i atg rup7 level
    first OAF page - shows list of employees under a manager
    on clicking an employee record, the second OAF page opens and it shows a set of records from descriptive flexfield. Currently 5 contexts of the same flexfield are enabled for this responsibiltiy using the ContextA||Seg1|Seg2|Seg3||ContextB||Seg1|Seg2||ContextC||Seg1|Seg2|Seg3|Seg4||ContextD||Seg1|Seg|Seg3|Seg4||COntextE||Seg1|Seg2 in the personalisation at responsibility
    So 5 sections(one for each context) are shown in the OA page
    My requirement is to show only 3 contexts for employee 'A' and 5 contexts for the employee 'B'. Both the employees are under the same manager.So i think i cannot do a simple personalisation at responsibility level.
    So assuming ,i have some parameter like person_id , how do i dynamically restrict to 3 or 5 contexts in my controller code?

    Hi,
    Use this :
    OADescriptiveFlexBean descFlexfieldsBean = (OADescriptiveFlexBean)oawebbean.findIndexedChildRecursive("flexitemid");
    descFlexfieldsBean.processFlex(oapagecontext);
    if(descFlexfieldsBean != null)
    descFlexfieldsBean.setFlexContextCode(pageContext,"ContextName");
    Thanks,
    Gaurav

  • How to dynamic set the X date series...

    Hi,
    I set the X axis date value interval 1 so it can show as a daily "date", however, the chart is good if the data point is within 24 records. However, when I draw 7 days data (around 168 records), the x axis date lable will be messed up and cannot
    view the actual date values.
    Could you advise a formular to evaluate the returned data set, if it is bigger than a variable (e.g 168 or returned data set records is larger than 168 then it will set to auto) ??
    Thanks

    Hi kkcci88888,
    According to your description, you create a chart and many values display on X axis, then you can’t see the actual date value clearly. So you want to make X axis values group on date, right?
    In your scenario, since there are too many records within 7 days, it will have too many date appear on the category (X-axis). However, we could specify the dataset fields group on day values, and make label displays as YYYY-MM_DD using expression. Please
    refer to steps below:
    1. Specify Label with expression Category Group Properties like below:
    =Year(Fields!date.Value)&"-"&Month(Fields!date.Value)&"-"&day(Fields!date.Value)
    2. Specify the Group on expression Category Group Properties like below:
    =day(Fields!date.Value)
    3. Preview the report.
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu

  • How can I set the parameters of global channels and tasks previously created inside my applicatio​n?

    Hi everyone !
    Before proceeding to the description below I think it´s important to say that I´m using NI USB-6008 as DAQ device and the driver used is DAQmx 7.5.
    I´m currently developing an application into which I intend to be able to have complete control of the DAQ device being used, i.e, I´ll be able to create, delete and change the configuration of global channels and tasks previously created, among other things.
    To achieve the ends specified above I´ve already developed two vis, one to create global channels and the other to create tasks, and these two are doing a fine job. After this, I thought I came to the easy part ... I think I couldn´t be far for the truth! I thought that everything I should do was to specify which channel or task I´d like to configure and then use a property node to get the results I wanted, but it´s not working ...there are some DAQmx property nodes I thought I could use to do it  but I didn´t find a way to change the configuration of the global channels, and none of these property nodes seemed to work, i.e, although the simple vis used to test them ran the chosen parameters didn´t alter at all, after each execution I used MAX to see if they had changed, and to my chagrin they hadn´t.
    Can anybody lend me a hand with this problem? As always, any help would be deeply appreciated !    

    Hi Giovani,
    There is a developer zone tutorial that discussus some advanced data acquisition features including programmatic saves of NI-DAQmx tasks, global channels, and scales.  This tutorial also includes an example program.
    I wrote a short program that creates tasks in MAX. Whenever I wanted to change a part of the task, I would just change that feature in the example program. Take a look at the examples and please let me know if you have any further questions.
    Regards,
    Hal L.
    Attachments:
    create task example.vi ‏33 KB

  • Urgent ! open the same page in query and create record mode...

    We have to page in our project
    First page include a list show employees(page1) and second page(page2) showsdetail information on employees.
    We have two button on page1 ("CREATE NEW EMPLOYEES" and "EDIT EMPLOYEES")
    When we press create button we need to create a record on second page.
    Second page is needed to open create insert mode.
    When we press edit button we need to edit emloyees details.
    Second page shows queried record.
    can we implement this using faces config xml without writing code . Or do we need to write code.
    How can we implement create insert and query event on the same page call (page2)...
    Thanks a lot...

    Hi,
    using ADF, drag the edit button from the component palette and point its navigation case to the next page that contains the edit form.
    Drag and drop the create button from the data control palette by dragging the "create" operation of the VO to the page. Also set the navigation case to the edit form and change the pagedef file (the binding) for this "Create" operation to use CreateInsert as an operation
    Frank

  • How do I set the finder column view to always display the "thin" column edges?

    Sometimes finder switches to display thick column edges. These screen shots were taken 5 min apart, after a restart.  I would love to know to to make sure it always displays the thin version.
    Side note: does anyone know how to open new columns that automatically resize to fit the largest file name.....?    Having to constantly resize columns is really irritating.

    it can not display what has not been downloaded, for them to be the same I assume you have chosen to leave messages on the server.
    Date: is set by the sender and has nothing to do with a delivery date in Thunderbird. If Thunderbird is displaying the date the message arrived in Thunderbird, what is in the date: header?
    Received: is a series of transmission points and following the instructions below will display the latest.
    * Select Tools/Options from the main menu.
    * Click Config Editor.
    * If a warning displays, click “I’ll be careful, I promise!”.
    * Locate the mailnews.customDBHeaders preference, e.g. by typing “dbh” in the Filter field. Double click it, or select and press Enter.
    * If the preference was not set previously, type “Received” and click OK. If some extension has already populated the preference, add “ Received” to the end of the list of headers, separating it with space.
    * Close the Config Editor and restart Thunderbird.

Maybe you are looking for