Oracle ADF Faces - Converting From Standard JSF Tags to ADF Faces Tags
Overview

ADF Faces includes replacements for many of the tags in the JavaServer Faces (JSF) specification. It is important to emphasize that there is no requirement whatsoever that you convert from standard JSF tags to ADF Faces tags. Standard JSF tags and ADF Faces tags can be mixed freely within a single page. In general, the ADF Faces tags are more powerful, because they:

  • Often offer more features than the standard tags
  • Can be used inside of the < af:forEach > tag (it is, unfortunately, not possible to support standard tags inside < af:forEach > )
  • Provide more efficient implementations of client-side state saving (reduced per-component size)
Some of the enhanced features of ADF Faces tags are described below .

Getting Started

If you're using ADF Faces for the first time, and you're adding ADF Faces tags into existing JSF pages, you'll need to know a few tips to get everything working correctly.

First, ADF Faces needs its stylesheet in each page to look correct. You can either add the < af:styleSheet > tag inside your < HEAD > tag, or, even better, just replace < HEAD > with our < afh:head > tag.

Second, if you call the Javascript form.submit() function, you'll bypass the ADF Faces support for client-side validation. We provide a submitForm() method that you can use instead, or, even better, look at the "autoSubmit" property on our input components.

Differences

Unless noted, the ADF Faces tag name is the same as the standard JSF tag with the exception of the prefix. ADF Faces tags use the prefix 'af'. For example, < h:commandButton > is < af:command Button > in ADF Faces.

The following list shows some of the common h: attributes and how they map to af: attributes:

  • accesskey - use accessKey
  • readonly - use readOnly
  • alt and/or title - use shortDesc
  • style - use inlineStyle
  • dir , lang , tabindex - n/a
The following table shows the standard JSF tags and how they map to ADF Faces tags.

Standard JSF tag What af: tag and/or attributes to use
< h:column > The af:column must be the immediate children of af:table . See the Table features section below.
< h:commandButton >
value - use text
type = "reset", use < af:resetButton > tag
image - use < af:objectImage > tag
onblur, onchange, onfocus, readonly - n/a.
< h:commandLink >
value - use text
charset, coords, hrefrel, rev, shape - n/a.
< h:dataTable > use < af:table > , and see the Table features section below.
< h:form >
enctype="multipart/form-data", use usesUpload="true"
target - use targetFrame
accept, acceptcharset, endtype onreset - n/a.
< h:graphicImage >
use < af:objectImage >
value or url - use source
ismap - use imageMapType="server"
longdesc - use longDescURL
usemap - n/a.
< h:inputHidden >
required - n/a
< h:inputSecret >
use < af:inputText > and set the "secret" attribute to true
maxlength - use maximumLength
size - use columns
redisplay - n/a.
< h:inputText >
maxlength - use maximumLength
size - use columns
< h:inputTextarea >
use < af:inputText > and set the "rows" attribute to the desired number of rows
cols - use columns
< h:message > showDetail, showSummary, xyzClass, xyzStyle, tooltip - n/a
< h:messages > globalOnly, showDetail, showSummary, xyzClass, xyzStyle, layout, tooltip - n/a
< h:outputFormat > no af: equivalent
< h:outputLabel >
onblur, onfocus - n/a.
< h:outputLink >
use < af:goLink >
value - use destination
use text for the link's text
target - use targetFrame
converter, charset, coords,hrefrel, rev, shape, type - n/a.
< h:outputText >

< h:panelGrid > no af: equivalent
< h:panelGroup >

< h:selectBooleanCheckbox >

< h:selectManyCheckbox >
layout - "vertical" and "horizontal" instead of "pageDirection" and "lineDirection"; also, the default is vertical, not horizontal
< h:selectManyListbox >

< h:selectManyMenu > use < af:selectManyListbox >
< h:selectOneListbox >

< h:selectOneMenu >
use < af:selectOneChoice >
< h:selectOneRadio >
border, disabledClass, enabledClass, layout - n/a.

The ADF < af:form > component does not implement the JSF NamingContainer API. When you use the < af:form > tag, the ID in the generated HTML does not include the form's ID as a prefix. For example:

  <h:form id="foo">
   <!-- This inputText will have an id of "foo:bar" -->
   <af:inputText id="bar"/>
  </h:form>

  <af:form id="foo2">
   <!-- This inputText will have an id of just "bar2" -->
   <af:inputText id="bar2"/>
  </af:form>
This makes it easier to write JavaScript (and results in smaller, more concise HTML) - especially in cases where you may not know the ID of the form - and enables the use of some CSS features on these fields. On the other hand, this means that pages using multiple forms cannot reuse IDs among forms. You can use the < f:subview > tag around an < af:form > if you need to reuse ID values, or you can just continue using < h:form > .

Additional features

As mentioned earlier, the ADF Faces tags offer some general features that are not available with the standard JSF tags - such as < af:forEach > support and more efficient (smaller) client-side state saving. There are many other features supported by the ADF Faces tags and components that are not supported by the standard JSF tags. It'd take too much space to discuss all of these features, but a couple of the more important ones are discussed here.

Label and message support

ADF Faces input components make it much easier to support the standard label-and-message pattern for laying out forms. Typically, a JSF page might contain content like:

  <h:panelGrid columns="2">
   <!-- Use outputLabel; outputText doesn't support accessibility -->
   <h:outputLabel for="nameInput" value="Name:  ">
   <h:panelGroup>
     <h:inputText id="nameInput" value="Enter a name"/>
     <f:verbatim><br></f:verbatim>
     <h:message for="nameInput"/>
   </h:panelGroup>
 </h:panelGrid>

All the ADF Faces input components automate this pattern; the single entry of:

  <af:inputText label="Name:" value="Enter a name"/>

...gives you all the layout of the JSF example above - automatic label and message layout and accessibility support. When you use a series of ADF Faces input components, you'll need to line up the labels and fields. For this purpose, ADF Faces provides the < af:panelForm > layout panel that will stack ADF Faces input components.

  <af:panelForm>
    <af:inputText label="First name:" value="/>
    <af:inputText label="Last name:" value="/>
  </af:panelForm> 

If you want to use an ADF Faces input component, but do not want any of these features (because you require a more flexible layout strategy, for example, or are already providing messaging), set the "simple" attribute to "true":

  <!-- No label or messaging -->
  <af:inputText simple="true" value="Enter a name"/>
Table features

The ADF Faces < af:table > component (a replacement for < h:dataTable > ) adds many features, including:

  • Built-in support for paging through data sets
  • Support for identifying rows by key instead of by index
  • No-code support for partial-page rendering (re-rendering only the table, not the entire page)
  • Support for sorting
  • "Single" and "multiple" selection columns
For more information, see Using ADF Faces Tables in Development Guidelines for Oracle ADF Faces Applications .

Message customization

In ADF Faces, for error messages that are reported for cases of invalid input for editable components, during conversion and validation can be customized for every converter or validator. This also applies to "required" validation on all input components.

   <af:selectInputDate id="mdf6" value="2004/09/06"
                    label="Date of birth"
                    tip="1/20/1972 or 1972/20/2">

    <af:convertDateTime 
           secondaryPattern="d/M/yyyy" pattern="yyyy/M/d" 
           convertDateMessageDetail="&quot;{0}&quot; in &quot;{1}&quot;
                                  is not a valid date. Example: &quot;{4}&quot;/>
                                      
   </af:selectInputDate>
 

For a invalid input value say 2004/15/1 - It would result in error message:

"2004/15/1" in "Date of birth" is not a valid date. Example: "2005/11/29".

Copyright © 2003-2006, Oracle Corporation. All Rights Reserved.

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy