get the URL param in ADF

If you want to use URL parameters in ADF

use below code.

In JSF view use this el

#{param.yourparamName}

In java you can use JSF util class

 String paramName= JSFUtils.resolveExpression("#{param.yourparamName}");

I am using JSFUtils resolveexpression method here.

public static Object resolveExpression(String expression)
  {
    FacesContext facesContext = getFacesContext();
    Application app = facesContext.getApplication();
    ExpressionFactory elFactory = app.getExpressionFactory();
    ELContext elContext = facesContext.getELContext();
    ValueExpression valueExp =
      elFactory.createValueExpression(elContext, expression, Object.class);
    return valueExp.getValue(elContext);
  }


Happy learning…

Get all the children components recursively for all UI Components

Problem- Need to reset all the input Components in the page on the click of a button.On first thought developer think of do this in the bean by getting the binding of the outermost layout component and then using the getChildren() method for that UIComponent.Then for all the UI components in the list,set the reset property to true.But problem here is that page contain multiple layout components. And getChildren() method would not recursively search for all the UI components (including inside the other layout components such as panelgrouplayout.


Implementation –
Its plain java.Call the method recursively.get each input Component and reset it.

// reset all the child uicomponents
private void resetValueInputItems(AdfFacesContext adfFacesContext,
                                 UIComponent component){
   List<UIComponent> items = component.getChildren();
   for ( UIComponent item : items ) {
      
       resetValueInputItems(adfFacesContext,item);
      
       if ( item instanceof RichInputText  ) {
           RichInputText input = (RichInputText)item;
           if ( !input.isDisabled() ) {
               input.resetValue() ;
               adfFacesContext.addPartialTarget(input);
           };
       } else if ( item instanceof RichInputDate ) {
           RichInputDate input = (RichInputDate)item;
           if ( !input.isDisabled() ) {
               input.resetValue() ;
               adfFacesContext.addPartialTarget(input);
           };
       }
   }
} 
 

Happy learning with Vinay Kumar in techartifact…

Get application Module DataSource Name in ADF

Requirement – To get the using current Data source name in Application Module

Implementation- Following source code will help you getting this

Hashtable hashtable = getSession().getEnvironment();

System.out.println(" value of JDBC data source is : "+hashtable.get("JDBCDataSource"));

Happy learning with Vinay Kumar in techartifact….