>From: Simon Kitching <[EMAIL PROTECTED]> > > Hi Koshi, > > Generally, having the component tree vary dynamically is not done with > JSF. If you want a choice of two different components, then typically > you define both of them in the page, then use the "rendered" property to > ensure that only the one you want is output. > > There is certainly no JSF tag in standard JSF or Tomahawk that allows a > random component to be inserted into the tree. I don't initially see why > it wouldn't be possible to do this, but it certainly isn't common JSF > practice AFAIK. > > If you *did* want to create such a component, I can imagine one that has > a single child; on encodeBegin it evaluates its value expression, sets > that component as its child then passes on the encodeBegin call. All > other component methods would get delegated down to the child as normal. >
I found a nifty mechanism in Trinidad to programmatically build the component tree. It's called an InternalView. The internal view is a pseudo view hander that can be associated with a specific view id. It looks like Trinidad uses it to build custom popup dialogs for some of the components. I was playing with this idea for Clay/Trinidad integration. These is a testbed in the shale sandbox that I've been hacking on. This implementation just adds a Clay component to the view root and assignes a template from a query string parameter, jsfid. http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/PageHandler.java?view=markup The Trinidad view handler looks for registered internal views by view id. You create the mapping by using a properties file that has a constant name and lives under the META-INF directory. http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/resources/META-INF/org.apache.myfaces.trinidad.render.InternalView.properties?view=log > Regards, > > Simon Gary > > koshi wrote: > > I have a managed bean with a method that returns a UIComponent, > > sometimes a commandLink or a outputText. > > > > public UIComponent getComponent () > > { > > UIComponent link ; > > if (this.isAction ()) { > > link = new HtmlCommandLink (); > > link.setTitle (this.title); > > > > MethodBinding method = FacesContext.getCurrentInstance > > ().getApplication (). > > createMethodBinding (this.value, null); > > link.setAction (method); > > } > > else { > > link = new HtmlOutputText (); > > link.setValue (this.title); > > } > > > > return link; > > } > > > > > > Then, in the view i imagine something like that > > : > > > > > > > > is this possible or i have to create a custom component ??? > > > > > > thanks in advance, and sorry for my english mistakes. >

