Monday, March 28, 2011

Using Region Capabilities API

 Assume the following task flow:

And now assume that we need to show the navigation available from the present view activity in a choice list, as shown below:

The question is how to do this?


We need to use Capabilities API available in java to populate the choice list as shown below:

public SelectItem[] getSelectItems(){
  RegionModel rm = getRegion().getRegionModel();
  Set<String> capabilities = rm.getCapabilities();
  SelectItem[] si = new SelectItem[capabilities.size()];
  Object[] s = capabilities.toArray();

  for ( int i = 0; i < s.length; i++ ){
      option = s[i].toString();
      si[i] = new SelectItem(option);
  return si;

You can refer that from the SelectOneChoice component as shown below:

        <af:selectOneChoice label="Navigations Available" id="soc1" ...>
          <f:selectItems value="#{Bean.selectItems}"

The EL equivalent to use the capabilities is shown as below:


The above EL expression figures out if the region is having Department as an available navigation capability from the current view activity.

That's it.

JDev Release

No comments:

Post a Comment