|
|
 |
Oracle ADF Faces - Configuring ADF Faces
adf-faces-config.xml
ADF Faces is configured with an
adf-faces-config.xml
file.
If you need an
adf-faces-config.xml
file then it must be placed in
the WEB-INF directory of your web application. This file has a
very simple XML structure that relies on the JSF expression
language (EL) for flexibility. Each configurable property can be
defined either inline with a static, constant value, or with a
JSF EL expression that is re-evaluated on each request.
Example file
<?xml version="1.0"?>
<adf-faces-config xmlns="http://xmlns.oracle.com/adf/view/faces/config">
<!-- Enable debug output -->
<debug-output>true</debug-output>
<!-- Pick accessibility options based on a per-user managed bean -->
<accessibility-mode>#{user.accessibilityMode}</accessibility-mode>
<!-- A silly use of EL: English users get one appearance, -->
<!-- others get another -->
<skin-family>
#{view.locale.language=='en' ? 'minimal' : 'oracle'}
</skin-family>
</adf-faces-config>
Definition of subelements
All
adf-faces-config.xml
files must begin with
an
<
adf-faces-config
>
element in the
http://xmlns.oracle.com/adf/view/faces/config
XML namespace.
The order of elements inside of
<
adf-faces-config
>
doesn't matter.
debug-output
The
<
debug-output
>
element controls whether output is enhanced for
debugging. ADF Faces adds a variety of features to aid in debugging,
including:
-
Automatically indenting output
-
Adding comments identifying which component was responsible
for a block of HTML
-
Detecting unbalanced elements, repeated use of the
same attribute in a single element, or other malformed markup
problems
-
Detecting common HTML errors (like
<
form
>
tags
inside other
<
form
>
tags,
<
tr
>
or
<
td
>
tags
used in illegal locations, etc.)
client-validation-disabled
The
<
client-validation-disabled
>
element controls whether client side converters and validators are run.
output-mode
The
<
output-mode
>
element configures what "Output Mode"
ADF Faces is using. Accepted values include:
-
"default" (or null): the default output mode
-
"printable": an output mode suitable for printable pages
-
"email": an output mode suitable for e-mailing a page's content
skin-family
The
<
skin-family
>
element configures the skin
to be used. Accepted values include:
-
"oracle": the Oracle Browser Skin
-
"minimal": a more minimal skin
Future releases of ADF Faces will define public APIs for extending
the set of available skins. Currently, you can create your own skin
by creating the skin definition in a file named adf-faces
-skins.xml.
See the ADF Faces demos for examples.
accessibility-mode
The
<
accessibility-mode
>
element defines the level
of accessibility support to be used. Accepted values are:
-
"default": Output supports accessibility features
-
"inaccessible": Accessibility-specific constructs are stripped out to optimize output size
-
"screenReader": Accessibility-specific constructs are added to improve behavior under a screen reader (but
may affect other users negatively)
oracle-help-servlet-url
The
<
oracle-help-servlet-url
>
element defines
an URL to an installation of Oracle Help for the Web (OHW).
ADF Faces supports OHW Version 2.0 as well as earlier versions.
Once this is configured, page content can be trivially attached
to any JSF tag that accepts an URL by using the "adfFacesContext" EL
object. For example:
<h:outputLink value="#{adfFacesContext.helpTopic.someTopicID}">
<h:outputText value="Get Help"/>
</h:outputLink>
page-flow-scope-lifetime
The
<
page-flow-scope-lifetime
>
element
controls the maximum number of pageFlowScope instances that will be
kept active at any one time. The default is 15. Unlike other
<
adf-faces-config
>
elements,
<
page-flow-scope
>
lifetime does not support EL
expressions - it must be configured statically.
time-zone
The
<
time-zone
>
element defines the default
time zone used for date processing and date display. ADF Faces
will attempt to default the time zone to the time zone used
by the client browser, but this property may be bound by
an EL expression to a
TimeZone
object if needed.
This value is used by
oracle.adf.view.faces.converter.DateTimeConverter
while converting strings to Date.
two-digit-year-start
The
<
two-digit-year-start
>
element defines the
year offset that should be used for parsing years with only two digits.
If it is not set, it is defaulted to year
1950
. This value is
used by
oracle.adf.view.faces.converter.DateTimeConverter
while converting strings to Date. This property may also
be explicitly configured with an EL expression that returns
Integer object if needed or can be directly harcoded to a integer value.
right-to-left
The
<
right-to-left
>
element defines whether pages
will be rendered in left-to-right mode (most languages) or
right-to-left mode (Arabic and Hebrew, for example). While ADF Faces
will automatically pick the reading direction for you (sufficient for
the vast majority of developers), if you need a different
default association of language to reading direction you can use an EL
expression here that returns a Boolean object, or hardcode it to either
"true" or "false".
number-grouping-separator
The
<
number-grouping-separator
>
element defines the
separator used for groups of numbers. ADF Faces will automatically
derive the separator from the current locale, but it may also
be hardcoded or can be explicitly configured with an EL expression that returns
a Character object. If set, this value is used by
oracle.adf.view.faces.converter.NumberConverter
while parsing
and formatting.
decimal-separator
The
<
decimal-separator
>
element defines the
separator used for the decimal point. ADF Faces will automatically
derive the separator from the current locale, but it may also
be hard
coded or can be explicitly configured with an EL expression that returns
a Character object. If set, this value is used by
oracle.adf.view.faces.converter.NumberConverter
while parsing
and formatting.
currency-code
The
<
currency-code
>
element defines the
ISO 4217 currency code used by default for formatting
currency fields when those fields do not specify an explicit
currency field via their converter. If this value is not specified
in the converter and is set here, then this value is used by
oracle.adf.view.faces.converter.NumberConverter
while
formatting. This value can be hardcoded or can be explicitly configured
with an EL expression that returns a String object.
uploaded-file-processor
The
<
uploaded-file-processor
>
element must
be the name of a class that implements the
oracle.adf.view.faces.webapp.UploadedFileProcessor
interface. This API is responsible for processing each individual
uploaded file as they come from the incoming request and making
its contents available for the rest of the request. Most developers
will find the default
UploadedFileProcessor
sufficient
for their purposes, but applications that need to support uploading
very large files may improve their performance by immediately
storing files in their final destination, instead of requiring
ADF Faces to handle temporary storage during the request.
web.xml
Some ADF Faces configuration options are set instead with
<
context-param
>
elements in your
WEB-INF/web.xml
file.
oracle.adf.view.faces.CLIENT_STATE_METHOD
Chooses the type of client-side state saving used when client-side state saving is enabled (with the JSF standard
javax.
faces.STATE_SAVING_METHOD
parameter). Two values are accepted:
-
"token": the default, which stores page state in the session,
but persists a token to the client that lets ADF Faces disambiguate
the same page appearing multiple times. Failover is supported.
-
"all": stores all state in the client in a (potentially large)
hidden form field. This matches the default behavior of the JSF reference
implementation, and can be useful for developers avoiding any
use of
HttpSession
.
oracle.adf.view.faces.CLIENT_STATE_MAX_TOKENS
In "token"-based client-side state saving, chooses how many tokens
should be preserved at any one time. The default value is 15.
When this is exceeded, state will have effectively been "forgotten"
for the least recently viewed pages, which can impact users
that actively use the Back button or that have multiple windows
open simultaneously. Developers building HTML applications that
rely heavily on frames will likely need to increase this value.
oracle.adf.view.faces.USE_APPLICATION_VIEW_CACHE
This configuration option enables an optimized strategy for caching some
view state at an application level, which significantly improves
scalability. However, it makes it harder to develop (updates to
pages will not be noticed until the server is restarted), and in
some rare cases cannot be used for some pages. See below for
more information about this option.
oracle.adf.view.faces.DEBUG_JAVASCRIPT
ADF Faces by default obfuscates the Javascript it delivers
to the client, as well as stripping comments and whitespace.
This dramatically reduces the size of our Javascript download,
but also makes it tricky to debug the Javascript. This
flag can be set to true to turn off the obfuscation.
oracle.adf.view.faces.CHECK_FILE_MODIFICATION
If this pa
rameter is enabled by setting to "true", ADF Faces will automatically
check the modification date of your JSPs, and discard saved
state when they change; this makes development easier,
but adds overhead that should be avoided when your application
is deployed.
Configuring ADF Faces for Performance
When configuring ADF Faces for deployment, it is most critical
that debug options have been turned off. Specifically:
-
<
debug-output
>
should be removed or set to false.
-
oracle.adf.view.faces.CHECK_FILE_MODIFICATION should be
removed or set to false.
-
oracle.adf.view.faces.DEBUG_JAVASCRIPT should be removed or set to false.
In general, we strongly recommend that all clients use
client-side state saving with ADF Faces, not server-side
state saving. In practice, server-side state saving is
in fact somewhat more performant, but it suffers from
critical limitations that make it inadvisable in the
real world: for example, there is no support for failover,
the back button is only supported very, very poorly, and
users cannot properly show multiple windows at one time.
When using client-side state saving with ADF Faces, the "token"
version of state-saving generally results in much better server
performance, because the CPU and I/O consumption is much lower.
However, "token"-based state saving does consume significantly more
memory, so memory-limited servers may in some cases benefit from using
"all" client-side state saving.
The Application View Cache
ADF Faces supports a special Application View Cache feature
that can increase scalability significantly. However, it
can, in so
me unusual cases, break an otherwise functioning
application, so it is important to understand how it works
to understand whether it can be enabled for your pages.
In conventional JSF state saving, a page's UI state is saved
the same way every time it is used. It doesn't matter if
state is being saved for an initial render of a page, or if
state is being saved after a user has posted back to that page.
No two postbacks are necessarily the same - the user may
have entered entirely different data, navigated to
a different set of rows in the table, etc. So, it is extremely
difficult to share state among postback requests.
However, most of the time, all initial renders of any
one page have exactly the same view state. It doesn't matter
if the page is showing different data, or responding to
different query parameters, and so forth, because in JSF
those are conventionally accessed using the JSF expression
language (EL). In JSF, what state saving remembers isn't the
result of evaluating an EL expression - it's the EL expression
itself. So, when you see:
<af:outputText value="#{mybean.value}"/>
... all that's being saved is "#{mybean.value}", and that state is
the same no matter what that expression evaluates to.
The Application View Cache takes advantage of this, and caches
the state for these initial renders at an application scope.
Once the page has been viewed once, all users can reuse that
same state coming and going, saving some CPU (the CPU cost
of saving the state each time) and more importantly the
memory overhead of keeping separate copies for each user.
State saving for postback is still separated per user,
but keep in mind that if the result of a postback is
that you navigate to a new page, the Application View
Cache is still in effect - it is only disabled when a postback
remains on a page (for example, because of a validation
failure).
Perhaps even more importantly, the Application View
Cache enables
the use of web Proxy Caches (like the OracleAS Web Cache) in front of
your application server. Token-based client-side state saving
defeats web proxy caches, because each user may have a different
token for any one page, defeating cacheability. The Application
View Cache uses the same token across all users.
All this should raise the question of why anyone would ever
not use the Application View Cache. First, the technology
currently does not invalidate itself if the page is modified;
it requires a server restart. This makes it difficult to use
during development. Beyond this, however, there are some
JSF coding techniques that break the core assumption of
the Application View Cache - the assumption that the initial
view state of any one page is always the same, no matter who
views it:
-
Conditional tags that may not evaluate identically for each user
-
JSF components that pull EL results into page state
The following JSP includes two potential examples of the first problem:
<c:if test="${user.locale.language='en'}">
<h:outputText value="You're in an English locale"/>
</c:if>
<af:selectOneListbox value="#{someValue}">
<af:forEach var="item" items="#{model.listOfItems}">
<af:selectItem value="#{item.value}" text="#{item.text}"/>
</af:forEach>
</af:selectOneListbox>
The
<
c:if
>
will show "You're in an English locale" if the locale's
language is English. This means that in English, a user's version of
the page will have an extra component over users who aren't
using English; the state will vary accordingly. This sort of
problem can cleanly be resolved by using "rendered" instead of
<
c:if
>
,
which is always a recommended JSF best-practice:
<h:outputText value="You're in an English locale"
rendered="#{user.locale.language == 'en'}"/>
The example using
<
af:forEach
>
is less clear-cut,
and
less easily resolved. If "model.listOfItems" always has the
same
number
of items when a page gets shown at first,
then there are no issues with this particular code sample. But
if the number of items does vary from one user to another,
then the page, as written, cannot support the Application View Cache.
In this particular case, there's also a simple workaround:
<af:selectOneListbox value="#{someValue}">
<f:selectItems value="#{model.listOfSelectItems}"/>
</af:selectOneListbox>
In addition to problems with non-JSF tags that manipulate the
page, you can run into problems with some JSF tags that
directly manipulate page state. A particular example of this
is the MyFaces
<
x:save_state
>
tag. This tag will
evaluate an EL expression and save it directly as part
of the page's view state. This is very nice functionality,
but it does directly and necessarily conflict with the
technique of the Application View Cache.
At the moment, the Application View Cache can only
be enabled or disabled globally. We are considering
adding support for disabling (or enabling) the view cache
on a page-by-page basis.
AdfFacesContext
All the properties defined in an
adf-faces-config.xml
file can be retrieved programatically with the
oracle.adf.view.faces.context.AdfFacesContext
class.
One instance of this class exists per request, and it can
be retrieved using the static
getCurrentInstance()
method (just like a
FacesContext
). Despite the name,
AdfFacesContext
does
not
actually extend
FacesContext
.
AdfFacesContext context = AdfFacesContext.getCurrentInstance();
// Get the time zone
TimeZone zone = context.getTimeZone();
// Are we in a right-to-left language?
if (context.isRightToLeft())
{
...
}
In addition to the configuration properties described above, the
AdfFacesContext
object also exposes several properties
of type
java.util.Map
that help users write EL
expressions (see the next section for information on this
use). For more information, see the Javadoc for this class.
The "adfFacesContext" EL object
ADF Faces exposes a number of values into the JSF EL language. All
are grouped underneath a single "adfFacesContext" EL variable.
#{adfFacesContext}
The EL expression
#{adfFacesContext}
returns
the AdfFacesContext object itself.
#{adfFacesContext.helpTopic['foo']}
The EL expression
#{adfFacesContext.helpTopic['foo'
]
}
returns
an URL to the help topic "foo". Before using this, you
must configure the
<
oracle-help-servlet-url
>
element
in
adf-faces-config.xml
.
#{adfFacesContext.helpSystem['frontPage']}
The EL expression
#{adfFacesContext.helpSystem['frontPage'
]
}
returns
an URL to the front page of the help system. Before using this, you
must configure the
<
oracle-help-servlet-url
>
element
in
adf-faces-config.xml
. (Other subproperties of
"helpSystem" may be added in the future.)
#{adfFacesContext.colorPalette}
The EL expression
#{adfFacesContext.colorPalette}
returns
a Map of color palettes, each of which is an array of
java.awt.Color
objects. Palette names include:
-
"web216": the 216 web-safe colors
-
"default49": a 49 color palette, including a fully transparent entry
-
"opaque49": a 49 color palette, without a transparent entry
-
"default80": an 80 color palette
These
color palettes can be used with the "selectInputColor" ADF Faces tag.
#{adfFacesContext.formatter}
The EL expression
#{adfFacesContext.formatter}
returns an
object that can be used for applying message formatting. For
example, the following EL expression:
<h:outputText value="#{adfFacesContext.formatter['One{0}Three']['Two']}"/>
... will result in the output:
At this time, the "formatter" can only support formatting messages
containing a single parameter.
#{adfFacesContext.agent}
The EL expression
#{adfFacesContext.agent}
returns an object that describes the client agent that is making the request and is to display the rendered output. The agent object describes the following,
-
agent type: Possible values "desktop", "pda", "phone" and "unknown"
-
agent name and version: Agent names include "ie", "gecko" (for all gecko based browsers including Mozilla, Firefox, and Netscape 6+ versions), "webkit" (for all webkit based browsers including safari), "netfront", "blazer"
-
platform name and version: Platform names include "windows", "linux", "mac", "palm", "solaris", "ppc"
-
(mobile) device make and model when available, and
-
capabilities : Capability names include
-
"dom" : dom level support (possible values are "none", "level1", "level2")
-
"tables" : table layout support (possible values "basic", "advanced")
-
"frames" : frames support (boolean value, "true" or "false"
-
"iframes" : iframes support (boolean value, "true" or "false"
-
"width" and "height" : screen resolution of the (mobile) device (integer value)
|
Copyright © 2003-2006, Oracle Corporation. All Rights Reserved.
|
|
|
|