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.


Comments:

Hi, This is not really a comment, but I dont your email id to ask you this. Any help regarding my question on af:selectInputDate is greatly appreciated. I have a date component in my jsp page which has a valueChangeListener attached to it. If I enter manually a 2 digit year, eg., 01/01/08, its giving 01/01/0008 inspite a converter is also attached to it. For other date components in the same page without valueChangeListener, its converting to 01/01/2008. Thanks,

Posted by Madhu on October 22, 2008 at 07:58 AM CEST #

Hi Madhu, you are right: it has nothing to do with this blog entry. I hope you understand it's not possible for me to answer your question with the information you provided. I would advise you to post your question to our OTN forum: http://forums.oracle.com/forums/forum.jspa?forumID=83 Please read this post fiirst: http://forums.oracle.com/forums/ann.jspa?annID=56 and detail your question: what's the version of JDeveloper, code snippet, ... Regards, Didier.

Posted by Didier on October 22, 2008 at 02:27 PM CEST #

Post a Comment:
Comments are closed for this entry.
About

Didier Laurent - Sr Principal Support Engineer in the JDeveloper team

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today