webtier@glassfish.java.net

Re: [webtier] JSF2.0 Composite Component with f:param

From: Jim Driscoll <Jim.Driscoll_at_Sun.COM>
Date: Wed, 07 Jan 2009 17:10:12 -0800

No, you're absolutely not asking too many questions - early adopters are
the best way to shake out problems. And given that this is related not
just to implementation, but also specification, it's very, very
important for us to get the specification right.

As for your usecase - if there's a need to pass in 0 to n parameters,
where n is effectively unlimited, then yes, that's exactly a reason to
use param instead of an attribute.

If, on the other hand, you have 0 to n, where n is a known number, and
may be a small number (say, 5), and it is unlikely to change, then you
could instead use an attribute, since that'd be (IMO) simpler. (And you
can make attributes optional, instead of required, so that part isn't a
problem.)

As a temporary workaround while Ryan looks at this, one thing you could
do is to define a Map or a List to hold all your parameters, and pass
that in as an attribute - which should do the same thing, albeit in a
somewhat clunky way while we come up with a better answer. (Note that
passing a list to a component's attribute isn't a test case I've written
- but I'll file a task for us to do so. Should work, though.)

Jim

Lincoln Baxter, III wrote:
> Hey guys,
>
> Thanks so much for your attentive responses to my messages, let me know
> if I'm asking too many questions. I'm just trying to migrate a medium
> sized app (it's opensource but not ready for any kind of public release
> yet;) over to 2.0 which is why I'm running into these issues.
>
> To answer your question, the use case is that multiple parameters of the
> same type must be passed into the component. I'm not sure if there's a
> way to pass multiple parameters otherwise. There could be as few as
> zero, but as many as N parameters, as defined by a configuration file
> which maps URLs to JSF views.
>
> Thanks again,
> --Lincoln
>
> On Wed, 2009-01-07 at 09:21 -0800, Jim Driscoll wrote:
>> Hi Lincoln -
>>
>> Out of curiosity, why does it have to be a parameter, and not an
>> attribute? (This is completely separate from the question of whether it
>> should work or not, I'm just curious for the use case.)
>>
>> So, instead of
>> <ocp:link value="#{myBean.getMappingId}">
>> <f:param value="${myBean.name}" /> <!-- This param never makes it to
>> where it needs to go -->
>> My Link Text
>> </ocp:link>
>>
>> You would say:
>> <ocp:link value="#{myBean.getMappingId}" param="${myBean.name}" >
>> My Link Text
>> </ocp:link>
>>
>> Jim
>>
>> Lincoln Baxter, III wrote:
>> > Hi all,
>> >
>> > I'm attempting to create an EZComp composite:component that takes
>> > multiple <f:param value=""/> tags and passes them to a sub-element, but
>> > it seems like all children are encased within a UIOutput component, thus
>> > f:param tag is not available as a child of the EZComp component itself,
>> > and my renderer class is not getting the values it needs.
>> >
>> > <ocp:link value="#{myBean.getMappingId}">
>> > <f:param value="${myBean.name}" /> *<!-- This param never makes it
>> > to where it needs to go -->*
>> > My Link Text
>> > </ocp:link>
>> >
>> >
>> > Is there any way to pass a parameter directly through the component so
>> > that the internals receive the parameter? <f:facet> instead of
>> > <composite:insertChildren /> does not seem to work either, and would end
>> > up cluttering my interface. I just want a straight passthrough like the
>> > original <ui:insert /> behaved in facelets. Anything like it?
>> >
>> > Thanks,
>> >
>> > Here is my component:
>> >
>> > <html xmlns="http://www.w3.org/1999/xhtml"
>> > xmlns:h="http://java.sun.com/jsf/html"
>> > xmlns:f="http://java.sun.com/jsf/core"
>> > xmlns:ui="http://java.sun.com/jsf/facelets"
>> > xmlns:pretty="http://ocpsoft.com/prettyfaces"
>> > xmlns:composite="http://java.sun.com/jsf/composite">
>> >
>> > <composite:interface>
>> > <composite:attribute name="value" required="true" />
>> > <composite:attribute name="type" default="mapping" />
>> > <composite:attribute name="rendered" default="true" />
>> > </composite:interface>
>> >
>> > <composite:implementation>
>> > <f:subview id="linkGroup"
>> > rendered="#{compositeComponent.attrs.rendered ne 'false'}">
>> > <pretty:link mappingId="#{compositeComponent.attrs.value}"
>> > rendered="#{compositeComponent.attrs.type eq 'mapping' || empty
>> > compositeComponent.attrs.type}">
>> > <composite:insertChildren /> *<!-- This is where the param needs to
>> > go -->*
>> > </pretty:link>
>> > <h:outputLink value="#{compositeComponent.attrs.value}"
>> > rendered="#{compositeComponent.attrs.type eq 'url'}">
>> > <composite:insertChildren />
>> > </h:outputLink>
>> > </f:subview>
>> > </composite:implementation>
>> >
>> > </html>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: webtier-unsubscribe_at_glassfish.dev.java.net <mailto:webtier-unsubscribe_at_glassfish.dev.java.net>
>> For additional commands, e-mail: webtier-help_at_glassfish.dev.java.net <mailto:webtier-help_at_glassfish.dev.java.net>
>>