this is the code from MyFaces, and it shows that the phase listener
should only be added once:

        // add phase listeners
        for (Iterator iterator =
_dispenser.getLifecyclePhaseListeners(); iterator.hasNext();)
        {
            String listenerClassName = (String) iterator.next();
            try
            {
                lifecycle.addPhaseListener((PhaseListener)
ClassUtils.newInstance(listenerClassName));
            } catch (ClassCastException e)
            {
                log.error("Class " + listenerClassName + " does not
implement PhaseListener");
            }
        }

I shortly looked over the rest of the code, don't see any problems there...

Maybe you got two faces-config.xml files in different directories and
this is why they are called twice?

regards,

Martin

On 6/15/05, Daniel Zwink <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> on 15.06.2005 00:57 Werner Punz said the following:
> >>
> >> I'm using Tomcat 5.5.9 and MyFaces 1.0.9. When I deploy my war-file
> >> the two debug-lines are printed twice on sysout with different
> >> hashcodes which indicates to me that the phase listener is instanced
> >> twice, too.
> >>
> >> If I request a JSF-Page the beforePhase- and afterPhase-method are
> >> also called twice for each phase.
> >>
> >> Is this normal behaviour? I hope not :-). Any hints?
> >>
> >>
> > did you check your rootId?
> >
> > String rootId = event.getFacesContext().getViewRoot().getViewId();
> >
> > the reason for doing that simply is, that the phase listeners
> > get chained, and basically at every request you run into the chain
> > of phase listeners sending different root ids, the phase listeners
> > are supposed to trigger on the phase (via callback) and on the rootid
> > which is sent into the listener cycle.
> 
> It's the same viewId. I don't think there are two requests (guessing you
> assumed that). I have no redirect and no forwarding - just a "plain"
> faces site with some content from a database (same behaviour if I call a
> simple "Hello World" page).
> 
> As I said, there seem to be two instances 'cause the constructor is
> called twice while deploying my test application to tomcat.
> 
> Any ideas?
> 
> 
> Daniel
> --
> Orientation in Objects GmbH
> Weinheimerstr. 68
> D-68309 Mannheim
> http://www.oio.de
> Tel +49(0)621-71839-0
> Fax. +49(0)621-71839-50
>

Reply via email to