Oracle ADF configurations in web.xml

The Web Application using ADF Faces can have the below configurations in the web.xml
1. Context parameter javax.faces.STATE_SAVING_METHOD. Default value set to client
2. Filters and maping values related to trinidad components
3. Resouce Servlet and maping values related to trinidad components
4. Servlet and maping values related to JSF
5. ADF Authentication servlet and mapping values
6. mime-mapping values for images , css, pdf, applications and javascripts.

 

org.apache.myfaces.trinidad.webapp.TrinidadFilter defined in the filer-class of Trinidad ensures that the ADF Faces are initialized properly. It also processes the file uploads.

org.apache.myfaces.trinidad.webapp.ResourceServlet defined in the servlet-class of resources ensures that the web application resources (images, style sheets, JavaScript libraries) will be delegated to a resource loader

javax.faces.webapp.FacesServlet defined in the servlet-class of Faces Servlet handles the request processing lifecycycle for the web applications.
Context Parameters:

The context parameter – org.apache.myfaces.trinidad.CLIENT_STATE_METHOD is defined to specify the type of client-side state saving to use.
We can define the below given values:

– token: defined to identify the block of a state stored in the HttpSession object, will actually resides on the client.

– all: defined to store all the information in the hidden FORM field and do not use HttpSession.
The context parameter – org.apache.myfaces.trinidad.CLIENT_STATE_MAX_TOKENS is defined to specify how many tokens should be stored at any one
time per user when token-based client-side state saving is enabled.

The context parameter – org.apache.myfaces.trinidad.COMPRESS_VIEW_STATE is defined to specify if the global state saving is to be compressed or not.

The context parameter – org.apache.myfaces.trinidad.USE_APPLICATION_VIEW_CACHE is defined to enable the Application View Cache
to improve the performance by caching the state of the UI Pages
The context parameter – oracle.adf.view.rich.security.FRAME_BUSTING is useful when we need to show the content of the page in the IFRAME.

 

ADF Session Timeout:

The below configuration allows you to set the session time out value. This can be set from the Overview tab of the web.xml file also.
<session-config>
<session-timeout>40</session-timeout>
</session-config>
ADF Authentication:
You can add the authentication mechanism to be used for authenticating the user credentials by various ways. The below configurations
are required to add the authentication to the ADF Web Application.

<filter-mapping>
<filter-name>adfBindings</filter-name>
<servlet-name>adfAuthentication</servlet-name>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>

<servlet>
<servlet-name>adfAuthentication</servlet-name>
<servlet-class>oracle.adf.share.security.authentication.AuthenticationServlet</servlet-class>
<init-param>
<param-name>success_url</param-name>
<param-value>/faces/success.jspx</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>adfAuthentication</servlet-name>
<url-pattern>/adfAuthentication</url-pattern>
</servlet-mapping>

<security-constraint>
<web-resource-collection>
<web-resource-name>allPages</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>valid-users</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>adfAuthentication</web-resource-name>
<url-pattern>/adfAuthentication</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>valid-users</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>   // Authentication Type
</login-config>
<security-role>
<role-name>valid-users</role-name>
</security-role>

Enable ADF Logger in Jdeveloper

Performt the following  steps to add the ADFLogger in your JDeveloper.

 1. Click on the Actions Tab in the Log windows which appears in the Editor. Select the option – Configure Oracle Diagnostic Logging

2. Expand the Root Logger

3. Click on the + icon to add the java classes which you need to include in the loggers. Select Add persistent loggers

4. Click on the Search Icon and select the com -> <YOUR_PACKAGE> folder from the available java classes. Click OK.

5. Select the Logger level as INFO.

6. Right Click on the Project –-> Project Properties -> Run/Debug/Profile.

7. Select the Default Configuration “Default” and click on Edit.

8. Add the value   -Djbo.debugoutput=adflogger in the java options. Click Ok

9. Perform the same steps for the Project to add the AppModule java file.

10. Run the application from login.jsp

11. The logs will be added in the logger placed at the below path. Please check for your local path accordingly.

 

Oracle ADF Framebusting in Web Application

Oracle ADF provides the oracle.adf.view.rich.security.FRAME_BUSTING context parameter to implement the Framebusting in the web application.

When a malicious site tries to retrieve the content of a page from another domain into a frame and allows hyperlinks or buttons (partial content of the original page) and performs action, it is known as clickjacking. Framebusting helps the web application to prevent from clickjacking

If you want to consume your ADF application in a frame, set the below given configuration in the web.xml of the web application.

<context-param>
<param-name>oracle.adf.view.rich.security.FRAME_BUSTING</param-name>
<param-value>never</param-value>
</context-param>

The apache server might require the commenting of the X-Frame-Options: sameorigin. The current apache server will show the below settings

HTTP/1.1 200 OK

Server: Apache

Cache-Control: no-cache

Pragma: no-cache

X-Powered-By: JSF/1.2

X-Frame-Options: sameorigin

Content-Type: text/html;charset=UTF-8

Transfer-Encoding: chunked

Connection: Keep-Alive

Oracle ADF redirection to login page on session expiry exception by invoking the web Filter in web.xml

Make the following entries in the web.xml in the <filter> tag

<filter>

<filter-name>SessionExpiryFilter</filter-name>

<filter-class> com.test.session. InvokeSessionExpiryFilter </filter-class>

<init-param>

<param-name>RedirectWhenSessionTimeout</param-name>

<param-value>login.jspx</param-value>

</init-param>

</filter>

Create a new java class – InvokeSessionExpiryFilter

package com.test.session;

import java.io.IOException;

import javax.faces.context.ExternalContext;

import javax.faces.context.FacesContext;

import javax.servlet.Filter;

import javax.servlet.FilterChain;

import javax.servlet.FilterConfig;

import javax.servlet.ServletException;

import javax.servlet.ServletRequest;

import javax.servlet.ServletResponse;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;

public class InvokeSessionExpiryFilter implements Filter {

private FilterConfig _filterConfig = null;

public void init(FilterConfig filterConfig) throws ServletException {

_filterConfig = filterConfig;

}

public void destroy() {

_filterConfig = null;

}

public void doFilter(ServletRequest request, ServletResponse response,

FilterChain chain) throws IOException,

ServletException {

boolean bypass = true;

String URL = ((HttpServletRequest)request).getRequestURL().toString();

HttpServletRequest httpRequest = null;

HttpSession session = null;

try {

httpRequest = (HttpServletRequest)request;

session = httpRequest.getSession();

if (session.getAttribute(“loginName”) == null) {

session.invalidate();

bypass = false;

} else {

bypass = true;

}

}

} catch (NullPointerException e) {

// RESET THE BYPASS FLAG TO FALSE IF LOGIN NAME IS NULL

bypass = false  ;

//  e.printStackTrace();

}catch (Exception e) {

// RESET THE BYPASS FLAG TO FALSE IF LOGIN NAME IS NULL

//  e.printStackTrace();

bypass = false  ;

}

Clustered Environment mapping in Oracle ADF

In the Web logic Server Clustered Environment for ADF, add the corresponding mapping in the ADF application so that the application can be accessed in case of any server failure. Following entries in the adf-config.xml and Weblogic.xml will be required to be updated.

Weblogic-application.xml: The file will be placed in the Application Resource tab -> META_INF folder. Open the XML file and add the below given tag in the file before the end tag </weblogic-application>

<session-descriptor>

<persistent-store-type>replicated_if_clustered</persistent-store-type>

</session-descriptor>

adf-config.xml: The file will be placed in the Application Resource tab -> ADF META-INF folder. Open the XML file and add the below given tag in the file before the end tag </adf-config>

<adf-controller-config xmlns=”http://xmlns.oracle.com/adf/controller/config”>

<adf-scope-ha-support>true</adf-scope-ha-support>

</adf-controller-config>

Creating business Components in ADF 11g

Perform the below given steps for creating the Business Components in JDeveloper 11g using ADF 11g
1) Create a new Application by selecting File > New > General > Applications > Application

2)  From the available application template list, select Fusion Web Application (ADF), Click OK

3)  Name the Application as testComponentApp.

4)  The Application should be selected with ADF Model Project and ADF View Controller Project.

5)  Right –Click on Model Project and select New > General > Connections > Database  

     Connection

Provide the Database Connection details as mentioned below:

  • Connection Name: testDBConn
  • Connection Type ( JDBC/ MySQL / Oracle Lite)
  • User Name
  • Password
  • Driver: Thin Driver / oci8
  • Host Name
  • SID / Service Name
  • JDBC Port

6)      Test the Connection. If it returns ‘SUCCESS’, the connection is established successfully.

7)      Right –Click on Model Project and select New >Business Tier > Business Components from Tables.

8)     Select the Connection – testDBConn

9)     Select the Schema from the list of available schemas fetched from Oracle Database.

10)  Enter the Filter expression in the Name Filter field to minimize the Database table search.

11)  Click on QUERY button to execute the filter on the database table.

12)  Select the table from the Available Table List and click on > icon to move it to the selected table list.

13)  Click Next.

14)  The list of available columns in the table will be shown. Move the columns to the selected column list.

15)  Click Next

16)  List of Business Component for the table selected will be shown. Click next.

17)  Click Finish.

18)  The Wizard will create the Entity Object which will be placed in the model package of the Model Project.