Reputation: 1809
Does anyone know how to filter the calendar events based on a certain property?
For example based on the provider ID or something else. What I want is to have some checkboxes and by checking those the calendar events will display accordingly.
Upvotes: 1
Views: 841
Reputation: 813
Using View Object View Criterias are the best way.
If you want to access the Providers, you can access it through Calendar bindings. Setup the bindings attribute of the Calendar Tag, so it's bound to a backing bean.
private RichCalendar thecal;
//getter and setter for ca
public RichCalendar getthecal() {
return thecal;
}
public void setthecal(RichCalendar calendar) {
this.thecal = calendar;
}
Then you can access the calendar model data (like providers) via getthecal().getValue() to get the CalendarModel object. see here for java reference: http://docs.oracle.com/cd/E14571_01/apirefs.1111/e10684/oracle/adf/view/rich/model/CalendarModel.html
However, I do all my filtering via View Object Attributes and View Criterias. I created a method in my application module implementation class and called it from a button bound to a backing bean action.
Button Action:
//get the application module
DCBindingContainer dcbindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
AppModule am = (AppModule)dcbindings.getDataControl().getApplicationModule();
//Run the filtering logic
am.nameOfYourMethod(PassSomeData,BlahBlah);
AM Method:
//get the view object your calendar uses
CalendarVOImpl voImpl = getCalendarVO();
ViewCriteria vc = voImpl.createViewCriteria();
//Just some name for the view criteria
vc.setName("filterCalendar");
ViewCriteriaRow vcRow = vc.createViewCriteriaRow();
//Set the name of the attribute and the value you're looking to filter by
vcRow.setAttribute("NameOfAttribute", "IN (" + valueFilter + ")");
vc.insertRow(vcRow);
voImpl.applyViewCriteria(vc);
voImpl.executeQuery();
Make sure your have some partial triggers setup to refresh your calendar after this method runs.
Upvotes: 2
Reputation: 1809
I tried to adapt the solution that was implemented in the adf-demo-aplication: http://jdevadf.oracle.com/adf-richclient-demo/faces/components/index.jspx#%2Fcomponents%2Fcalendar.jspx But I found it too complicated, so I found the solution through using ViewCriteria in the ViewObject of the Calendar component. I created three bind variables and I created a ViewCriteria that would display those events with provider equal to each of them ("OR" related). Then I created a method in my VOImpl class and I bound it in my calendar page. On Button click then I executed the ViewCriteria with desired values on different cases.
Hope this helps someone else
Upvotes: 1