myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tonio Caputo <ton...@exeo.com.ar>
Subject Re: ValueChangeEvent getSource()
Date Wed, 07 Jun 2006 22:10:06 GMT
Matthias, 

   I'll try to.

   This is what I suppose is happening in my faces,
    regarding this problem.

    1 - Restore View/Apply Request Value/Process Validations  Phases
	 - The Backing Bean is constructed
                - Old components are stored in the BackingBean with
		  their old values or new components are created and 
		  the old values are stored in them 
		  (really don't know exactly).
         - The Component Tree is updated with the new values.

    2 - ValueChangeListeners are called
         - The getValue() of the components returns the old value
         - UIComponents are not the same of those in the component tree

    3 - UpdateModel Phase
         - The UIComponents from the component tree are stored
           in the BackingBean.
         - This implies the the BackingBean getValue() methods
           return the new values.

   So when you call event.getSource() (in point (2)) the UIComponent
   returned is the one in the component tree, but not the one
   in the BackingBean. (this will not happen in ActionEvents that
   are executed after the UpdateModel Phase)

   In RI in point (2) the values and the components stored in
   the BackingBean are those of the new request, that's why it
   is working.


Hope it is clearer
if not just ask and I'll try again

Tonio

On Wed, 2006-06-07 at 14:16 -0700, Matthias Wessendorf wrote:
> I guess I didn't get you. sorry
> 
> so what is different between MyFaces and RI ?
> 
> Can you explain more detailed, so that fools like me can follow?
> :)
> 
> -Matthias
> 
> On 6/7/06, Tonio Caputo <tonioc@exeo.com.ar> wrote:
> > Matthias,
> >
> > Well, I understood what was going on.
> >
> > The event source correctly return the UIComponent that
> > generated the event, the problem is that the
> > BakingBean Components are not updated during the execution of the
> > ValueChangeListener.processValueChange() method.
> >
> > If I look the at the BakingBean after the UpdateModel phase, the
> > getSource() is correctly containing a reference to the updated
> > UIComponent.
> >
> > Thanks a lot, and I will use myFaces valueChangeNotifier for the rest
> > of my life.
> >
> > On Mon, 2006-06-05 at 20:12 -0700, Matthias Wessendorf wrote:
> > > Have you tried "getComponent()" which is defined in FacesEvent?
> > > The getSource() comes from java.util.Event clazz.
> > >
> > > In MyFaces getComponent() is *only*:
> > >    return (UIComponent) getSource();
> > >
> > >
> > > So can you tell us, what you get form a "getSource()" call?
> > >
> > > -Matthias
> > >
> > > On 6/5/06, Tonio Caputo <tonioc@exeo.com.ar> wrote:
> > > > Hi everybody,
> > > >
> > > > I'm moving my application from sun's implementation
> > > > (it's working ok) to myfaces.
> > > >
> > > > I'm using:
> > > >     jsf 1.1-01
> > > >     myfaces 1.1.1
> > > >
> > > > I'm having a difference in behavior regarding
> > > > valueChangeEvent source.
> > > >
> > > > My application:
> > > > ~~~~~~~~~~~~~~~
> > > >
> > > >    JSP    - Jsp with standard JSF components,
> > > >             all bound to components in a java Page
> > > >
> > > >    Page   - Java class with all components of the JSP page
> > > >           - It adds ValueChangeListeners to the components
> > > >             who need it.
> > > >           - Request Scope
> > > >
> > > > My code for ValueChangeListener looks something like this:
> > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > >
> > > >      public void processValueChange(ValueChangeEvent ev)
> > > >      {
> > > >         ......
> > > >         Object src=ev.getSource();
> > > >         if ( src.equals(_cmbCountry) ) do.......
> > > >         else if ( src.equals(_cmbAnyCode) ) do........
> > > >         else if ( src.equals(_cmbState) ) do......
> > > >         else
> > > >           do nothing .......
> > > >         ........
> > > >      }
> > > >
> > > >      where _cmbXXX are HtmlSelectOneMenu components
> > > >      defined in the Page class.
> > > >
> > > > The problem:
> > > > ~~~~~~~~~~~~
> > > >
> > > >         In my faces, the event source does not match any of the
> > > >         the components, in sun's implementation it does.
> > > >
> > > >         If I change the equals function for ==, it doesn't work
> > > >         either (as expected, there is a new Page for each request)
> > > >
> > > >
> > > > The question:
> > > > ~~~~~~~~~~~~~
> > > >
> > > >         Is this OK, a myfaces problem, a bad implementation (as usual)
> > > >         of sun's reference, or just worked by chance ?
> > > >
> > > >         The solution of this problem is easy, I'm just checking to see
> > > >         what goes on.
> > > >
> > > >
> > > > Thanks in advance
> > > > tonio
> > > >
> > > >
> > >
> > >
> >
> >
> 
> 


Mime
View raw message