incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Winer" <awi...@gmail.com>
Subject Re: Must refresh page to get returnListener value from dialogs
Date Thu, 22 Feb 2007 17:11:14 GMT
All you need to do is redo that outputText:

                         <tr:outputText value=""
                                        binding="#{passwordRetrDialog.output}"
                                        rendered="false"/>

to

                         <tr:outputText
                                        binding="#{passwordRetrDialog.output}"
                                        partialTriggers="buddonId"/>

... and remove the code that calls setRendered() from your
return listener.

Three things to know:
(1) returnListeners always come with partial-page rendering
(2) Setting partialTriggers will repaint the outputText when that
  commandLInk fires.
(3) Partial-page rendering cannot deal with changes to "rendered",
   at least not on the top component that is being re-rendered.
   So in a situation like this, either leave it rendered all the time
   (which will work fine here), or put partialTriggers on the parent.

-- Adam


On 2/22/07, Causevic, Dzenan <dcausevic@navisite.com> wrote:
>
> I use dialogs for user to be able to retrieve his password if he forgets it. On the login
page I have a link 'forgot your password' that opens up external window via dialogs where
the user can enter his username and click on the 'Send' button for his password to be sent
to him. Now I want the external window to close automatically upon clicking on Submit button,
and the message (success or failure) to be displayed in the parent window from which external
window was originally called. I use returnListener for this however my problem is I have to
refresh the page to see the message. After I submit send button, external window closes, but
the message is not being displayed on the parent page. I have to refresh the page it in order
to be able to see it.
>
> loginJSF.jsp is a parent page:
>                       <h:panelGroup>
>                           <tr:outputText value=""
>                                          binding="#{passwordRetrDialog.output}"
>                                          rendered="false"/>
>                           <tr:commandLink id="buddonId"
>                                           inlineStyle="margin-left:10px;"
>                                           action="dialog:passwordRetr"
>                                           text="Forgot your password?"
>                                           useWindow="true" windowWidth="500"
>                                           partialSubmit="true"
>                                           returnListener="#{passwordRetrDialog.returned}"/>
>                       </h:panelGroup>
>
> passwordRetrJSF.jsp is JSF page that opens in external window:
>                      <h:panelGroup>
>                           <h:outputText escape="false" value="<!--Enter E-mail
-->" />
>                           <h:outputText id="userName2L" styleClass="labelText" value="E-mail*"
/>
>                           <h:inputText id="User_Name2TI_R" styleClass="inputText"
value="#{passwordRetr.userName}" />
>                           <tr:commandButton id="retrieveB" action="#{passwordRetr.send}"
text="Submit" inlineStyle="margin-left:10px;" />
>                       </h:panelGroup>
>
> PasswordRetrBean.java:
> import org.apache.myfaces.trinidad.context.RequestContext;
>
> public class PasswordRetrBean {
>
>     private String _userName;
>
>     /** Creates a new instance of PasswordRetrBean */
>     public PasswordRetrBean() {
>         setUserName("address@host");
>     }
>
>     public String getUserName() {
>         return _userName;
>     }
>
>     public void setUserName(String userName) {
>         this._userName = userName;
>     }
>
>     public String send()
>     {
>         String firstPart = "first part ";
>         String secondPart = " second part";
>         // check if user name is valid using getUserName()
>         // if yes then
>             // firstPart = "something ";
>             // secondPart = " something";
>         // if no then
>             // firstPart = "something else ";
>             // secondPart = " something else";
>         // end of if statement
>         RequestContext.getCurrentInstance().returnFromDialog(firstPart+getUserName()+secondPart,
null);
>         return null;
>     }
> }
>
> PasswordRetrDialogBean.java:
> import org.apache.myfaces.trinidad.event.ReturnEvent;
> import org.apache.myfaces.trinidad.component.UIXOutput;
>
> public class PasswordRetrDialogBean {
>
>     private UIXOutput _output;
>
>     /** Creates a new instance of PasswordRetrDialogBean */
>     public PasswordRetrDialogBean() {
>         setOutput(null);
>     }
>
>     public UIXOutput getOutput() {
>         return _output;
>     }
>
>     public void setOutput(UIXOutput output) {
>         _output = output;
>     }
>
>     public void returned(ReturnEvent event)
>     {
>         if (event.getReturnValue() != null)
>         {
>             getOutput().setRendered((boolean)true);
>             getOutput().setValue(event.getReturnValue());
>         }
>     }
> }
>
> faces-managed-beans.xml:
>   <managed-bean>
>       <managed-bean-name>passwordRetr</managed-bean-name>
>       <managed-bean-class>com.navisite.view.beans.PasswordRetrBean</managed-bean-class>
>       <managed-bean-scope>request</managed-bean-scope>
>   </managed-bean>
>   <managed-bean>
>       <managed-bean-name>passwordRetrDialog</managed-bean-name>
>       <managed-bean-class>com.navisite.view.beans.PasswordRetrDialogBean</managed-bean-class>
>       <managed-bean-scope>request</managed-bean-scope>
>   </managed-bean>
>
> faces-navigation.xml:
>     <navigation-rule>
>         <from-view-id>/jsp/registration/loginJSF.jsp</from-view-id>
>         <navigation-case>
>             <from-outcome>login</from-outcome>
>             <to-view-id>/jsp/registration/personalInfoJSF.jsp</to-view-id>
>         </navigation-case>
>         <navigation-case>
>             <from-outcome>dialog:passwordRetr</from-outcome>
>             <to-view-id>/jsp/registration/passwordRetrJSF.jsp</to-view-id>
>         </navigation-case>
>     </navigation-rule>
>
> This e-mail is the property of NaviSite, Inc. It is intended only
> for the person or entity to which it is addressed and may contain
> information that is privileged, confidential, or otherwise protected
> from disclosure. Distribution or copying of this e-mail, or the
> information contained herein, to anyone other than the intended
> recipient is prohibited.
>

Mime
View raw message