Applying view criteria dynamically

Hi,
its urgent...... please guide me....
in my application I want to execute the viewobject once using database than it should store in cache memory and after applying view criteria it should filter the data and give from the memory after clearing it it should return all the records from the cache memory no need to go database...
I have used the following code......
public void getViewdata()
               ApplicationModule am = Configuration.createRootApplicationModule("model.HRAppModule", "HRAppModuleLocal");
        ViewObject viewobject = am.findViewObject("employeesVo1");
        viewobject.executeQuery();
              System.out.println("no of records:\t" + viewobject.getRowCount());
        System.out.println("no of records:\t " + viewobject.getFetchedRowCount());
        System.out.println("no of records:\t" + viewobject.getEstimatedRowCount());
        System.out.println("Query Mode of viewobject:\t" + viewobject.getQueryMode());
        ViewCriteria Viewcriteria = null;
        Viewcriteria = viewobject.createViewCriteria();
        Viewcriteria.setCriteriaMode(Viewcriteria.CRITERIA_MODE_QUERY | Viewcriteria.CRITERIA_MODE_CACHE);
        System.out.println("Viewcriteria mode is:\t" + Viewcriteria.getCriteriaMode());
        viewobject.setQueryMode(viewobject.QUERY_MODE_SCAN_VIEW_ROWS);
        System.out.println("Query Mode of viewobject:\t" + viewobject.getQueryMode());
        Viewcriteria.setConjunction(Viewcriteria.VC_CONJ_AND);
        ViewCriteriaRow Viewcriteriarow = Viewcriteria.createViewCriteriaRow();
        ViewCriteriaRow Viewcriteriarow1 = Viewcriteria.createViewCriteriaRow();
        Viewcriteriarow.setAttribute("ManagerId", this.getMgr());
        Viewcriteriarow.setConjunction(Viewcriteriarow.VC_CONJ_AND);
        Viewcriteriarow1.setAttribute("Salary", this.getSal());
        Viewcriteriarow1.setConjunction(Viewcriteriarow.VC_CONJ_AND);
        Viewcriteria.add(Viewcriteriarow);
        Viewcriteria.add(Viewcriteriarow1);
        if (Viewcriteria.hasData())         {
            System.out.println("Query Mode of viewobject:\t" + viewobject.getQueryMode());
            viewobject.applyViewCriteria(Viewcriteria);
            viewobject.executeQuery();
            System.out.println("no of records after apply view criteria:\t" + viewobject.getRowCount());
            System.out.println("no of records after apply view criteria:\t" + viewobject.getFetchedRowCount());
            System.out.println("no of records after apply view criteria:\t" + viewobject.getEstimatedRowCount());
            System.out.println(" view criteria where clause:\t" + viewobject.getViewCriteria());
                       System.out.println("Viewcriteria mode is:\t" + Viewcriteria.getCriteriaMode());
            System.out.println("Query Mode of viewobject:\t" + viewobject.getQueryMode());
            System.out.println("Query :\t" + viewobject.getQuery());
        else
                      Viewcriteria.removeAllElements();
            viewobject.applyViewCriteria(Viewcriteria);
            System.out.println("Viewcriteria mode is:\t" + Viewcriteria.getCriteriaMode());
             System.out.println(" view criteria where clause:\t" + viewobject.getViewCriteria());
                       System.out.println("Query :\t" + viewobject.getQuery());
            viewobject.executeQuery();
            System.out.println("no of records after apply view criteria:\t" + viewobject.getRowCount());
            System.out.println("no of records after apply new view criteria:\t" + viewobject.getFetchedRowCount());
            System.out.println("no of records after applying new view criteria:\t" + viewobject.getEstimatedRowCount());
            System.out.println("Viewcriteria mode is:\t" + Viewcriteria.getCriteriaMode());
            System.out.println("Query Mode of viewobject:\t" + viewobject.getQueryMode());
        }Edited by: user13385388 on Jan 21, 2011 6:59 AM

Hi,
I'm not able to get that so I have put all the things u go through it tell me the solution please its urgent...... please guide me....
in my application I want to execute the viewobject once using database than it should store in cache memory and after applying view criteria it should filter the data and give from the memory after clearing it it should return all the records from the cache memory no need to go database...
I have used the following code......
backing bean code
public class Beanclass
    private String deptid;
    private String mgrid;
    private String sal;
    public void setDeptid(String deptid)
        this.deptid = deptid;
    public String getDeptid()
        return deptid;
    public void setSal(String sal)
        this.sal = sal;
    public String getSal()
        return sal;
    public String ROView_action()
        // Add event code here...
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Application app = facesContext.getApplication();
        ExpressionFactory elFactory = app.getExpressionFactory();
        ELContext elContext = facesContext.getELContext();
        ValueExpression valueExp = elFactory.createValueExpression(elContext, "#{bindings}", Object.class);
        BindingContainer bindings = (BindingContainer) valueExp.getValue(elContext);
        DCIteratorBinding iter = (DCIteratorBinding) bindings.get("EmPdetails1Iterator"); //("employeesVo1Iterator");
        ViewObject viewobject = iter.getViewObject();
        System.out.println("no of records without applying view criteria value:\t" + viewobject.getRowCount());
        System.out.println("no of records without applying view criteria value:\t " + viewobject.getFetchedRowCount());
        System.out.println("no of records without applying view criteria value:\t" + viewobject.getEstimatedRowCount());
        System.out.println("Query Mode of viewobject before applying view criteria:\t" + viewobject.getQueryMode());
        ViewCriteria Viewcriteria = null;
        Viewcriteria = viewobject.createViewCriteria();
        Viewcriteria.setCriteriaMode(Viewcriteria.CRITERIA_MODE_CACHE);
        //Viewcriteria.setCriteriaMode(Viewcriteria.CRITERIA_MODE_QUERY | Viewcriteria.CRITERIA_MODE_CACHE);
        System.out.println("Viewcriteria mode is:\t" + Viewcriteria.getCriteriaMode());
        viewobject.setQueryMode(viewobject.QUERY_MODE_SCAN_VIEW_ROWS);
        System.out.println("Query Mode of viewobject:\t" + viewobject.getQueryMode());
        Viewcriteria.setConjunction(Viewcriteria.VC_CONJ_AND);
        ViewCriteriaRow Viewcriteriarow = Viewcriteria.createViewCriteriaRow();
        ViewCriteriaRow Viewcriteriarow1 = Viewcriteria.createViewCriteriaRow();
        ViewCriteriaRow Viewcriteriarow2 = Viewcriteria.createViewCriteriaRow();
        Viewcriteriarow.setAttribute("DepartmentId", this.getDeptid());
        Viewcriteriarow.setConjunction(Viewcriteriarow.VC_CONJ_AND);
        Viewcriteriarow1.setAttribute("ManagerId", this.getMgrid());
        Viewcriteriarow1.setConjunction(Viewcriteriarow.VC_CONJ_AND);
        Viewcriteriarow2.setAttribute("Salary", this.getSal());
        Viewcriteriarow2.setConjunction(Viewcriteriarow.VC_CONJ_AND);
        Viewcriteria.add(Viewcriteriarow);
        Viewcriteria.add(Viewcriteriarow1);
        Viewcriteria.add(Viewcriteriarow2);
        viewobject.applyViewCriteria(Viewcriteria);
        viewobject.executeQuery();
        System.out.println("no of records after applying view criteria value:\t" + viewobject.getRowCount());
        System.out.println("no of records after applying view criteria value:\t" + viewobject.getFetchedRowCount());
        System.out.println("no of records after applying view criteria value:\t" + viewobject.getEstimatedRowCount());
        System.out.println("Viewcriteria mode is:\t" + Viewcriteria.getCriteriaMode());
        System.out.println("Query Mode of viewobject:\t" + viewobject.getQueryMode());
        Viewcriteria.removeAllElements();
        viewobject.applyViewCriteria(Viewcriteria);
        //  viewobject.setQueryMode(viewobject.QUERY_MODE_SCAN_DATABASE_TABLES);
        viewobject.executeQuery();
        System.out.println("no of records after removing view criteria:\t" + viewobject.getRowCount());
        System.out.println("no of records after removing view criteria:\t" + viewobject.getFetchedRowCount());
        System.out.println("no of records after removing view criteria:\t" + viewobject.getEstimatedRowCount());
        System.out.println("Viewcriteria mode is:\t" + Viewcriteria.getCriteriaMode());
        System.out.println("Query Mode of viewobject:\t" + viewobject.getQueryMode());
        return null;
}Jspx code
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <f:view>
    <af:document id="d1">
      <af:messages id="m1"/>
      <af:form id="f1">
        <af:pageTemplate viewId="/oracle/templates/threeColumnTemplate.jspx"
                         id="pt1">
          <f:facet name="center">
            <af:panelGroupLayout id="pgl2" layout="vertical"
                                 inlineStyle="width:1327px;">
              <af:table value="#{bindings.EmPdetails1.collectionModel}"
                        var="row" rows="#{bindings.EmPdetails1.rangeSize}"
                        emptyText="#{bindings.EmPdetails1.viewable ? 'No data to display.' : 'Access Denied.'}"
                        fetchSize="#{bindings.EmPdetails1.rangeSize}"
                        rowBandingInterval="0"
                        selectedRowKeys="#{bindings.EmPdetails1.collectionModel.selectedRow}"
                        selectionListener="#{bindings.EmPdetails1.collectionModel.makeCurrent}"
                        rowSelection="single" id="t1" partialTriggers="::cb1"
                        width="1290">
                <af:column sortProperty="DepartmentId" sortable="true"
                           headerText="#{bindings.EmPdetails1.hints.DepartmentId.label}"
                           id="c5">
                  <af:outputText value="#{row.DepartmentId}" id="ot11">
                    <af:convertNumber groupingUsed="false"
                                      pattern="#{bindings.EmPdetails1.hints.DepartmentId.format}"/>
                  </af:outputText>
                </af:column>
                <af:column sortProperty="DepartmentName" sortable="true"
                           headerText="#{bindings.EmPdetails1.hints.DepartmentName.label}"
                           id="c10">
                  <af:outputText value="#{row.DepartmentName}" id="ot3"/>
                </af:column>
                <af:column sortProperty="EmployeeId" sortable="true"
                           headerText="#{bindings.EmPdetails1.hints.EmployeeId.label}"
                           id="c1">
                  <af:outputText value="#{row.EmployeeId}" id="ot9">
                    <af:convertNumber groupingUsed="false"
                                      pattern="#{bindings.EmPdetails1.hints.EmployeeId.format}"/>
                  </af:outputText>
                </af:column>
                <af:column sortProperty="FirstName" sortable="true"
                           headerText="#{bindings.EmPdetails1.hints.FirstName.label}"
                           id="c9">
                  <af:outputText value="#{row.FirstName}" id="ot2"/>
                </af:column>
                <af:column sortProperty="LastName" sortable="true"
                           headerText="#{bindings.EmPdetails1.hints.LastName.label}"
                           id="c3">
                  <af:outputText value="#{row.LastName}" id="ot12"/>
                </af:column>
                <af:column sortProperty="Email" sortable="true"
                           headerText="#{bindings.EmPdetails1.hints.Email.label}"
                           id="c11">
                  <af:outputText value="#{row.Email}" id="ot10"/>
                </af:column>
                <af:column sortProperty="PhoneNumber" sortable="true"
                           headerText="#{bindings.EmPdetails1.hints.PhoneNumber.label}"
                           id="c6">
                  <af:outputText value="#{row.PhoneNumber}" id="ot7"/>
                </af:column>
                <af:column sortProperty="HireDate" sortable="true"
                           headerText="#{bindings.EmPdetails1.hints.HireDate.label}"
                           id="c7">
                  <af:outputText value="#{row.HireDate}" id="ot1">
                    <af:convertDateTime pattern="#{bindings.EmPdetails1.hints.HireDate.format}"/>
                  </af:outputText>
                </af:column>
                <af:column sortProperty="JobId" sortable="true"
                           headerText="#{bindings.EmPdetails1.hints.JobId.label}"
                           id="c4">
                  <af:outputText value="#{row.JobId}" id="ot5"/>
                </af:column>
                <af:column sortProperty="Salary" sortable="true"
                           headerText="#{bindings.EmPdetails1.hints.Salary.label}"
                           id="c12">
                  <af:outputText value="#{row.Salary}" id="ot8">
                    <af:convertNumber groupingUsed="false"
                                      pattern="#{bindings.EmPdetails1.hints.Salary.format}"/>
                  </af:outputText>
                </af:column>
                <af:column sortProperty="CommissionPct" sortable="true"
                           headerText="#{bindings.EmPdetails1.hints.CommissionPct.label}"
                           id="c2">
                  <af:outputText value="#{row.CommissionPct}" id="ot6">
                    <af:convertNumber groupingUsed="false"
                                      pattern="#{bindings.EmPdetails1.hints.CommissionPct.format}"/>
                  </af:outputText>
                </af:column>
                <af:column sortProperty="ManagerId" sortable="true"
                           headerText="#{bindings.EmPdetails1.hints.ManagerId.label}"
                           id="c8">
                  <af:outputText value="#{row.ManagerId}" id="ot4">
                    <af:convertNumber groupingUsed="false"
                                      pattern="#{bindings.EmPdetails1.hints.ManagerId.format}"/>
                  </af:outputText>
                </af:column>
              </af:table>
            </af:panelGroupLayout>
          </f:facet>
          <f:facet name="header"/>
          <f:facet name="start">
            <af:panelGroupLayout id="pgl1" layout="vertical">
              <af:inputText label="Department Id" id="it1"
                            value="#{Viewcriteriabackingbean.deptid}"/>
              <af:inputText label="Salary" id="it2"
                            value="#{Viewcriteriabackingbean.sal}"/>
              <af:commandButton text="ApplyviewcriteriaUsingIteratorBindingforROView" id="cb1"
                                partialTriggers="t1"
                                action="#{Viewcriteriabackingbean.ROView_action}"/>
            </af:panelGroupLayout>
          </f:facet>
          <f:facet name="branding"/>
          <f:facet name="copyright"/>
          <f:facet name="status"/>
          <f:attribute name="startColumnSize" value="200"/>
        </af:pageTemplate>
      </af:form>
    </af:document>
  </f:view>
  <!--oracle-jdev-comment:preferred-managed-bean-name:Viewcriteriabackingbean-->
</jsp:root>output:
its returning the filtered records based on deptid and sal after removing view criteria its not returning the all the records its returns filtered records only.
Edited by: user13385388 on Jan 25, 2011 1:58 AM

Similar Messages

  • Is it even possible to dynamically apply view criteria in an ADF Web App?

    This is one of those situations where something that should take an hour ends up taking days.
    * I have a view.
    * The view has Bind Variables associated with it.
    * The view has View Criteria associated with it.
    * Each of the View Criteria use different Bind Variables.
    * I have a search criteria input page that receives from the user what will ultimately be used to set the bind variables.
    * I have a search results page that uses the view to display a table.
    * I have the code that dynamically sets view criteria and parameters. It is based on the following:
    http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcadvvo.htm#BCGFHAGA
    * This code works great, until the iterator associated with the table binding to the view is initialized. At that time, the view is reset to its defaults, and all of my code's doings are discarded. How do I know this? Because I have gone so far as to run my code that sets view criteria and binding variables dynamically in a phase event handler for the search results page in the render response phase. There is no other point at which to dynamically modify the view.
    This is turning into a situation where it seems I will need 5 different views and 5 different pages in order to show a single set of query results. I cannot get dynamically applied view criteria to work in an ADF web app. Has anyone else done it? Can anyone relate to this? Are there any other suggestions before I conclude that it's not possible for this framework to handle this simple scenario?
    Thanks

    There must be a setting or something that I am still missing here. If I write code just like this and make sure it is executed, I still only see the results of my view executed without the view criteria applied using the default bind variable values that I supplied in the view object.
    It's like the fact that I set the bind variables, the view criteria, and executed the view query programmatically is lost on the iterator -- it's like it never happened. What setting is used to ensure that the iterator uses the outcome of what I executed programmatically? There has to be a critical set or setting that I am missing.
    Here is the iterator and search region definitions defined in the page def "executables" section:
      <executables>
         <iterator Binds="CustomSearchView1" RangeSize="25"
                  DataControl="AppModuleDataControl"
                  id="CustomSearchView1Iterator"/>
        <searchRegion Binds="CustomSearchView1Iterator"
                      Customizer="oracle.jbo.uicli.binding.JUSearchBindingCustomizer"
                      id="CustomSearchView1Query"/>
        </executables>Here's the "tree" binding in the page def file:
      <bindings>
       <tree IterBinding="CustomSearchView1Iterator" id="CustomSearchView1">
          <nodeDefinition DefName="Model.CustomSearchView" Name="CustomSearchView10">
            <AttrNames>
              <Item Value="CustomId"/>
              <Item Value="CustomProjectNumber"/>
              <Item Value="CustomName"/>
              <Item Value="CustomStatus"/>
              <Item Value="CustomStatusDate"/>
            </AttrNames>
          </nodeDefinition>
        </tree>
      </bindings>In an effort to take page flow out of this mess, I had modified this to include the search criteria and search results on a single page. So, I now have a "Search" button. When the "Search" button is clicked, the action method does the following:
        public String searchActionListener ()
              // Get search criteria from select one choice and text input controls.
              AppModule appModule =
                    ( AppModule ) Configuration.createRootApplicationModule (
                        "Model.AppModule",
                        "AppModuleLocal");
              appModule.customSearch( searchCriteria1,
                                                   searchCriteria2,
                                                   searchCriteria3 );
        }In my application module this translates to:
        public void customNoticeSearch ( String searchCriteria1, String searchCriteria2, String searchCriteria3)
           CustomSearchViewImpl searchViewImp =
               ( CustomSearchViewImpl ) this.getCustomSearchView1 ();
           searchViewImp.customExecuteQuery ( searchCriteria1, searchCriteria2, searchCriteria3);
        }Finally, in my custom view object implementation code:
        public void customExecuteQuery ( String searchCriteria1, String searchCriteria2, String searchCriteria3 )
            // Set-up the parameters that are part of the core query.
            this.setp_searchCriteria1( searchCriteria1);
            this.setp_searchCriteria2( searchCriteria2);
            if ( searchCriteria3 != null )
                ViewCriteriaManager vcm = this.getViewCriteriaManager();
                ViewCriteria vc = vcm.getViewCriteria ( "WithLastCriteria" );
                this.setp_searchCriteria3( new Number ( searchCriteria3 ) );
                this.applyViewCriteria( vc );
            System.out.println ("This is fun.");
            this.executeQuery();
        }This code executes, but the results table is empty, and I know that there are results, because I can execute use execute with params to execute the base query and get the correct results back.
    Thanks for taking a look at this.

  • Apply View criteria at runtime to child View object

    Hi,
    I am facing issues while trying to assign View Criteria to child VO that is part of View hierarchy at runtime.
    AM Model:
    Parent VO ->
    Child VO1
    -> Child VO2
    View Link between :
    Parent VO -> Child VO1
    Child VO1 -> Child VO2
    I have to apply View criteria at runtime at Child VO1 & Child VO2, i tried setApplyViewCriteriaName from AMImpl for these VO but that doesnt work.
    It works for Parent VO, So I concluded Apply VC doesnt work directly for Tree structure.
    I then override executeQueryforCollection in the VO however i am never able to get the handle for the VO that is getting executed :
    Here's what is happening when i fetch my VO tree from AM :
    - Parent VO , Child VO are getting instantiated
    - Parent VO executeQueryforCollection called
    - ** After this a new instance of Child VO is getting instantiated and i dont have any control of setting the VC based on some custom property
    as all get defaulted at this point.
    Please suggest what can be done in this case.
    PS : i can not hardcode the VC condition at View Link.
    - Sam

    I was able to set the VC condotinally based on property set at Parent level using following code in executeQueryForCollection :
    ApplicationModule am= this.getApplicationModule();
    ViewObject vo = am2.findViewObject("ParentView1");
    prop = (String)vo.getProperty("Parent_prop");
    if(propVo_prop.equals("Y"))
    this.setApplyViewCriteriaName("VC");
    super.executeQueryForCollection(object, object2, i);
    is this the right way ? Any performance bottleneck ? This service can be called for 1000 Id's .
    Please suggest if there is some better way.
    Thanks
    -Sam

  • Including additional where clause conditions to view criteria dynamically

    Hi,
    We have a set of view objects that serves as LOV for various other view objects. All such LOV view objects have three specific attributes, two date attributes namely EffectiveStartDate, EffectiveEndDate and a String attribute namely UserSwitch based on which the LOV list needs to be filtered.
    All the view objects are having one or more view criterias with specific where clause conditions.
    Apart from those view criteria conditions, invariantly, we need the following conditions also
    :bindEffDate between EffectiveStartDate and EffectiveEndDate and UserSwitch = :bindUserSwitch.
    We wish not to include the above condition in each and every view criteria of each and every view object (Since we have around 800 view objects and a minimum of 2 view criterias per view object). Instead, we created a dummy view object (BaseViewObject) with two bind variables :bindEffDate and :bindUserSwitch and all the LOV view objects were made to extend this BaseViewObject.
    Therefore, whenever a view object atribute is attached with LOV using the above said LOV View Objects, the bind variables of the baseViewObject as well as the view object specific bind variables are available in the view accessors tab of the view object wizard where we can supply values to those bind variables.
    Now, we need to construct the view criteria filter clause. To achieve this, we created a class, CustomCriteriaAdapter.java extending oracle.jbo.server.CriteriaAdapterImpl. In the getCriteriaClause() method, we included the follwoing code:
    public String getCriteriaClause(ViewCriteria pViewCriteria)
    ViewObject vo = pViewCriteria.getViewObject();
    String userSelectSwitch = (String) vo.ensureVariableManager().getVariableValue("bindUserSwitch");
    String effBgnDt = vo.getAttributeDef(vo.getAttributeIndexOf("EffectiveStartDate")).getName();
    String effEndDt = vo.getAttributeDef(vo.getAttributeIndexOf("EffectiveEndDate")).getName();
    String customCriteria = " ( :bindEffDate >= " + effBgnDt + " ) AND ( :bindEffDate <= " + effEndDt + " OR " + effEndDt + " IS NULL ) ";
    StringBuffer completeCriteria = new StringBuffer();
    String criteriaClause = super.getCriteriaClause(pViewCriteria);
    if (criteriaClause != null && !criteriaClause.isEmpty())
    completeCriteria.append(criteriaClause + " AND ");
    completeCriteria.append(customCriteria);
    if (userSelectSwitch != null && "Y".equals(userSelectSwitch))
    String userSelectSw = vo.getAttributeDef(vo.getAttributeIndexOf("UserSwitch")).getName();
    completeCriteria.append(" AND (" + userSelectSw + "='Y' ) ");
    return completeCriteria.toString();
    Issues:
    The LOV list is not filtering the records based on the constructed conditions. Instead it is listing either all of the records considering only the view criteria conditions applied at design time irrespective of the userswitch and effectivedate conditions or the list is empty.
    Here, my questions are,
    1. Am I in the correct approach? If not, guide me in a more proper approach to achieve the same requirement.
    2. If the way I am trying is correct, where things are going wrong and why the dynamic condition is not getting effected?
    Kindly help in sorting out the issue.
    Thanks in advance.

    Hi Jobinesh,
    Thanks for your response and yes, we have done exactly as what you have mentioned. As explained earlier, a baseViewObject along with its Impl class has been created and it will be extended by all the viewobjects meant for serving LOV. Therefore, the superClass for any such LOV viewObject is the baseViewObjectImpl class. In that baseViewObjectImpl(), we have over-rided the criteriaAdapter() method and returned an instance of our customCriteriaAdapter() class.
    Below is the code we are using in the baseViewObjectImpl():
    package model.base.vo;
    import oracle.jbo.CriteriaAdapter;
    import oracle.jbo.server.ViewObjectImpl;
    public class BaseViewObjectImpl
    extends ViewObjectImpl
    * This is the default constructor (do not remove).
    public BaseViewObjectImpl()
    * Over-rided method of ViewObjectImpl class of the framework.
    * Calls the customized criteria adapter so that the default where clauses are added to the view criteria.
    * @return CriteriaAdapter.
    @Override
    public CriteriaAdapter getCriteriaAdapter()
    return new CustomCriteriaAdapter();
    I'll create a sample in HR schema and share with you shortly.
    Thanks and regards.

  • Issue while applying View Criteria

    Hi all,
    We have a taskflow which has View Criteria as the input parameter.
    When the taskflow is invoked, the View Criteria is set in the pageFlowScope.
    Requirement is that we need to apply this view criteria to a View object.
    When we applied the view criteria to the View object and executed the query, an SQLException is being thrown
    (Missing IN or OUT Parameter at index::1)
    In the ManagedBean's method, verified if the view criteria has bindVariables:
    VariableValueManager variableValueManage = vc.ensureVariableManager();
    System.err.println("Name :"+variableValueManage.getVariableValue("pName"));
    Confirmed that the bind variable is carrying the appropriate value.
    This View Criteria when applied to the corresponding VO and executed, java.sql.SQLException is thrown:
    ViewObjectImpl testVO = gettestVO() ;
    ViewCriteriaManager vcm = testVO.getViewCriteriaManager();
    vcm.applyViewCriteria(quickSearchViewCriteria);
    testVO.executeQuery();     
    Exception: java.sql.SQLException: Missing IN or OUT parameter at index:: 1     
    In the query, the bind Variable "pName" is not binded, though the view criteria has the value.
    Thanks in advance,
    Raghu

    Hi all,
    We have a taskflow which has View Criteria as the input parameter.
    When the taskflow is invoked, the View Criteria is set in the pageFlowScope.
    Requirement is that we need to apply this view criteria to a View object.
    When we applied the view criteria to the View object and executed the query, an SQLException is being thrown
    (Missing IN or OUT Parameter at index::1)
    In the ManagedBean's method, verified if the view criteria has bindVariables:
    VariableValueManager variableValueManage = vc.ensureVariableManager();
    System.err.println("Name :"+variableValueManage.getVariableValue("pName"));
    Confirmed that the bind variable is carrying the appropriate value.
    This View Criteria when applied to the corresponding VO and executed, java.sql.SQLException is thrown:
    ViewObjectImpl testVO = gettestVO() ;
    ViewCriteriaManager vcm = testVO.getViewCriteriaManager();
    vcm.applyViewCriteria(quickSearchViewCriteria);
    testVO.executeQuery();     
    Exception: java.sql.SQLException: Missing IN or OUT parameter at index:: 1     
    In the query, the bind Variable "pName" is not binded, though the view criteria has the value.
    Thanks in advance,
    Raghu

  • Applying view criteria to LOV programmatically in ADF UI

    Hi,
    I have a LOV defined in model on VO. I want to populate this LOV programmatically based on some view criteria.
    How can I do this?
    Thanks
    - Harish

    Hi.
    Welcome to OTN.
    Check this http://www.oracle.com/technetwork/developer-tools/adf/learnmore/44-restrict-lov-169186.pdf

  • ADF View Criteria on a Read Only View Object

    Hi,
    I have created a read only view object using a query. The query consists of analytical functions to fetch the AVG values dynamically.
    So far my approach worked fine.
    I want the Average values in my query to be calculated dynamically based on the certain view criteria.
    But after applying view criteria, my query is formulated as shown below:
    SELECT * FROM (SELECT   RECEIVED_YEAR,
               WEEK_NO,
               NO_RECEIVED,
               NO_STARTED,
               ROUND (TO_NUMBER (REPLACE (AVG_HRS_TO_START, ':', '.')),2) AVG_HRS_TO_START,
               ROUND (AVG (TO_NUMBER (REPLACE (AVG_HRS_TO_START, ':', '.'))) OVER (ORDER BY RECEIVED_YEAR),2)              OVERALL_AVG_HRS,
               GOAL_HRS,
               ROUND (AVG (NO_STARTED) OVER (ORDER BY RECEIVED_YEAR), 2) AVG_NO_STARTED,
               ROUND (AVG (NO_RECEIVED) OVER (ORDER BY RECEIVED_YEAR), 2) AVG_NO_RECEIVED
               FROM ORDERS_RCPT_TO_START_VW
    ORDER BY RECEIVED_YEAR, WEEK_NO) QRSLT  WHERE ( ( ( ( (RECEIVED_YEAR = :RecdYear ) AND (WEEK_NO <= :weekNo ) ) ) ) )
    As per this query, it is calculating the Average values first and then applying filter criteria rather than applying the filter criteria and calculating average values.
    Please help me on this.

    Entity objects are used to update/delete/insert data to the database.
    If all your base DB object offers is read then just create a read only view object.

  • Search Page question - view criteria

    Guys,
    I am in the process of creating a search page. I need to change the search criteria on the page load. is it possible? (is this good practice to change view criteria dynamically of the search page or is it s good practice to create different search pages for each view criteria?)
    Little more detail:
    In entity edit page user selects the process---> based on the process i need to apply search criteria (before search page loads) --> user selects the entity and i need to show confirm message before calling stored procedure.
    Thank you guys in advance...
    -Raj

    polo wrote:
    I am in the process of creating a search page. I need to change the search criteria on the page load. is it possible? (is this good practice to change view criteria dynamically of the search page or is it s good practice to create different search pages for each view criteria?)If you want to apply criteria values, this is OK. How do you navigate to the search page? Usually you have an initialization method that runs before the page is displayed. In the initialization method you apply the criteria values and you execute the View object query.

  • View Criteria issue on ADF Tree

    Hi,
    JDev 11.1.1.5.0
    I am facing an issue while displaying ADF tree. I've created ParentVO & ChildVO from a single table with view criteria to filter the nodes.And then created two View links ParentToChild & ChildToChild.
    Added VOs & corresponding ViewLinks to ApplicationModule. When I tried to run application module, getting the results as per expectation (applying view criteria at each level).
    Now i've dragged the parent vo from data control on to jspx page. when I run the jspx page, it's displaying the tree structure.
    Issue is only view criteria is applying for top level nodes(parent VO) but not sub levels. If there is some issue with creation of View criteria then it should give same problem while executing AM. But while running AM, getting the expected results.
    It would be great if you provide any clue on this issue
    Thanks,
    Samba

    Thanks for your response.
    But my usecase is different. I need to filter the sublevels of the tree.
    Following is the sample
    Level1
         Level1.1
         Level1.2
         Level1.3
    Level2
         Level2.1
         Level2.2
         Level2.3
         Level2.4
    Level3
         Level3.1
         Level3.2
         Level3.3
    If I gave View Criteria as contains '2' then, Need to filter the nodes contains character 2. Able to filter first level nodes according VC. But VC is not applying for sub levels. Is there any way to set the VC in my case?

  • View Criteria

    Hi,
    I am new to adf exploring by doing one POC ,my requirement is, i need to call the application module impl through backing bean to search based on 2 inputs form DB table and the result set i need to store into session.
    for this i wrote view criteria and how to call
    I need to get through backing bean
    this i wrote in VOImpl class under one method which i am calling from Application module impl class
    Proj_name and PA_name are bind variables of View criteria in VOimpl class(Generated View Object class)
    ViewCriteria vc =getViewCriteria("ProjectViewObjVOCriteria");
    setPA_name(ProjName);
    setProj_name(PANumber);
    applyViewCriteria(vc);
    executeQuery();
    error :oracle.jbo.InvalidObjAccessException: JBO-25036: An invalid object operation was invoked on type View Object with name ProjectViewObjVOImpl_19 at first line( setPA_name(ProjName);) setting in above stmts
    is it correct what i m doing? if not can anyone guide me in this
    Thanks in advance
    Praveen
    Edited by: user13584306 on Feb 6, 2012 3:20 AM

    hi,
    just go through the links
    http://udayarocks.wordpress.com/2011/06/08/how-to-reuse-a-view-object-vo-for-different-search-criteria-in-multiple-pages-in-adf/
    Set the view criteria bind variable from backing bean
    http://adfpractice-fedor.blogspot.in/2011/08/how-to-apply-view-criteria.html
    regards,
    Ranjith

  • How to reset view criteria in transient view object

    Hi,
    I have a view object with one transient attribute:
    ViewCriteria vc = null;
    ViewCriteriaRow vcRow = null;
    ViewObject vo = am.findViewObject("TestView");
    vo.setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);
    Row newRow1 = vo.createRow();
    newRow1.setAttribute("TestAttr", new Number(10));
    vo.insertRow(newRow1);
    Row newRow2 = vo.createRow();
    newRow2.setAttribute("TestAttr", new Number(20));
    vo.insertRow(newRow2);
    ViewCriteria vc = null;
    ViewCriteriaRow vcRow = null;
    vc = vo.createViewCriteria();
    vc.setCriteriaMode(ViewCriteria.CRITERIA_MODE_CACHE);
    vcRow = vc.createViewCriteriaRow();
    vcRow.setAttribute("TestAttr", new Number(10));
    vc.addElement(vcRow);
    vo.applyViewCriteria(vc);
    vo.executeQuery();
    System.out.println("Rows: "+vo.getEstimatedRowCount());  // Works as expected
    vo.getViewCriteria().resetCriteria();  // This code should reset view criteria
    vc = vo.createViewCriteria();
    vc.setCriteriaMode(ViewCriteria.CRITERIA_MODE_CACHE);
    vcRow = vc.createViewCriteriaRow();
    vcRow.setAttribute("TestAttr", new Number(20));
    vc.addElement(vcRow);
    vo.applyViewCriteria(vc);
    vo.executeQuery();
    System.out.println("Rows: "+vo.getEstimatedRowCount());  // Returns 0 rows - should return 1How to reset and apply view criteria ?

    try to remove the previously view criteria. ie
    ViewObjectImpl vo = this.getSomeViewObject();
    ViewCriteria vc = vo.getViewCriteria("criteria_name");
    vo.removeViewCriteria("criteria_name");
    vc.resetCriteria();
    vo.applyViewCriteria(vc);
    see the link below
    http://adfcodebits.blogspot.com/2010/04/bit-7-reseting-view-criteria-associated.html

  • How to apply common View criteria for all LOV View programatically?

    Hi,
    In my application I use nearly 100 VOs, which will be mapped as LOV to some base VOs. These VOs are not only for LOV but also will be used directly in screen as read-only table. All these VOs contains EFF_BGN_DTand EFF_END_DT. Requirement is to display only the active records in VO.
    We don't want to crete view criteria at design time for each and every VO. Instead we want to have a base ViewObjectImpl class, create at runtime and add this common criteria with the existing view criterias (If any given, which are actually required for the developer for screen specific functionality).
    NOTE: As all of our VOs are custom java data source implemented and none of them have queries, we cannot use whereclause API but only ViewCriteria.
    We want to create a view criteria, that somewhat looks like the below condition.
               (     (TO_CHAR( EffBgnDt, 'yyyy-mm-dd') <= '2010-02-01' )
                 AND (TO_CHAR( EffEndDt, 'yyyy-mm-dd') >= '2010-02-01' )
                 OR
               (     (TO_CHAR( EffBgnDt, 'yyyy-mm-dd') <= '2010-02-01' )
                 AND (EffEndDt IS NULL )
               )Question:
    1. Which is the best place in ViewObject class, where I will be able to create common view criteria, include it with existing criterias.
    Thanks in Advance.
    Raghu

    No it is not working. I've tested. When i test your implementation in my sample using AM tester, it is not at all going inside getCriteriaItemClause(ViewCriteriaItem pViewCriteriaItem). For example when i say, AM.findViewObject(String ViewObjectName), followed by getEstimatedRowCount(), it should apply common filter criteria and give me the result.
    Given below required scenario:
    Department table:
    ID     DEPT_NAME     START_DATE     END_DATE
    1     Hr          1-Jan-2010     
    2     Purchasing     1-Jan-2010     31-Dec-2010
    3     Shipping             1-Jan-2010     31-Dec-2055
    4     Sales          1-Jan-2010     
    Common criteria to be applied (Programatically) : :bind_current_date between StartDate and EndDate or :bind_current_date >= StartDate and EndDate is null
    VO specific view criteria (may vary VO to VO): DeptName not equal to 'Sales'
    Expected Result:
    Case 1:
             a. DeptView = AM.findViewObject("DepartmentVO")
             b. DeptView.getEstimatedRowCount()
              It should give me 3 records (Hr, Shipping, Sales)
    Case 2:
             a. DeptView = AM.findViewObject("DepartmentVO")
             b. Create View Criteria 'NotSalesDeptVC', which should not list out Sales department.
             c. Apply NotSalesDeptVC using RowSet rowSet = (RowSet) this.findByViewCriteria(NotSalesDeptVC, -1, ViewObject.QUERY_MODE_SCAN_VIEW_ROWS)
             d. rowSet.getEstimatedRowCount()
              It is in-memory filtering, will not disturb the default rowset, should give me 2 records (Hr, Shipping)
    Case 3:
             a. DeptView = AM.findViewObject("DepartmentVO")
             b. Apply 'NotSalesDeptVC' to the default row set, followed by executeQuery
             c. DeptView.getEstimatedRowCount()
              It should give me 2 records. (Hr, Shipping)
    Case 4:
             a. DeptView = AM.findViewObject("DepartmentVO")
             b. Unapply the applied 'NotSalesDeptVC', followed by executeQuery
             c. DeptView.getEstimatedRowcount()
              It should give me 3 records (Hr, Shipping, Sales)Essence is at any point of time, User should always work with active records. He no need to write extra logic to retrieve only the active records but the base Viewobject impl should have. Note, All of my view objects are custom java data source implemented and not query based. Similarly it does not meant that all of my VOs will be having some business specific View criteria. Some VOs may have. Some VOs may not have. However basic active records criteria is applicable for all VOs

  • Dynamic Region:VO with a view criteria does not filter data

    Hi all,
    I am using Jdeveloper 11.1.1.0
    I have a page with two section: the first section contains a table, the second contains a region that changes depending on the row choosed in the table of the first table.
    Starting from a VO a I have defined some view criterias and in my application module I have created some data control components based on that VO and those view criterias.
    So, in my application module, I have a components for every view criteria defined in the VO.
    In every fragments visualized in the dynamic region I have a table derived from a view object derived from view criterias defined before.
    The problem is that in the fragment I always see all the data and not filtered data.
    Instead, if I run my application module, in those view objects, I see the filtered data.
    I have noted that (after dragging and dropping the component to the fragment) in the "Bindings" schede, in "Executable" editing myVOFilteredQuery, the field "Criteria" is empty.
    Is this the problem? How have I to fill it?
    Or the problem is another?
    Thank you so much
    Andrea

    This issue is fixed.
    Thanks and Regards
    Sameer

  • Applying distinct to a query search panel view criteria

    I have a VO that returns multiple instances of the same project code...In the ADF query panel I only need to display a distinct set of these project codes...
    When building a simple ADF query panel based on a view criteria declaratively the project codes will repeat themselves in the select one choice component of the query panel.
    What is the best way to apply a distinct to a view criteria of this sort?
    Thanks in advance.

    Hi
    Edit query- Select Sql Mode to "Expert" and manually change the query.
    M Niaz

  • Applying different view criterias to af:query based different situations

    Hi all;
    Lets say i have 3 different view criterias ....and i want to apply only one of them to af:query based user's role....
    I dont have an idea how to do that...My only clue is my supervisor mentioned to me i can use page definition to do that;
    <searchRegion Criteria="DepartmentViewCriteria" Customizer="oracle.jbo.uicli.binding.JUSearchBindingCustomizer"
                      Binds="DepartmentView1Iterator" id="DepartmentViewCriteriaQuery"/>Can u help me on this matter please!
    If post is too shallow to understand i can elaborate more...
    jDeveloper 11.1.2.1.0
    Oracle DB 11g

    Create a custom public method in yr applicationmoduleImpl class. Get the viewcriteria of target vo or programmatically create yr viewcriteria.
    Based on current loggedInUser role which can be access by ADFContext.getCurrent().getSecurityContext().getUserRoles(), u can apply specific viewcriteria on VO.
    After that u can follow this link - http://dstas.blogspot.com/2010/09/adf-11g-methodaction-and-invokeaction.html, from +"We will now expose the method in the client interface of the AM"+ teopic.
    At the end u will be able to execute this method from pagedef file, whenever u enter to this page.
    Hope this helps.

Maybe you are looking for

  • Mobile Accounts: Manual Sync works, Automated Sync Does Not

    I've got a small office network with about 10 users. Each have mobile accounts under Tiger (server and clients) and they've been working flawlessly for years. All of a sudden we've noticed that for some users the background sync is no longer working.

  • Help with a year planner.

    Hi there, I've been trying to create a year planner and been advised to use zellers algorithm to ensure the correct date is placed in each cell of the planner. the algorithm given was: IF M is january or M is february add 12 onto the M subtract 1 fro

  • OS 10.4  disk 2 install problem on mother inlaws mac mini

    The installation OS 10.4 disk 1 went ok but disk 2 would not mount. Called apple care and they sent me a replacement for disk 2. When I mounted the replacement disk 2 it said to insert disk 1 to install "OSX and the bundled software". Are they tellin

  • How to set mozilla firefox homepage for all users in windows 7?

    I want to set same homepage for all users in windows 7.

  • Data template - no xml data?

    Hello, I have a data template that does not seem to want to display my data. I am at a loss as to why… The select works and returns the data correctly. Data I get when I run the select is from SQL Developer: 01-JAN-08     Hourly     1155     31     0