Oracle® Application Development Framework Developer's Guide
10g Release 3 (10.1.3) B25386-01 |
|
![]() Previous |
![]() Next |
When you create a JSF application using ADF Faces components, besides configuring elements in faces-config.xml
you can configure ADF Faces-specific features in the adf-faces-config.xml
file. The adf-faces-config.xml
file has a simple XML structure that enables you to define element properties using the JSF expression language (EL) or static values.
In JDeveloper when you insert an ADF Faces component into a JSF page for the first time, a starter adf-faces-config.xml
file is automatically created for you in the /WEB-INF
directory of your ViewController project. Example A-28 shows the starter adf-faces-config.xml
file.
Typically you would want to configure the following in adf-faces-config.xml
:
Page accessibility levels
Skin family
Time zone
Enhanced debugging
Oracle Help for the Web (OHW) URL
Example A-28 Starter adf-faces-config.xml Created by JDeveloper
<?xml version="1.0" encoding="windows-1252"?> <adf-faces-config xmlns="http://xmlns.oracle.com/adf/view/faces/config"> <skin-family>oracle</skin-family> </adf-faces-config>
The following JSF tasks are supported by the adf-faces-config.xml
file.
To define the level of accessibility support in an application, use <accessibility-mode>
. The supported values are:
default
—Output supports accessibility features.
inaccessible
—Accessibility-specific constructs are removed to optimize output size.
screenReader
—Accessibility-specific constructs are added to improve behavior under a screen reader (but may have a negative affect on other users. For example access keys are not displayed if the accessibility mode is set to screen reader mode).
To set the currency code to use for formatting currency fields, and define the separator to use for groups of numbers and the decimal point, use the following elements:
<currency-code>
—Defines the default ISO 4217 currency code used by oracle.adf.view.faces.converter.NumberConverter
to format currency fields that do not specify a currency code in their own converter.
<number-grouping-separator>
—Defines the separator used for groups of numbers (for example, a comma). ADF Faces automatically derives the separator from the current locale, but you can override this default by specifying a value in this element. If set, this value is used by oracle.adf.view.faces.converter.NumberConverter
while parsing and formatting.
<decimal-separator>
—Defines the separator (e.g., a period or a comma) used for the decimal point. ADF Faces automatically derives the separator from the current locale, but you can override this default by specifying a value in this element. If set, this value is used by oracle.adf.view.faces.converter.NumberConverter
while parsing and formatting.
Example A-30 Configuring Currency Code and Separators For Numbers and Decimal Point
<!-- Set the currency code to US dollars. --> <currency-code>USD</currency-code> <!-- Set the number grouping separator to period for German --> <!-- and comma for all other languages --> <number-grouping-separator> #{view.locale.language=='de' ? '.' : ','} </number-grouping-separator> <!-- Set the decimal separator to comma for German --> <!-- and period for all other languages --> <decimal-separator> #{view.locale.language=='de' ? ',' : '.'} </decimal-separator>
ADF Faces enhances debugging output when you set <debug-output>
to "true". The following features are then added to debug output:
Automatic indenting.
Comments identifying which component was responsible for a block of HTML.
Detection of unbalanced elements, repeated use of the same attribute in a single element, or other malformed markup problems.
Detection of common HTML errors (for example, <form>
tags inside other <form>
tags or <tr>
or <td>
tags used in illegal locations).
ADF Faces validators and converters support client-side validation and conversion as well as server-side validation and conversion. ADF Faces client-side validators and converters work the same way as the server-side validators and converters, except that JavaScript is used on the client. ADF Faces JavaScript-enabled validators and converters run on the client when the form is submitted; thus errors can be caught without a server round trip. You can, however, turn off client-side conversion and validation in your ADF Faces application by setting <client-validation-disabled>
to "true".
By default, ADF Faces page rendering direction is based on the language being used by the browser. However, you can explicitly set the default page rendering direction in the <right-to-left>
element by using "true" or "false".
By default, ADF Faces uses the Oracle <skin-family>
for all pages. You can change this to specify a custom <skin-family>
. See also Section A.12.1, "Tasks Supported by adf-faces-skins.xml".
For information about creating custom skins, see Section 14.3, "Using Skins to Change the Look and Feel".
To change the output mode ADF Faces uses, set the <output-mode>
element, using one of these values:
default
—The default page output mode (usually display).
printable
—An output mode suitable for printable pages.
email
—An output mode suitable for e-mailing a page's content.
By default ADF Faces sets the maximum number of active processScope
instances at 15. Use the <process-scope-lifetime>
element to change the number. A static value must be used.
To set the time zone used for processing and displaying dates, and the year offset that should be used for parsing years with only two digits, use the following elements:
<time-zone>
—ADF Faces defaults to the time zone used by the client browser. This value is used by oracle.adf.view.faces.converter.DateTimeConverter
while converting strings to Date
.
<two-digit-year-start>
—Defaults to the year 1950 if no value is set. This value is used by oracle.adf.view.faces.converter.DateTimeConverter
to convert strings to Date
.
Most applications don't need to replace the default UploadedFileProcessor
instance provided by ADF Faces, but if your application needs to support uploading of very large files or rely heavily on file uploads, you may wish to replace the default processor with a custom UploadedFileProcessor
implementation. For example you could improve performance by using an implementation that immediately stores files in their final destination, instead of requiring ADF Faces to handle temporary storage during the request. To replace the default processor, specify a custom implementation using the <uploaded-file-processor>
element.
If you use Oracle Help for the Web (OHW) to provide help in your application, you can attach help content to any JSF tag that accepts a URL. Before you can do this, you must configure your help site URL by using the <oracle-help-servlet-url>
element. ADF Faces supports OHW Version 2.0 as well as earlier versions
Use the adfFacesContext.helpTopic
EL object to attach help content to the JSF tag. For example:
<h:outputLink value="#{adfFacesContext.helpTopic.someTopicID}"> <h:outputText value="Help!"/> </h:outputLink>
Once you have configured elements in the adf-faces-config.xml
file, you can retrieve property values using one of the following approaches:
Programmatically using the AdfFacesContext
class.
The AdfFacesContext
class is a context class for all per-request and per-webapp information required by ADF Faces. One instance of the AdfFacesContext
class exists per request. Although it is similar to the JSF FacesContext
class, the AdfFacesContext
class does not extend FacesContext
.
To retrieve an ADF Faces configuration property programmatically, first call the static getCurrentInstance()
method to get an instance of the AdfFacesContext
object, then call the method that retrieves the desired property, as shown in the following example:
// Get an instance of the AdfFacesContext object AdfFacesContext context = AdfFacesContext.getCurrentInstance(); // Get the time-zone property TimeZone zone = context.getTimeZone(); // Get the right-to-left property if (context.isRightToLeft()) { ... }
For the list of methods to retrieve ADF Faces configuration properties, refer to the Javadoc for oracle.adf.view.faces.context.AdfFacesContext
.
Using a JSF EL expression to bind a component attribute value to one of the properties of the ADF Faces implicit object (adfFacesContext
).
The AdfFacesContext
class contains an EL implicit variable, called adfFacesContext
, that exposes the context object properties for use in JSF EL expressions. Using a JSF EL expression, you can bind a component attribute value to one of the properties of the adfFacesContext
object. For example in the EL expression below, the <currency-code>
property is bound to the currencyCode
attribute value of the JSF ConvertNumber
component:
<af:outputText> <f:convertNumber currencyCode="#{adfFacesContext.currencyCode}"/> </af:outputText>