« January 2008 | Main | May 2008 »

April 2008 Archives

April 2, 2008

How To Avoid The JBO-27014 Error During The AutoSubmit


When your ADF Faces page includes a component with the property autoSubmit set to true, you get the following error:

JBO-27014: Field <fieldName> in <AppModule>.<ViewObject> is mandatory

for a component with the property immediate set to true.

This happens f.ex. when you try to populate a Description field as soon as the end user typed the Code value.

This error is raised because of the immediate on the component, what implies that the component's value will
be validated before any input components that do not have the immediate
attribute set to true.
At the time of the validation, this component hasn't got its value yet and the error is raised.


You can easily workaround this problem as the following:

  1. in the backing bean, add a boolean variable ppr true when a Partial Request occurs:
    (...)
    import oracle.adfinternal.view.faces.renderkit.core.xhtml.PartialPageUtils;
    (...)
    private boolean ppr;
    (...)
    public void setPpr(boolean ppr) {
       this.ppr = ppr;
    }

    public boolean isPpr() {
       FacesContext fctx = FacesContext.getCurrentInstance();
       return PartialPageUtils.isPartialRequest(fctx);
    }
    (...)

  2. use it in the required property of the mandatory field:
    <af:inputText ...
                  required="#{! backing_validation.ppr}"
                  immediate="true" ... />

April 21, 2008

invokeAction Invoked Twice

Symptom

Suppose you published an Application Module method as a client method, f.ex.:
public void yourMethod() {
   System.out.println("Hello World");
}

You created an ADF Faces page and included the following in your page definition (<yourPage>PageDef.xml):
...
  <executables>
    ...
    <invokeAction Binds="yourMethod" id="executeYourMethodAction"
                  RefreshCondition="${!adfFacesContext.postback}"/>
    ...
  </executables>
  <bindings>
...
  <methodAction id="yourMethod" InstanceName="AppModuleDataControl.dataProvider"
                DataControl="AppModuleDataControl" MethodName="yourMethod"
                RequiresUpdateModel="true" Action="999"
                IsViewObjectMethod="false"/>
  </bindings>
</pageDefinition>

The aim is to execute yourMethod when the page first renders (controlled by the RefreshCondition).
The method is correctly executed, but you see it's executed twice.
The Log window of JDeveloper shows:
Hello World
Hello World 

Cause

The property Refresh is not defined for the invokeAction.
Its default value is ifNeeded, what means that the related action binding will be invoked twice during each request.


Solution


You should change the default Refresh setting for the invokeAction bindings to either prepareModel or renderModel.
With prepareModel, your invokeAction will be invoked before the JSF invokeApplication phase.
With renderModel, your invokeAction will be invoked after the JSF invokeApplication phase.

Since JSF's invokeApplication phase is when the JSF action events fire, you should decide if you want your invokeAction to trigger before (prepareModel) or after (renderModel) the action listeners have performed their processing,

For more information, see the ADF Develoepr's Guide, topic "10.5.5.3 Correctly Configuring Refresh Property of InvokeAction Executables"


April 23, 2008

Application Lifecycle Management Tools Survey


Sunsan Duncan
has opened a 8 question online survey
to find out what Application Lifecycle Management (ALM) tools our
customers (or any software developers as it's not restricted to JDeveloper
users) use. 

The aim  is to add better integration with ALM tools in JDeveloper, and product management is interested in knowing what tools are most used today so they can better serve the needs. 

If you have any interests in that area, please have a look and fill in the survey.
You can find Susan's request on her blog.

Thanks in advance !

April 30, 2008

Only Rendered ADF Faces Components Can React To PPR


This question comes regularly at Oracle Support and in the forums.
You want to show (render) and hide an ADF Faces component dynamically on your page, depending on the value of another component.

Suppose f.ex. a Radio Group with 2 buttons "Show" and "Hide'.
Clicking "Show" should display a button; it should disappear when clicking "Hide".
For that, you defined a selectOneRadio that saves the values "show" and "hide" in your backing bean, in an attribute "radioBtnValue":

            <af:selectOneRadio label="Show/Hide" id="yourSelectOneRadio"
                               value="#{Backing.radioBtnValue}"
                               autoSubmit="true">
              <af:selectItem label="Show" value="show"/>
              <af:selectItem label="Hide" value="hide"/>
            </af:selectOneRadio>
You then defined your button as the following:
            <af:commandButton text="Button"
                              rendered="#{Backing.radioBtnValue=='show'}"
                              partialTriggers="yourSelectOneRadio"/>
Because of the partialTriggers property, you are expecting the button to be updated when an event occurs on the selectOneRadio.
The rendered property should then be re-evaluated and set to true when the button "Show" was clicked.

Unfortunately, it doesn't work

You cannot use PPR (Partial Page Rendering)
to directly toggle the "rendered" attribute of a component.
You have to wrap
the component (with the rendered attribute) in a parent component and set the
partialTriggers in its parent.
The reason is that only components that
are rendered can react to PPR.

In the example above, you can create a parent with the partialTriggers property, a panelGroup f.ex.:


            <af:panelGroup partialTriggers="yourSelectOneRadio">
                 <af:commandButton text="Button"
                                   rendered="#{Backing.radioBtnValue=='show'}"/>
               </af:panelGroup>

When an event occurs on the selectOneRadio, the parent component will react to PPR.
During the PPR,
the parent component and all its children will be updated.

the rendered property of the button will be evaluated and the button
displayed or hidden accordingly


I added sample 7 to my ADF Sample Applications page.


About April 2008

This page contains all entries posted to Didier's Blog in April 2008. They are listed from oldest to newest.

January 2008 is the previous archive.

May 2008 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle