dev@jsftemplating.java.net

Re: JSFTemplating: Is it possible to write JSFT component that wraps <f:selectItems />

From: Ken Paulsen <Ken.Paulsen_at_Sun.COM>
Date: Tue, 25 Sep 2007 14:14:36 -0700

Leonid Lamburt wrote:
> I have a follow up question then,
>
> I understand that it's possible to create another tag mergeSelectOneMenu.
>
> but that would be a major inconvenience for tag users, as they'll be
> forced to
> learn a new set of tags (in addition to JSF h: tags).
I think there's a learning curve in introducing the <myjsft:merg> as
well... but if you'd like to replace the h:selectItems tag with a
different factory... you can modify the
META-INF/jsftemplating/UIComponentFactory.map file in your
jsftemplating.jar file to point to your own custom factory. This will
allow f:selectOneMenu to function as normal + add your additional
functionality. Alternatively, you could build your own
jsftemplating.jar file after changing the
com.sun.jsftemplating.component.factory.ri.SelectOneMenuFactory file to
do what you want.
> I was thinking about just one tag that can be plugged into all h: tags
> that take f:selectItems, e.g.
Yes, this can also be done... although exactly as you described below,
you'll end up w/ a UIComponent underneath h:selectOneMenu (which may
just get ignored... not sure). Anyway, the factory for the
"myjsft:merge" UIComponent could manipulate the parent UIComponent and
add the f:selectItems after sorting, filtering, etc.

A handler (or two) would be a better approach, though:

<!afterCreate
    filter(items="#{geoController.USStatesAndTerritories}" filter="PR
VI" filteredList=>$attribute{filteredList});
    setSelectItems(items="#{filteredList}");
/>
>
> <h:selectOneMenu id="selectUSState" value="#{myBean.selectedState}">
> <myjsft:merge filterout="PR VI">
> <f:selectItems value="#{geoController.USStatesAndTerritories}" />
> </myjsft:merge>
> </h:selectOneMenu>
>
> I understand that if JSFT is using JSF RI facilities to render
> selectOneMenu, then it won't work out of the box. It will throw
> an exception (as the child is not an instance of UISelectItem/UISelectItems ).
>
> However, maybe it possible to create a component (for myjsft:merge tag)
> public class MergeSelectItems extends UISelectItems
> ?
>
Yes maybe, but I think you're making this more complicated than required.
> or more complicated:
> MergeSelectItems doesn't extend UISelectItems,
> but the framework swaps out MergeSelectItems for UISelectItems right before
>
Well, a "Factory" could instanticate UISelectItems directly, so this
probably doesn't need to happen.

Let me know what approach you want to explore... handlers might be the
best if you don't want a new tag (might be the best anyway). A new
factory would also be easy to implement.

Ken
> encodeBegin()
>
> and then puts it back after encodeEnd()
>
> ?
>
> Thanks.
>
>
>
>
> ------------------------------------------------------------------------
> Kick back and relax with hot games and cool activities at the
> Messenger Café. Play now!
> <http://www.cafemessenger.com?ocid=TXT_TAGLM_SeptWLtagline>