Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java View Criteria at runtime - Between Dates

Stuart FlemingApr 5 2016 — edited Apr 7 2016

Jdeveloper 12.1.2

Hi.  I have a requirement to query a bunch of fields (basically create a query screen).  Users select which fields they want.  They may want to select the user field and dates between which this person entered data.

I have the code OK for the last name, but how would I handle the between startDateX and endDateX

vcr1.setAttribute("LastName","Hemant");

I need to do this in java.....no other way, thanks!

Thank you,

Stuart

EXAMPLE I found:

public class TestClientViewCriteria {

public static void main(String[] args) {

String amDef = "devguide.examples.readonlyvo.PersonService";

String config = "PersonServiceLocal";

ApplicationModule am =

Configuration.createRootApplicationModule(amDef, config);

// 1. Find the view object to filter

ViewObject vo = am.findViewObject("PersonList");

// Work with your appmodule and view object here

Configuration.releaseRootApplicationModule(am, true);

// 2. Create a view criteria row set for this view object

ViewCriteria vc = vo.createViewCriteria();

// 3. Use the view criteria to create one or more view criteria rows

ViewCriteriaRow vcr1 = vc.createViewCriteriaRow();

// 4. Set attribute values to filter on in appropriate view criteria rows

vcr1.setAttribute("PersonId","> 200");

vcr1.setAttribute("Email","d%");

vcr1.setAttribute("PersonTypeCode","STAFF");

vcr1setAttribute("PersonId","IN (204,206)");

vcr1.setAttribute("LastName","Hemant");

// 5. Add the view criteria rows to the view critera row set

vc.add(vcr1);

// 6. Apply the view criteria to the view object

vo.applyViewCriteria(vc);

// 7. Execute the query

vo.executeQuery();

This post has been answered by Stuart Fleming on Apr 7 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 5 2016
Added on Apr 5 2016
7 comments
1,661 views