ViewCriteria and setWhereClause

Hello guys,.

I use Jdeveloper 11.1.2.3.0

I have a ViewObject where I added a view control so I can create an af:query

at runtime, I add a where clause using VO.setWhereClause () and VO.defineNamedWhereClauseParam () clause

When do the new NamedParam appear in the af: query

so my question is how to solve this problem, I want the af: query to stay as it is

concerning

Mount VariableImpl, something like:

VariableImpl vr = (VariableImpl)vvm.findVariable("idArray");
vr.setProperty(VariableImpl.ATTRIBUTE_DISPLAY_HINT, VariableImpl.ATTRIBUTE_DISPLAY_HINT_HIDE);

One last thing, you should probably use VO.ensureVariableManager () instead of VO.getVariableManager)

Dario

Tags: Java

Similar Questions

  • Exception when using setWhereClause()

    Hello

    I use JDeveloper 11.1.2.3

    I need to get a row in the Dattabse table.

    To do this, I put the WHERE clause in the VO using the setWhereClause (String) method.

    Where clause looks almost like

    setWhereClause("Companyid = '"+getCompanyId()+"' and CustomerGroupName like 'Elite' ");
    

    while I try to run the application, his throw and error as:

    oracle.jbo.SQLStmtException: Houston-29114 ADFContext is not configured to process this exception messages. Use the code of exception stack trace and error to investigate the root cause of this exception. Root cause error code is Houston-27122. Are parameters of error message {0 = SELECT * FROM (SELECT * FROM OFFERRULE) QRSLT WHERE (Companyid = "01616C8F-4430-4F11-9257-B23626C50E99") and CustomerGroupName as 'élite'}

    Why is this happening?

    Kind regards

    Nigel.

    Nigel,

    the error you got is only the analytical error. There is an error detailed in the journal a place that tells you exactly what the problem is (for example table or view does not exist). The summary shows you the statement sql has a problem, so an action you should do is copy the statement and run it from a sql inside jdev worksheet. See is the instruction

    SELECT * FROM (SELECT * FROM OFFERRULE) QRSLT WHERE (Companyid = "01616C8F-4430-4F11-9257-B23626C50E99") and CustomerGroupName as 'élite'

    runs without problem.

    Next step is that you must not build your own where clause. To do this, you must use a ViewCriteria and apply the criteria of the vo, when you need to get the data.

    Timo

  • Strange ORA-01722: invalid number on viewCriteria

    Hello

    I defined in jDev 11.1.1.5 do with viewCriteria and everything works until I have migrate jDev 11.1.1.6. Now, I get this exception run this view

    < Utils > < buildFacesMessage > ADF: addition of the JSF error message: ORA-01722: invalid number

    java.sql.SQLSyntaxErrorException: ORA-01722: invalid number

    After a few experiences, I found that this problem is viewCriteria, which is not so simple. It is used with condition NOT IN subquery.

    (P_P_ID_FK NOT IN (SELECT P_ID of P where NVL (VALID_FROM, CURRENT_DATE) < = CURRENT_DATE))

    I know that DOESN'T look good is not standard in ADF viewCriteria, but SQL work well. So tell me why there at - it SQLSyntaxErrorException!

    When I remove that part or AppModule viewCriteria viewCriteria, then everything works.

    Exception disappear even when I move the condition NOT IN with the main request viewCriteria subquery.

    I tried to rewrite viewCriteria using NOT EXISTS, but there is no possibility of query from same table due to the inability of aliasing table names.

    You have a work around?

    Thank you.

    Problem is resolved declaratively by manual editing of XML view this tutorial Andrejus Baranovskis Blog: implementation of criteria seen in Colombia - British ADF

  • Apply ViewCriteria not added to the request

    JDeveloper 11.1.2.2

    I have a ViewCriteria which is supposed to be applied to a ViewObject, but I get an error "attempt to define a parameter name that does not intervene in the sql code.  I know that the ViewCriteria is applied, but for some reason, the 'criteria' in the ViewCriteria are not added to the query that is sent to the database.

    Here's the method where the error occurs:

    public List<SelectItem> getCategorySelectItems()
        {
            categorySelectItems = new ArrayList<SelectItem>();
            
            BindingContainer bindings = ADFUtils.getBindingContainer();
            DCIteratorBinding dcIteratorBinding = (DCIteratorBinding) bindings.get(ITERATOR_NAME_CATEGORY_SITEID_PHASEID);
            MytrainCategoriesVOImpl mytrainCategoriesVO = (MytrainCategoriesVOImpl) dcIteratorBinding.getViewObject();
            
            mytrainCategoriesVO.setbind_SiteId(GuidoUtils.getSelectedSiteId());        
            mytrainCategoriesVO.setbind_PhaseId(selectedPhaseId);
            
            ViewCriteriaManager vcm = mytrainCategoriesVO.getViewCriteriaManager();
            String[] vcs = vcm.getApplyViewCriteriaNames();
            for(String vcname : vcs){
                logger.finer("Applied ViewCriteria: " + vcname);
            }
            
            mytrainCategoriesVO.executeQuery();
            
            while(mytrainCategoriesVO.hasNext())
            {
                MytrainCategoriesVORowImpl mytrainCategoriesVORow = (MytrainCategoriesVORowImpl) mytrainCategoriesVO.next();
                SelectItem newSelectItem = new SelectItem(mytrainCategoriesVORow.getCategoryId(), mytrainCategoriesVORow.getTitle());
                categorySelectItems.add(newSelectItem);
            }
            
            return categorySelectItems;
        }
    

    The debugging part where I write on the getApplyViewCriteriaNames() shows that the criteria of the "site_id" and "phase_id" applies, but does not query SQL that is sent to the server contain the ' where phase_id =: bind_PhaseId "section, even if the query contains the" where site_id =: bind_SiteId "section.

    Any ideas why it would apply a ViewCriteria, and not the other, even if the ViewCriteriaManager said that the two criteria are applied?

    One problem I have seeIs you do all this in the view controller, while you should do it in the model layer. Depending on how the view criteria is build (ignore nulls, required binding variable) the sql generator fails to messages of where clause.

    What might happen is that one of your bind variables are set to null without your knowledge. To be sure that your variables are set correctly, you must save the message to the executeQuery method. an example on how to do this can be found here http://wp.me/pcBZk-2d

    Third method exports the query and its parameters.

    Timo

  • Trying to keep the search criteria in the session and stubborn taskflow outdoors

    I have a page within a delimited taskflow on which the user can search. I use ViewCriteria and af:query.
    I can get the taskflow anytime, but when I return to my search criteria are still empty. I don't want to. I tried the following:

    a custom queryListener that calls saveState() so that we remember the search criteria (I also put a boolean session to remember whether there were non-empty search criteria):
    <af:query id="qryId1" disclosed="true" 
                              model="#{bindings.StandaardFilterQuery.queryModel}"
                              value="#{bindings.StandaardFilterQuery.queryDescriptor}"
                              queryListener="#{reinigingsRechtBean.onQuery}"
                              queryOperationListener="#{reinigingsRechtBean.processQueryOperation}"
                              displayMode="compact" headerText="blaaa" 
                              resultComponentId="::t1"
                              visible="#{reinigingsRechtBean.showFilter}" 
                              saveQueryMode="hidden" styleClass="querypanel"
                              maxColumns="1">
    public void onQuery(QueryEvent queryEvent) {
            // zet het filter standaard op nonactief
            filterActief = false;
    
            QueryDescriptor queryDescriptor = queryEvent.getDescriptor();
            DCBindingContainer bc = FacesUtils.getBindings();
            Object execBinding = bc.findExecutableBinding("StandaardFilterQuery");
            ViewCriteria vc =
                JUSearchBindingCustomizer.getViewCriteria((DCBindingContainer)execBinding,
                                                          queryDescriptor.getName());
            Variable[] variables = vc.getVariableManager().getDeclaredVariables();
    
            //         loop door de variabelen en kijk of er 1 een waarde heeft.
            //         zoja dan markeren we het filter als actief.
            //         kunnen we dat aan de gebruiker melden
            for (Variable o : variables) {
                System.out.println(o.getColumnName());
                System.out.println(vc.getVariableManager().getVariableValue(o));
                if (vc.getVariableManager().getVariableValue(o) != null) {
                    filterActief = true;
                }
            }
            // raarheid, deze methode wist de waardes die we hierboven uitlezen.
            // dus niet boven de loop zetten want daar zie je ze dan niet meer
            vc.saveState();
    
            
            // voer nog wel de query uit, anders krijg je geen gegevens :)
            FacesUtils.invokeMethodExpression("#{bindings.StandaardFilterQuery.processQuery}",
                                              Object.class, QueryEvent.class,
                                              queryEvent);
    
        }
    That part works. I leave the taskflow and enter again and see my values. Yay! This feature breaks the "reset" button but reset() goes into its last saved state. I want to "reset" to clear the values and research. So I created this:
        public void processQueryOperation(QueryOperationEvent event) {
            if (event.getOperation().equals(event.getOperation().RESET)) {
                QueryDescriptor queryDescriptor = event.getDescriptor();
                DCBindingContainer bc = FacesUtils.getBindings();
                Object execBinding =
                    bc.findExecutableBinding("StandaardFilterQuery");
                    ViewCriteria vc =
                        JUSearchBindingCustomizer.getViewCriteria((DCBindingContainer)execBinding,
                                                                  queryDescriptor.getName());
                    Variable[] variables =
                        vc.getVariableManager().getDeclaredVariables();
                    for (Variable o : variables) {
                        vc.getVariableManager().setVariableValue(o, null);
                    }
                    
                    //JUSearchBindingCustomizer.applyNamedCriteria(bc, queryDescriptor.getName());
                    // saveState() hoeven we volgens mij niet uit te voeren want de onQuery zal ook afgaan en die doet een saveState()
                    vc.saveState(); // toch maar wel
                    FacesUtils.getRRAppModuleImpl().getMoeReinigingsRechtRO().applyViewCriteria(vc);
            }
        }
    When I press reset, I catch the ViewCriteria, empty values, save the State and even to apply the Victoria Cross to the viewObject. However, the af: query indicates the criteria I entered before AND the search is made to these criteria.
    When I loop through the values of ViewCriteria they all void in the onQuery that is executed immediately after processQueryOperation(), but still it is ignored.

    What I am doing wrong?
    (Jdeveloper 11.1.1.3)

    Wendy,

    Here's one that is generic

        public void onQueryOperation(QueryOperationEvent queryOperationEvent) {
    
            if (queryOperationEvent.getOperation().equals(queryOperationEvent.getOperation().RESET)) {
                QueryDescriptor queryDescriptor =
                    queryOperationEvent.getDescriptor();
                DCBindingContainer bc =
                    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
                Object execBinding =
                    bc.findExecutableBinding("queryEmployeesByDepartmentOrJobIdQuery");
                ViewCriteria vc =
                    JUSearchBindingCustomizer.getViewCriteria((DCBindingContainer)execBinding,
                                                               queryDescriptor.getName());
                Row rw = vc.getCurrentRow();
                String[] attrNames = rw.getAttributeNames();
    
                for (String name : attrNames) {
                    if(rw.getAttribute(name)!=null){
                        rw.setAttribute(name, null);
                    }
                }
    
                vc.saveState();
            }
    
            //--------------------------------------
            FacesContext fctx = FacesContext.getCurrentInstance();
            ELContext elctx = fctx.getELContext();
            ExpressionFactory exprFactory =
                fctx.getApplication().getExpressionFactory();
    
            MethodExpression me =
                exprFactory.createMethodExpression(elctx, "#{bindings.queryEmployeesByDepartmentOrJobIdQuery.processQueryOperation}",
                                                   Object.class,
                                                   new Class[] { QueryOperationEvent.class });
            me.invoke(elctx, new Object[] { queryOperationEvent });
        }
    }
    

    Frank

  • Default value in the object MessageLovInput - with results mapped to fields MessageStyledText

    Have a personalized page of the OPS with a simple LOV entry on this subject (MessageLovInput) for an account number that works very well.   User has entered an account number, the LOV works as it should and when the value is chosen I lovMappings that map a couple of fields result view-only MessageStyledText boxes indicating the name and address that was chosen.  Result - key user Acct # and the name and address appears automatically for the user for reference purposes.

    However, I have an entry point to the screen where I would like to pass a parameter to the account number and have it auto select the LOV for me so that the only 2 display fields are visible.  In my controller page, I put the default account number (accountBean.setValue(pageContext,"12345") and it works EXCEPT that it never fill the results in the only fields of 2 display for the customer does not have the reference except with force, they choose the LOV and select the address.)

    Is it possible to make the LOV "auto-run" at the entrance to the page so if there is an input value it will even act as if user keyed it?  I tried several variations of things of guide to Dev and Google for several hours and must be missing something.

    Here's the Basic code that I have in place (cut down to simplicity)

    PageCO-> ProcessRequest method:

    String acctNumber = pageContext.getParameter ("InputAccountNumber");

    If (acctNumber! = null)

    {

    Lov OAMessageLovInputBean = webBean.findChildRecursive ("AccountNumber");

    lov.setValue (pageContext, acctNumber);

    }

    With just the code above, when the screen lorsque l' ecran commence begins has the InputAccountNumber appropriate in the account number field and correctly displayed.  The other fields only 2 screen remain blank well.  If I make a form submission (PageCO-> ProcessFormRequest), it correctly handles the LOV selection as well.

    I tried to add the code to the stream to instantiate the LOV VO with the appropriate value and it works - selects the LOV properly and has a vo.getRowCount (1) because I expect.  But it's as if she doesn't have the lovMappings to the map screen.

    Any suggestions?

    Objects involved are:

    MessageLovInput (with the region associated with listOfValues, tables and lovMappings, including mappings in Nom_tiers areas and address MessageStyledText)

    LovVO-> query VO Sql Simple that is the query for the LOV (i.e. not based on an EO)

    LovAM-> separate AM which houses the LovVO and is listed on the MessageLovInput

    LovCO-> separate CO which house the PR and PFR for MessageLovInput field

    PageCO-> controller for the page-> code LOV is the room above that sets the value.

    PageAM-> AM for the page-> have you tried including the LovVO in its data model and it set aside.  Have you tried including a reference to the LovAM and removing it - same results

    Got this working.  As aJohny said, I essentially had to manually set the other fields in the PR.  Had to do it in the PR of the PageCO since the LovCO is not called until the user interacts with the specific field of the MessageLovInput.

    For reference, here's a rough description of what I had to do.

    PageCO-> controller of main page in the ProcessRequest method:

    (1) pick up the parameter and done a setValue on the MessageLovInput to the main field of LOV visible by the user.

    (2) calls LovAM to initialize the specific LOV with the input parameter (see section LovAM below)

    (3) calls LovAM to return the LovVO

    (4) Gets the first line of the LovVO and fills the fields of the MessageStyledText (if there is only 1 line returned.  If 0 or 2 + it doesn't fill the dependent fields)

    LovAM-AM for the LOV-> a > code to initialize the LovVO as follows

    (1) Gets the LovVO

    (2) setWhereClause (null) and setWhereClauseParams (null)

    (3) setWhereClause to include the input parameter

    (4) executeQuery

    (5) If no input parameter then it gets just the LovVO and setWhereClause (null) (null) /setWhereClauseParams

    LovCO-> controller of the LOV

    (1) in PR-> call LovAM to initialize the VO with an empty/null input parameter.  This allows user to key in a new account number in the entry field Lov and it works.  In the contrary case, it always binds in the account number which is entered into the page as a parameter.

    This method seems to work after a series of tests.  Seems like overkill for the lovMapping themselves and the feature base LOV all done automatically.  I expect to be able to do something to force the instantiate LOV and do its normal operations.  But I could never get this to work in the PageCO in the ProcessRequest method.

    Thank you

  • ViewObject where Clause SET based on logged in user roles

    Hello Experts

    I have a view object based on a custom query to get distinct values from a table. My requirement is to display the results as a listview. The listview is is filled without any problem. But I need to add a where clause clause the object view based on the user roles.

    I have a method that generates the where clause and returns one string something like "COUNTRIES ('USA', 'UK').

    I created a class of the view object Impl and put WhereClause as below: but where clause is not applied when I run the page. I see everywhere instead of just USA & UK.

    Can you let me know at what time should I set the where the clause?

    SerializableAttribute public class CountriesVOImpl extends ViewObjectImpl {}

    /**

    * This is the default constructor (do not remove).

    */

    public CountriesVOImpl () {}

    this.setWhereClause (getCountries ());

    }

    public String getCountries() {}

    return '('USA', 'UK') COUNTRIES. "

    }

    }

    In class ViewImpl try to replace "executeQueryForCollection" and setWhereClause in this function as:

        protected void executeQueryForCollection(Object object, Object[] object2, int i)
        {
            setWhereClause("COUNTRY in ('USA','UK')");
            super.executeQueryForCollection(object, object2, i);
        }
    
  • [Resolved] menu button

    Hello

    I have a use case where I want a menu bar with the buttons. When you click on have the buttons they should basically filter the table below.

    For example, Menubar, with 3 buttons

    | A | B | C |

    Clicking one of these buttons, it must filter the table below.

    I think I should have a VO with a ViewCriteria and a bindvariable, but I tried so many different things without getting this working, and now I would like to ask if someone can point me to a tutorial that does what I described.

    Thank you

    You can implement the get vo methods that apply the criteria to view just for example filterForYear (year number), you that then filters the vo. This method will expose you to the interface of the client of the vo that makes the method available in the data control.

    You can then drag this method of the data control in the toolbar and create a button here specifying the year you want to filter in the dialog box you get when removing the method.

    This procedure also do you for your other filter criteria.

    My I ask why you do not use the bed in the filter of the table?

    Timo

  • Look up values in the query are retained when a query Panel is used in popup

    We used a panel of popup for the search request. When popup is opened again, the search criteria previous values are preserved. They may not get deleted if pop up attribute of content delivery is lazy not cached. Is it possible to clear these values or is this a bug of frame work?

    This is normal and expected behavior. The query pattern keeps the criteria values, otherwise the query Panel would be empty if you refresh the it by PPR. Depending on the configuration of the ViewCriteria and research underlying link, values can be retained even if you leave the page, and then open the page again.

    If you want to clear the query criteria when you open the context menu, you can implement a PopupFetchListener for the popup. PopupFetchListener runs every time when the popup is open. Here, you can get and to reset the component query programmatically. Check out this blogpost for more details how to reset:

    Binary: Reset and table of search results programmatically

    Dimitar

  • ADF 11 g 11.1.1.6 TreeTable - filter not applied to child VO

    Article http://www.oracle.com/technetwork/developer-tools/adf/learnmore/32-tree-table-from-single-vo-169174.pdf (How to create a picture of the tree to a single object View and how to access selected lines), we can generate a unique view table tree. It works very well. I am building a similar user interface, except that I have a filter (tried to use the view criteria and setWhereClause) and it seems the filter applied only to the next level.

    I tried to force the filter applied also to the child by getting the child iterator in backing bean and apply the same filter, had no change in the result.

    Everyone knows about this problem? If so, please share the best way to solve this problem.

    Thank you

    Hello

    You may need to replace createViewLinkAccessorRS.

    Binary: Research by child attributes on a tree table

  • How not to display variable binding in the query ADF search panel?

    Hello, I use JDeveloper 11.1.2.3.0.

    I have a variable binding in my VO, (* required) that I use in the sql query. I put the value of this variable to link through the groovy expression so I don't have to manually put through my page. It works fine but the problem is that it appears in the query ADF Panel that I created in my page. To do this, I created a ViewCriteria and I've specified to display only 3 (other) fields for the simple search. Apart from the selected 3 variable bind shows here again because its value is set. I tried to remove the ' * required ' of the variable binding in the original Version, but in this case I have problems with my sql query.

    Does anyone know how this variable is not to display in the Panel request ADF?

    Thank you

    Has tried to define the binding to bee hidden variable?

    Controll tips, hint of display = hide

  • AF:query with table

    I use the af: query with table to create a query, but the funny page, is in charge of the query page, the data contained in af:table are not fulfilled automatically. any idea, what the problem is?

    Rgds!

    Hello
    Do you use ViewCriteria to build your af:query with table, if yes, go to your ViewObject, then select your viewCriteria and click edit, and then open the data of the user interface tab, then check the query automatically .

  • Filter the table data

    I use JDeveloper 11.1.1.3.0 and I created a table (as a master / detail) and I can't seem to get the filtering of data enabled for the table captain. I have the property "Filterable" of the column set to true, but can not see the boxes of filtering above each column. However, filtering is displayed for the secondary table.

    How can I get this to work? Or is not possible for a Master table having data filtering?

    Hi Anil,

    Can u please check that your Master ViewObject has viewCriteria and also check if the criteria name mapped in the median file your ViewObject as pageDef below
    ++
    ++

    One also check your master af:table this has now in your JSPX

    + filterModel = "#{bindings." EmployeesViewQuery.queryDescriptor}"queryListener =" #{bindings. " EmployeesViewQuery.processQuery}' filterVisible = 'true ' +.

    Kind regards
    Suganth.G

    Published by: celine on 18 January 2011 09:44

    Published by: celine on 18 January 2011 09:44

  • Recursive tree question

    Hello!

    I made a display with gites SEO link display object, relinquished control of the data on the page, added a rule, selected attributes.
    It works fine, but the tree displays all rows of the tablefirst, because the tree uses a unique view object and query does not limit data because if I limit to select only records of root, children are seen, of course. How to build a recursive tree, while it would initially only the records of root on top?

    Thank you!

    Yes, 1 view object can create a tree model. First of all on the data model for the App Module will be one with ViewCriteria and her child, using the ViewLink you defined for himself, without a viewcriteria.

  • setWhereClause and ViewCriteria fail with an error in the original of the VO contains GROUP BY queries

    I have a display with a defined as query object:

    Select t.text, count (l.tag_id) as the use of tags t taglinks left outer join on t.id = l.tag_id inner join service_requests on l.svr_id = sr group of text sr.svr_id

    I am trying to allow a user to refine the displayed lines by providing additional search criteria.

    1. the approach with setWhereClause


    (contains thenewWhereClause '(sr.problem_description LIKE ' % machine % ") ' )

    this.setWhereClause (newWhereClause);
    this.executeQuery ();

    and it generates a new query as:

    Select t.text, count (l.tag_id) as the use of tags t taglinks left outer join on t.id = l.tag_id inner join service_requests on l.svr_id = sr.svr_id sr Group of text WHERE ((sr.problem_description LIKE '% machine %'))))

    (the problem is that the WHERE clause is behind the GROUP BY clause)

    2. the approach with ViewCriteria


    (the HashSet tgCrit contains a collection of strings)

    ViewCriteria vc = this.createViewCriteria ();
    ViewCriteriaRow vcr;
    Iterator;
    String value;
    It = tgCrit.iterator ();
    While (it.hasNext ()) {}
    value = (String) it.next ();
    VCR = vc.createViewCriteriaRow ();
    vcr.setAttribute ("Text", "LIKE" % "+ value +" %'");)
    vc.insertRow (vcr);
    }
    this.applyViewCriteria (vc);
    this.executeQuery ();

    and it generates a query such as:

    Select t.text, count (l.tag_id) as the use of tags t taglinks left outer join on t.id = l.tag_id inner join service_requests on l.svr_id = sr.svr_id sr Group of text WHERE (((TEXTE COMME: vc_temp_1)))

    (the same problem as before)

    The full background to the question is described in the other thread: Houston-27122 error after setWhereClause vo

    According to the previous thread, you disabled query package then this is the expected behavior (and is not caused by group by clause).

    The packaging of the query is prerequisite for a feature correct ViewCriteria because this allows framework generate something like: select * (your query) WHERE view_criteria_clauses.

    Dario

Maybe you are looking for