How to hide the viewcriteria from the af:query panel


If you want to hide the view criteria, then here is the easy way
The code is written in the setter of the af:query binding

public void setQuery_binding(RichQuery query_binding) {

 this.query_binding = query_binding;

 DCBindingContainer bindings = (DCBindingContainer)this.getBindings();
 DCIteratorBinding iter =
 bindings.findIteratorBinding("<TableIterator>");

 ViewObjectImpl voimpl = (ViewObjectImpl)iter.getViewObject();
 ViewCriteria vc =  voimpl.getViewCriteriaManager().getViewCriteria("");
 vc.setProperty(ViewCriteriaHints.CRITERIA_SHOW_IN_LIST, ViewCriteriaHints.CRITERIA_HINT_FALSE);

 }
  • getting the handle to the iterator
  • getting handle to the ViewCriteriaManager, and then getting handle to the specific view criteria that we wanted to hide
  • modifying the ViewCriteriaHints.CRITERIA_SHOW_IN_LIST property to false

note: helper method – getBindings()

 private BindingContainer getBindings() {
 if (this.bindings == null) {
 FacesContext fc = FacesContext.getCurrentInstance();
 this.bindings =
 (BindingContainer)fc.getApplication().evaluateExpressionGet(fc,
 "#{bindings}",
 BindingContainer.class);
 }
 return this.bindings;
 }
Advertisements

One thought on “How to hide the viewcriteria from the af:query panel

  1. Ravi

    Excellent man … I was wondering how to do this for days … finally its just setProperty method … i knew its hidden in some class. all I was looking for was get a handle to “ShowInList” property somehow. This is awesome.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s