Showing posts with label adf. Show all posts
Showing posts with label adf. Show all posts

Change /faces from ADF application url

There is an easy way to identify ADF production applications from the URL pattern. Most of the ADF applications are using the default configuration for JSF request and response processing and it generates /faces url pattern in application url .

There is an easy way to customize ADF application URL from web.xml file. Below configuration shows the default configuration.

  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern><b>/faces/*</b></url-pattern>
  </servlet-mapping>

And application URL would be http://127.0.0.1:7101/contextpath/faces/Home

Change /faces to your custom name. For eg, I am using /adffaces in my web.xml .

  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/adffaces/*</url-pattern>
  </servlet-mapping>

ADF application URL would be  http://127.0.0.1:7101/contextpath/adffaces/Home

Using IN operator in view criteria.


 Unfortunately, there is no declarative way to add IN operator in view criteria.Below code show programmatic way to add in clause in View criteria.

I have created EmployeesViewCriteria in EmployeesView view object and below method appends IN .

    public void filterWithInOperator() {

        ViewObjectImpl vo = this;

        ViewCriteria vc =
            vo.getViewCriteriaManager().getViewCriteria("EmployeesViewCriteria");
        ViewCriteriaRow vcr = vc.createViewCriteriaRow();
        vcr.setConjunction(ViewCriteriaRow.VC_CONJ_AND);
        ViewCriteriaItem vci = vcr.ensureCriteriaItem("DepartmentId");
        vci.setOperator(JboCompOper.OPER_IN);
        vci.setValueMinCardinality(3);
        vci.setValueMaxCardinality(3);
        vci.setValue(0, 10);
        vci.setValue(1, 20);
        vci.setValue(2, 30);
        vc.addRow(vcr);
        vo.applyViewCriteria(vc);
        vo.executeQuery();
        vo.setCurrentRow(this.first());

    }

Convert SQL date from Util date.


public static final java.sql.Date getSQLDateFromUtilDate(java.util.Date date) {
java.sql.Date sqlDate = null;
if (date == null) {
return null;
} else {
sqlDate = new java.sql.Date(date.getTime());
}
return sqlDate;
}

Handy code for getting value from property bundle


public static final Object getUiBundleValue(String key) {
Map propertyMap =
(Map)ADFUtil.resolveExpression(“#{adfBundle['org.xxx.xxx.xxx.xxx.xxxUIBundle']}”);
return propertyMap.get(key);
}
public static Object resolveExpression(String el) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory =
facesContext.getApplication().getExpressionFactory();
ValueExpression valueExp =
expressionFactory.createValueExpression(elContext, el, Object.class);
return valueExp.getValue(elContext);
}

Set and get object into/from session



/**
* Method for setting an object in session
* @param name
* @param value
* @return null
*/
public static void setSessionValue(String name, Object value) {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request =
(HttpServletRequest)context.getExternalContext().getRequest();
HttpSession httpSession = request.getSession(false);
httpSession.setAttribute(name, value);
}
/**
* Method for getting an object from session
* @param null
* @return Object
*/
public static Object getSessionValue(String attName) {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request =
(HttpServletRequest)context.getExternalContext().getRequest();
HttpSession httpSession = request.getSession(false);
return httpSession.getAttribute(attName);
}

Method for converting oracle.jbo.domain.Date to java.util.Date




public static java.util.Date convertDomainDateToUtilDate(oracle.jbo.domain.Date domainDate) {
java.util.Date date = null;
if (domainDate != null) {
java.sql.Date sqldate = domainDate.dateValue();
date = new Date(sqldate.getTime());
}
return date;
}