myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rene Stehr" <Why-De...@gmx.de>
Subject SOLVED: ExtVal: ELHelper composite component problem
Date Wed, 02 Jun 2010 15:16:00 GMT
Hi Gerhard,

after some hours of intensive debbugging, I have found the differences between the EL resolution
at render and invoke-application time. It seems that the FacesContext is used as temporary
saving location for the NamingContainer of the composite component, which is currently rendered
(saved in the attributes-map with the key: UIComponent.CURRENT_COMPOSITE_COMPONENT). In the
class ContextualCompositeValueExpression, this attribute is read for the treatment of composite
components, which enables to resolve "cc.attrs" expressions. 

If I set the CURRENT_COMPOSITE_COMPONENT attribute manually before calling the ELHelper, the
return-value is not null and holds the expected data.

Code:
// "namingCont" is the NamingContainer which holds the current UIComponent "comp"

// set the naming container
fctx.getAttributes().put(UIComponent.CURRENT_COMPOSITE_COMPONENT, namingCont);

// get the property details
ELHelper helper = ExtValUtils.getELHelper();
PropertyDetails details = helper.getPropertyDetailsOfValueBinding(comp);

// remove the naming container
fctx.getAttributes().remove(UIComponent.CURRENT_COMPOSITE_COMPONENT);


However, I'm not sure if this could lead to negative side effects. I will test the methods
that you have recommended (UIComponent#invokeOnComponent UIComponent#visitTree). Maybe the
CURRENT_COMPOSITE_COMPONENT-attribute is set automatically while traversing the view-root.

Thank you in advance for your help

Best regards,
Rene


-------- Original-Nachricht --------
> Datum: Wed, 2 Jun 2010 11:55:40 +0200
> Von: Gerhard Petracek <gerhard.petracek@gmail.com>
> An: MyFaces Discussion <users@myfaces.apache.org>
> Betreff: Re: ExtVal: ELHelper composite component problem

> hi rene,
> 
> in addition to the suggestion of my previous e-mail:
> 
> you can also use a custom ProcessedInformationRecorder to create a
> (request
> scoped) storage which provides the required information.
> 
> regards,
> gerhard
> 
> http://www.irian.at
> 
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
> 
> Professional Support for Apache MyFaces
> 
> 
> 
> 2010/6/2 Rene Stehr <Why-Deeps@gmx.de>
> 
> >
> > Hello,
> >
> > I need for each UIInput object the backing bean and the attribute name
> that
> > are bound to this component.
> >
> > A simple example:
> >
> > // sample Backing Bean
> > @ManagedBean(name="person")
> > class Person{
> >  private String name;
> >  private String surname;
> >  private Address address;
> >  ...
> > }
> >
> > // sample xhtml-page
> > <h:inputText id="inputField1" value="#{person.name}"/>
> > <h:inputText id="inputField2" value="#{person.surname}"/>
> > <address:addressCC id="address" address="#{person.address}/>
> >
> > // sample composite component
> > <composite:interface>
> >  <composite:attribute name="address"/>
> > </composite:interface>
> > <composite:implementation>
> >  <h:inputText id="inputField3" value="#{cc.attrs.zipcode}"/>
> > </composite:implementation>
> >
> > The information I need is the value binding at runtime.
> > For this example, that would be:
> > 1. inputField1 => base object: person, attribute name:name
> > 2. inputField2 => base object: person, attribute name:surname
> > 3. inputField3 => base object: address, attribute name:zipcode
> >
> > If a have such a map, I am able to map the backend event "error occured
> at
> > 'Person.address.zipcode'" to the corresponding UIComponent.
> >
> > The simplest way to get this data is the method
> > ELHelper.getPropertyDetailsOfValueBinding(), which unfortunately does
> not
> > work for the inputField3.
> >
> > I hope that descibes my concern in more detail.
> >
> > Regards,
> > Rene
> >
> >
> > -------- Original-Nachricht --------
> > > Datum: Wed, 2 Jun 2010 03:36:27 -0500
> > > Von: Leonardo Uribe <lu4242@gmail.com>
> > > An: MyFaces Discussion <users@myfaces.apache.org>
> > > Betreff: Re: ExtVal: ELHelper composite component problem
> >
> > > Hi
> > >
> > > It could be good to have more information about what you are trying to
> > do.
> > > In myfaces there is a special code that handles "#{cc}" resolution,
> using
> > > the Location object to identify the right composite component from the
> > > composite component stack, so in theory mojarra could have something
> > > similar
> > > and that could be the source of the problem.
> > >
> > > regards,
> > >
> > > Leonardo Uribe
> > >
> > > 2010/6/2 Rene Stehr <Why-Deeps@gmx.de>
> > >
> > > >
> > > > Dear Gerhard,
> > > >
> > > > thank you for the quick reply. I am using the ExtVal library in my
> > > custom
> > > > code to get further information about the value binding in order to
> map
> > > > errors (from our backend) that occur at the Invoke Application phase
> to
> > > the
> > > > corresponding UIInput-fields. That means, I need to know for each
> > > > UIInput-object the bound backing bean object and the attribute name,
> > > both
> > > > are described by the EL expression in the value-attribute of the
> > UIInput
> > > > (e.g., #{cc.attrs.person.name} -> Backing Bean object is
> > > "person1:Person",
> > > > attribute name is "name"; person1 is just an example of an existing
> > > object
> > > > at runtime).
> > > >
> > > > If the ELHelper is not able to resolve "cc.attrs" expressions, I
> would
> > > be
> > > > grateful if you could recommend me another solution.
> > > >
> > > > Regards,
> > > > Rene
> > > >
> > > > -------- Original-Nachricht --------
> > > > > Datum: Wed, 2 Jun 2010 00:39:17 +0200
> > > > > Von: Gerhard Petracek <gerhard.petracek@gmail.com>
> > > > > An: MyFaces Discussion <users@myfaces.apache.org>
> > > > > Betreff: Re: ExtVal: ELHelper composite component problem
> > > >
> > > > > hi rene,
> > > > >
> > > > > are you using the implementation provided by extval for your
> custom
> > > code?
> > > > > or
> > > > > are you just using extval and the problem occurs during the
> > validation
> > > > > process?
> > > > >
> > > > > regards,
> > > > > gerhard
> > > > >
> > > > > http://www.irian.at
> > > > >
> > > > > Your JSF powerhouse -
> > > > > JSF Consulting, Development and
> > > > > Courses in English and German
> > > > >
> > > > > Professional Support for Apache MyFaces
> > > > >
> > > > >
> > > > > 2010/6/2 Rene Stehr <why-deeps@gmx.de>
> > > > >
> > > > > > Hello,
> > > > > >
> > > > > >
> > > > > >
> > > > > > I am using the ELHelper class in order to achieve information
> about
> > > the
> > > > > > value binding of UIComponents (the binded attribute and the
> > > > > corresponding
> > > > > > backing bean). This information can be received by the method
> > > > > > „ELHelper.getPropertyDetailsOfValueBinding(UIComponent)“,
> which
> > > > > returns a
> > > > > > PropertyDetails-object that contains the data I need.
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Here is the code:
> > > > > >
> > > > > > ELHelper helper = ExtValUtils.getELHelper();
> > > > > >
> > > > > > PropertyDetails details =
> > > > helper.getPropertyDetailsOfValueBinding(comp);
> > > > > //
> > > > > > The comp-Object is an instance of UIInput.
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > This solution works very well, however, if the comp-object is
> part
> > > of a
> > > > > > custom Composite Component, the details-object is always null.
I
> > > have
> > > > > > started to debug the ELHelper but until now I have no clue how
> it
> > > works
> > > > > in
> > > > > > detail. I suppose that the problem is caused by the
> “cc.attrs”
> > > > > expression
> > > > > > in
> > > > > > the value-binding of the composite components, e.g.,
> > > > > > #{cc.attrs.person.name}, that probably can not be resolved.
> > > > > >
> > > > > > I also tried to use the ValueExpression directly but this did
> not
> > > work
> > > > > as
> > > > > > well.
> > > > > >
> > > > > >
> > > > > >
> > > > > > Does anyone understand that problem or even have a solution?
> > > > > >
> > > > > >
> > > > > >
> > > > > > Thanks in advance for any help
> > > > > >
> > > > > > Regards,
> > > > > >
> > > > > > Rene
> > > > > >
> > > > > >
> > > > > >
> > > > > > -----------------
> > > > > >
> > > > > > Facts:
> > > > > >
> > > > > > JSF: mojarra 2.0.2
> > > > > >
> > > > > > ExtVal: 2.0.4 Snapshot
> > > > > >
> > > > > > Server: Apache Tomcat 6.0.26
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > >
> > > > --
> > > > GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> > > > Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> > > >
> >
> > --
> > GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> > Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> >

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

Mime
View raw message