On 2/6/06, Gary VanMatre <[EMAIL PROTECTED]> wrote: > > >On 2/6/06, Ryan Wynn <[EMAIL PROTECTED]> wrote: > >> > >> It seems the binding attribute is not getting set until the restore > >> view phase. For example if I have > >> > >> <component> > >> <attributes> > >> <set name="binding" value="#{foo.bar}" bindingType="VB"/> > >> ... > >> > >> setBar is not called until the view is restored. I would have thought > >> that I would have access to the component during the initial render > >> phase. > >> > >> What I would like to do is during render have getBar() return me a > >> reference to the UIComponent, but of course it returns null. > >> > >> Is this a bug or a misunderstanding on my part? > > > > > >The "binding" attribute is evaluated and reattached in the Restore View > >phase of the request processing lifecycle, and I know this works > correctly > >for components in JSP pages (Creator 2 sets up bindings for *all* > >components). Maybe there needs to be is something interesting going on > >inside Clay for this attribute? > > > > I agree. I took a peek at the myfaces UIComponentTag and in the > "createComponentInstance" method there is a check for the existence of > a "binding" attribute. If there is one, the component instance pulled > from > the target managed bean. Otherwise, it's using the createComponent > factory > method on the application. > > The Clay component is not respecting the "binding" attribute when creating > the component subtree. It should use the binding attribute to create the > component > and ignore it when setting the property values of the component. > > Does this sound correct?
It's actually slightly more complicated. The spec language covering Restore View phase related to this attribute is in Section 2.2.1: For each component in the component tree, determine if a value binding for "binding" is present. If so, call the setValue() method on this value binding, passing the component instance on which it was found. And there is functionality on the UIComponentTag.findComponent() method that essentially does this: * Does the JSP tag for this component have a "binding" attribute? If not, just call Application.createComponent(String) with the appropriate component type. * If the "binding" attribute is present, use it to call Application.createComponent(ValueBinding) instead. In Clay, since you don't have custom tags to do this, you'll have to make sure that this logic is followed in ClayViewHandler.createView() -- the net effect is that the backing bean can, if it wishes to, preconfigure a component instance for you, which should be used instead of asking the component factory to create a new instance. private HtmlInputText username = new HtmlInputText(); { username.setLength(30); } public HtmlInputText getUsername() { return this.username; } public void setUsername(HtmlInputText username) { this.username = username; } The tree building process will use this instance if you have a binding to "#{backingbean.username}". Craig > > >>Thanks, > >> Ryan > >> > > > > > >Craig > > Gary > > >