Implementing the Use Case

Topics:

Task 1   Create an Application

You create JSF JSP pages using the Create JSF Page dialog.

To create a JSF JSP page:

  1. In the Application Navigator, right-click the directory where you would like the page to be saved, and choose New. In the New Gallery, expand the Web Tier node, select JSF and then JSF Page, and click OK.

    OR

    From a navigation diagram, double-click a page icon for a page that has not yet been created.

  2. Complete the Create JSF Page dialog. For help, click Help in the dialog.

If you chose to use one of the quick layouts, then Oracle JDeveloper also adds the components necessary to display the layout. The following examples shows the generated code when you choose a two-column layout, where the first column is locked and the second column stretches to fill up available browser space, and you also choose to apply themes.

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <f:view>
    <af:document id="d1">
      <af:form id="f1">
        <af:panelStretchLayout startWidth="100px" id="psl1">
          <f:facet name="start"/>
          <f:facet name="center">
            <!-- id="af_twocol_left_sidebar_stretched"   -->
            <af:decorativeBox theme="dark" id="db2">
              <f:facet name="center">
                <af:decorativeBox theme="medium" id="db1">
                  <f:facet name="center"/>
                </af:decorativeBox>
              </f:facet>
            </af:decorativeBox>
          </f:facet>
        </af:panelStretchLayout>
      </af:form>
    </af:document>
  </f:view>
</jsp:root>

If you chose to automatically create a backing bean using the Page Implementation section of the dialog, Oracle JDeveloper also creates and registers a backing bean for the page, and binds any existing components to the bean. The following example shows the code created for a backing bean for a page.

package view.backing;
 
import oracle.adf.view.rich.component.rich.RichDocument;
import oracle.adf.view.rich.component.rich.RichForm;
 
public class MyFile {
    private RichForm f1;
    private RichDocument d1;
 
    public void setF1(RichForm f1) {
        this.f1 = f1;
    }
 
    public RichForm getF1() {
        return f1;
    }
 
    public void setD1(RichDocument d1) {
        this.document1 = d1;
    }
 
    public RichDocument getD1() {
        return d1;
    }
}

Tip:

You can access the backing bean source from the JSF page by right-clicking the page in the editor, and choosing Go to and then selecting the bean from the list.

Additionally, Oracle JDeveloper adds the following libraries to the view project:

  • ADF Faces Runtime 11

  • ADF Common Runtime

  • ADF DVT Faces Runtime

  • Oracle JEWT

  • ADF DVT Faces Databinding Runtime

Oracle JDeveloper also adds entries to the web.xml file, as shown in the following sample:

<?xml version = '1.0' encoding = 'UTF-8'?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                             http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
  <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION</param-name>
    <param-value>false</param-value>
  </context-param>
  <context-param>
    <param-name>oracle.adf.view.rich.versionString.HIDDEN</param-name>
    <param-value>false</param-value>
  </context-param>
  <filter>
    <filter-name>trinidad</filter-name>
    <filter-class>org.apache.myfaces.trinidad.webapp.TrinidadFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>trinidad</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
  </filter-mapping>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet>
    <servlet-name>resources</servlet-name>
    <servlet-class>
      org.apache.myfaces.trinidad.webapp.ResourceServlet
    </servlet-class>
  </servlet>
  <servlet>
    <servlet-name>BIGRAPHSERVLET</servlet-name>
    <servlet-class>
     oracle.adfinternal.view.faces.bi.renderkit.graph.GraphServlet
    </servlet-class>
  </servlet>
  <servlet>
    <servlet-name>BIGAUGESERVLET</servlet-name>
    <servlet-class>
     oracle.adfinternal.view.faces.bi.renderkit.gauge.GaugeServlet
    </servlet-class>
  </servlet>
  <servlet>
    <servlet-name>MapProxyServlet</servlet-name>
    <servlet-class>
      oracle.adfinternal.view.faces.bi.renderkit.geoMap.servlet.MapProxyServlet
    </servlet-class>
  </servlet>
  <servlet>
    <servlet-name>GatewayServlet</servlet-name>
    <servlet-class>
      oracle.adfinternal.view.faces.bi.renderkit.graph.FlashBridgeServlet
    </servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>resources</servlet-name>
    <url-pattern>/adf/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>resources</servlet-name>
    <url-pattern>/afr/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>BIGRAPHSERVLET</servlet-name>
    <url-pattern>/servlet/GraphServlet/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>BIGAUGESERVLET</servlet-name>
    <url-pattern>/servlet/GaugeServlet/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>MapProxyServlet</servlet-name>
    <url-pattern>/mapproxy/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>resources</servlet-name>
    <url-pattern>/bi/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>GatewayServlet</servlet-name>
    <url-pattern>/flashbridge/*</url-pattern>
  </servlet-mapping>
</web-app>

In the faces-config.xml file, when you create a JSF JSP page, Oracle JDeveloper creates an entry that defines the default render kit (used to display the components in an HTML client) for ADF Faces, as shown in the following sample:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee">
  <application>
    <default-render-kit-id>oracle.adf.rich</default-render-kit-id>
  </application>
</faces-config>

An entry in the trinidad-config.xml file defines the default skin used by the user interface (UI) components in the application, as shown in the following example:

<?xml version="1.0" encoding="UTF-8"?>
<trinidad-config xmlns="http://myfaces.apache.org/trinidad/config">
  <skin-family>fusion</skin-family>
</trinidad-config>

When the page is first displayed in Oracle JDeveloper, it is displayed in the visual editor (accessed by clicking the Design tab), which allows you to view the page in a WYSIWYG environment. You can also view the source for the page in the source editor by clicking the Source tab. The Structure window located in the lower left-hand corner of Oracle JDeveloper, provides a hierarchical view of the page.

Task 2   Configure the Application

Once you have created the application, you are required to configure a few parameters:

  1. Navigate to Application > Deploy > Deploy to Application Server.

  2. Either select or create the Oracle Java Cloud Service connection you will use.

  3. Once you have deployed your application, check the application status and state from the Oracle Java Cloud Service console. You should see a green arrow and the State Active.

When the application becomes available, you can locate the test URL by clicking Test Application. Note that you may need to add the URL of your trial service instance provided in the context root to the path for the actual page.