Hi,
as you can see:
2005-08-05 13:43:35,688 [http-8080-Processor24] INFO - RENDER_RESPONSE(6) 
[EMAIL PROTECTED]
2005-08-05 13:43:35,688 [http-8080-Processor24] INFO - RENDER_RESPONSE(6) null

All states are executed twice....the first RENDER_RESPONSE works fine, but in 
the second one my [EMAIL PROTECTED] gets lost. But actually I don't now why.

##### MessagePhaseListener.beforePhase ######

public void beforePhase(PhaseEvent event) {
                
                Integer i = new Integer(0);             
                FacesContext facesContext = FacesContext.getCurrentInstance();
                BaseController controller = (BaseController) 
FacesContext.getCurrentInstance().getApplication().getVariableResolver().resolveVariable(facesContext,
 "baseControllerBean");              
                internalMessage = controller.getNotification();
                controller.log.info(event.getPhaseId() + " " + internalMessage);
                if(event.getPhaseId() == PhaseId.RENDER_RESPONSE) {
                        i++;
                        if(i == 0) {
                                controller.log.info(internalMessage);
                                if(internalMessage == null) {
                                        String notification = 
Utils.getMessageResourceBundle(controller.getBundle(), 
"internalStandardMessage", null, controller.getLocale());
                                        FacesMessage standardMessage = new 
FacesMessage(FacesMessage.SEVERITY_INFO, notification, notification);
                                        
facesContext.addMessage("globalMessage", standardMessage);
                                } else {
                                        
facesContext.addMessage("globalMessage", internalMessage);
                                }               
                        }
                        else {
                                controller.resetNotification();                 
        
                        }                       
                }
        }


Regards Johannes

"MyFaces Discussion" <[email protected]> schrieb am 05.08.05 13:55:30:
> no...
>  
>  I don't understand the logs, either - you have the message at the beginning 
> of the render-response phase and when does it get lost?
>  
>  regards,
>  
>  Martin
> 
> On 8/5/05, Johannes Hiemer <[EMAIL PROTECTED]> wrote: 
> Hi Martin,
> after trying to implement the phaseListener I got stuck at this point:
> It seems to be, that the phaseListener is loosing the message:
> 2005-08-05 13:43:35,657 [http-8080-Processor24] INFO - RESTORE_VIEW(1) [EMAIL 
> PROTECTED]
> 2005-08-05 13:43:35,657 [http-8080-Processor24] INFO - RESTORE_VIEW(1) [EMAIL 
> PROTECTED]
> 2005-08-05 13:43:35,688 [http-8080-Processor24] INFO - RENDER_RESPONSE(6) 
> [EMAIL PROTECTED]
> 2005-08-05 13:43:35,688 [http-8080-Processor24] INFO - RENDER_RESPONSE(6) null
> 2005-08-05 13:43:35,890 [http-8080-Processor24] INFO -
> 
> Do you know why this happens? 
> 
> Regards JOhannes
> 
> "MyFaces Discussion" <[email protected]> schrieb am 05.08.05 12:08:12:
> > no, you can't save values in the phaseListener. 
> >
> >  you would acquire a reference to your managed bean by doing:
> >
> >          FacesContext.getCurrentInstance().getApplication().
> >                  
> > getVariableResolver().resolveVariable(FacesContext.getCurrentInstance 
> > (),"yourBeanName");
> >
> >  ...except you can do a phaseEvent.getFacesContext() instead of 
> > FacesContext.getCurrentInstance()
> >
> >  regards,
> >
> >  Martin
> >
> > On 8/5/05, Johannes Hiemer < [EMAIL PROTECTED]> wrote:
> > Hi,
> > good to know, that there another ways to do it.
> > In my solution the problem with a PhaseListener would be, that I need to 
> > get the current instance of a BaseController, or is it possible to save 
> > values to a phaseListener, and to dispense with my BaseController completly?
> >
> > Richard are you still alive? :-)  What do you think?
> >
> > Regards Johannes
> >
> > "MyFaces Discussion" <[email protected] > schrieb am 05.08.05 
> > 11:24:28:
> > >
> > > I don't know if this can helps you but there is the way to handle
> > > messages throw redirects, the Matt Raible' way  into appFuse/JSF :
> > > 
> > >
> > > the message filter :
> >  >  
> > https://appfuse.dev.java.net/source/browse/appfuse/extras/jsf/src/web/org/appfuse/webapp/filter/MessageFilter.java?rev=1.1&view=auto&content-type=text/vnd.viewcvs-markup
> > >
> > > the BasePage with addMessage method 
> > >  
> > > https://appfuse.dev.java.net/source/browse/appfuse/extras/jsf/src/web/org/appfuse/webapp/action/BasePage.java?rev=1.1&view=auto&content-type=text/vnd.viewcvs-markup
> > >  
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > 2005/8/5, Martin Marinschek <[EMAIL PROTECTED]>: 
> > > >
> > > >
> > > > ---------- Forwarded message ----------
> > > > From: Martin Marinschek < [EMAIL PROTECTED]> 
> > > > Date: Aug 5, 2005 11:05 AM
> > > > Subject: Re: Messages and navigation rule redirects post
> > > > To: Johannes Hiemer < [EMAIL PROTECTED]>
>  > > >
> > > > Nice solution,
> > > >
> > > >  even though a bit verbose... You might want to try a phase-listener 
> > > > wich
> > > > you add before the render response phase and which checks for this bean 
> > > > and 
> > > > adds the messages to the context instead of doing that in a bean as 
> > > > well.
> > > >
> > > >  regards,
> > > >
> > > >  Martin
> > > >
> > > >
>  > > > On 8/5/05, Johannes Hiemer < [EMAIL PROTECTED]> wrote:
> > > > >
> > > > > Hi Richard, Hi Martin,
> > > > > perhaps I got something. I took my time this morning and spend it 
> > > > > trying 
> > > > some things. In my implementation I got a standard BaseController for 
> > > > all my
> > > > handlers. So I thought, why should I use this BaseController to save 
> > > > this
> > > > message for a while. After a few minutes I got a working solution. 
> > > > > Here is my code:
> > > > >
> >  > > > ##### BaseController #####
> > > > >
> > > > > private static FacesMessage notification;
> > > > > 
> > > > >         /**
> > > > >          * @return Returns the notification.
> > > > >          */
> > > > >         public FacesMessage getNotification() {
> > > > >                 return notification;
> > > > >         }
> > > > >
> > > > >         /**
> > > > >          * @param notification The notification to set.
> > > > >          */ 
> > > > >         public void setNotification(FacesMessage notification) {
> > > > >                 this.notification = notification;
> > > > >         }
> > > > >
> > > > > ###### faces-config.xml ########
> > > > >
> > > > > <managed-bean>
> > > > > 
> > > > <managed-bean-name>BaseController</managed-bean-name>
> > > > >                 <managed-bean-class>
> > > > >
> > > > itecon.web.resource.BaseController
> > > > >                 </managed-bean-class>
> > > > >
> > > > <managed-bean-scope>session</managed-bean-scope>
> > > > >         </managed-bean>
> > > > >
> > > > > 
> > > > > This is my BaseController, now we get to the SparepartHandler.java 
> > > > > where
> > > > actually the first stept happens.
> > > > >
> > > > > public String add() {
> > > > >                 message = this.getMessage();
> > > > >                  log.info (message);
> > > > >                 String notification =
> > > > Utils.getMessageResourceBundle(getBundle(), "internalDatasetExists", 
> > > > null,
> > > > getLocale());
> > > > >                 setNotification(new
> > > > FacesMessage(FacesMessage.SEVERITY_INFO, notification, notification));
> > > > >                 return message;
> > > > >         }
> > > > >
> > > > > As you can see, I get my notification from my ResourceBundle of the
> > > > Application. After the I put it through BaseController.setNotification 
> > > > into
> > > > my private static FacesMessage notification;
> > > > > Till here - fine.
> > > > >
> > > > > No I have a second managed bean called: NotificationHandler. 
> > > > >
> > > > > ##### NotificationHandler.java #######
> > > > >
> > > > > public class NotificationHandler extends BaseController implements
> > > > Serializable { 
> > > > >
> > > > >         private String hiddenField = null;
> > > > >
> > > > >         public void pageLoad() {
> > > > >                 log.info(getNotification());
> > > > >                 facescontext.addMessage("globalMessage",
> > > > getNotification());
> > > > >         }
> > > > >
> > > > >         /**
> > > > >          * @return Returns the hiddenField. 
> > > > >          */
> > > > >         public String getHiddenField() {
> > > > >                 return hiddenField;
> > > > >         }
> > > > >
> > > > >         /**
> > > > >          * @param hiddenField The hiddenField to set.
> > > > >          */ 
> > > > >         public void setHiddenField(String hiddenField) {
> > > > >                 this.hiddenField = hiddenField;
> > > > >         }
> > > > > }
> > > > >
> > > > > The hiddenField was created because I don't know another way to 
> > > > > initialize
> > > > the managed-bean through my success.jspx
> > > > > That's my managed bean in my faces-config.xml
> > > > >
> > > > > ###### faces-config.xml #####
> > > > > <managed-bean>
> > > > > 
> > > > <managed-bean-name>notificationSpringBean</managed-bean-name>
> > > > >                 <managed-bean-class>
> > > > >
> > > > itecon.web.controller.NotificationHandler
> > > > >                 </managed-bean-class>
> > > > >
> > > > <managed-bean-scope>session</managed-bean-scope>
> > > > >                 <managed-property>
> > > > >
> > > > <property-name>pageLoad</property-name>
> > > > >                         <value>true</value>
> > > > >                 </managed-property>
> > > > >         </managed-bean>
> > > > >
> > > > > And last but not least my success.jspx.
> > > > >
> > > > > ####### success.jspx ######
> > > > >
> > > > > <h:form id="form">
> > > > >         <h:panelGrid columns="3" styleClass="parentTable"
> > > > headerClass="tableHeader" columnClasses="childTable"> 
> > > > >                 <f:facet name="header">
> > > > >                         <h:outputText id="closer"
> > > > value="YIIPPIIEIIOOO SCHWEINEBACKE" />
> > > > >                 </f:facet>
> > > > >                 <h:inputHidden id="hiddenField"
> > > > value="#{notificationSpringBean.hiddenField}" />
> > > > >                 <x:messages id="globalMessage" layout="table"
> > > > >                 showSummary="true" showDetail="false" />
> > > > >         </h:panelGrid>
> > > > > </h:form>
> > > > >
> > > > >
> > > > > As attachement the result. 
> > > > > To proove it:
> > > > > Here the extract of my Resources.properties
> > > > > internalDatasetExists=Dataset already exists
> > > > >
> > > > > Try it, tell me If I am wrong, or if there better ways to do it. 
> > > > >
> > > > > Regards Johannes
> > > > >
> > > > >
> > > > ______________________________________________________________
> > > > > Verschicken Sie romantische, coole und witzige Bilder per SMS! 
> > > > > Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193
> > > > >
> > > > >
> > > > >
> > > > > 
> > > >
> > > >
> > >
> > >
> > > --
> > >
> > > hicham ABASSI
> > > [EMAIL PROTECTED]
> >
> >
> > ______________________________________________________________ 
> > Verschicken Sie romantische, coole und witzige Bilder per SMS!
> > Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193
> >
> >
>  >
> 
> 
> ______________________________________________________________
> Verschicken Sie romantische, coole und witzige Bilder per SMS!
> Jetzt bei WEB.DE FreeMail:  http://f.web.de/?mc=021193
> 
> 
>  


______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193

Reply via email to