right.

we use in Trinidad a special FacesBean concept. You register properties like:

 static public final PropertyKey RENDERED_KEY =
   TYPE.registerKey("rendered", Boolean.class, Boolean.TRUE);
 static public final PropertyKey BINDING_KEY =
   TYPE.registerKey("binding");
...


so saveState (only used in UIXComponentBase) looks like:

 public Object saveState(FacesContext context)
 {
   return getFacesBean().saveState(context);
 }

also the getter and setter look much cleaner.

HTH,
Matthias


On 10/22/06, Martin Marinschek <[EMAIL PROTECTED]> wrote:
Hi Randahl,

look into Trinidad and the StateManager for an alternative.

regards,

Martin

On 10/18/06, Randahl Fink Isaksen <[EMAIL PROTECTED]> wrote:
>
>  I was wondering if there were any alternatives to this approach of creating
> and populating arrays in each and every one of your components - has anyone
> tried using reflection to do all of this automatically. Surely for simple
> components one could easily run through its getter methods and extract the
> values to generate the Object[] automatically.
>
>  Has anyone tried such alternative approaches?
>
>  Randahl
>
>
>
>
>  Cagatay Civici wrote:
> The example you posted is the old code of UISaveState. It's has a special
> usage.
>
>  Actually you don't need to care about valuebindings. There is a special map
> that holds the valuebindings of a component in UIComponentBase, this map is
> saved-restored in each postback.
>
>
> On 10/18/06, Randahl Fink Isaksen <[EMAIL PROTECTED]> wrote:
> > Actually I finally found an example on the web in which the restoreState
> > method actually takes responsibility of restoring the value bindings
> > internal state (see below) - can anyone confirm that this is the right
> > approach for properties with value bindings?
> >
> > Randahl
> >
> >
> > public Object saveState(FacesContext context) {
> >   Object values[] = new Object[2];
> >   values[0] = super.saveState(context);
> >   values[1] = getValue();
> >   return values;
> > }
> >
> > public void restoreState(FacesContext context, Object state) {
> >   Object values[] = (Object[]) state;
> >   super.restoreState(context, values[0]);
> >   Object savedValue = values[1];
> >   ValueBinding vb = getValueBinding("value");
> >   if (vb != null) {
> >   vb.setValue(context, savedValue);
> > }
> >
> >
> >
> >
> > Randahl Fink Isaksen wrote:
> > > I have been looking through a number of MyFaces components to see how
> > > state saving was implemented, and it turns out that all the components
> > > I have checked simply implement the saveState and restoreState methods
> > > by returning an Object[] containing their private properties.
> > >
> > > But I keep asking myself "what about value bound properties?" If I
> > > have a component which has a property X which may be bound to
> > > #{someBean.someProperty} does that not mean that I need to restore the
> > > value of the value binding?
> > >
> > > I would expect that restoreState should check if X was bound with a
> > > value binding and then restore the value of the value binding instead.
> > > Could anyone please elaborate? Thanks.
> > >
> > > Randahl
> > >
> > >
> > >
> >
> >
>
>


--

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces



--
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Reply via email to