I like the direction this is going. My thoughts on this...
 I like the syntax familiar syntax <set-if name="styleClass" value="#{shale:
attribute.class}"/>
 However, how about instead of inventing a new syntax "#{shale:
attribute.class}" we use the existing one. For example
 <set name="styleClass" value="#{clayContext.symbols['class']}"/>
 This approach assumes that clay has defined the existing clay context as a
managed-bean in request scope and pushed it's value appropriately during the
evaluation. So styleClass is evaluted just like any other VB.
 This also takes care of the set-if case, because if the symbol is not
defined in the symbols map then the result will be null, and you would not
get <span class="">..</span> but rather the correct response of
<span>...</span> in the case that the class symbol is not set.
 So just to explain further.. in clays faces-config.xml
 <managed-bean>
 <managed-bean-name>clayContext</managed-bean-name>
 <managed-bean-class>org.apache.shale.clay.component.chain.ClayContext
</managed-bean-class>
 <managed-bean-scope>request</managed-bean-scope>
</managed-bean>

That way there is not need to invent a new el evaluation and no need to add
<set-if>
  On 11/5/05, Craig McClanahan <[EMAIL PROTECTED]> wrote:
>
> On 11/5/05, Rahul Akolkar <[EMAIL PROTECTED]> wrote:
> >
> > On 11/5/05, Gary VanMatre <[EMAIL PROTECTED]> wrote:
> >
> > > > For the class substitution case that conditionally sets styleClass
> > only if
> > > > class is actually specified, either the element would need to be
> smart
> > > > about knowing whether there was really a value there, or we could do
> a
> > "set
> > > > if" operation that only performed the set if the expression
> evaluated
> > to
> > > > something other than null or empty string:
> > > >
> > > > <set-if name="styleClass" value="#{shale:attribute.class}"/>
> > > >
> > > > where the expression would evaluate the value of the "class"
> > attribute, if
> > > > it exists, and perform the set only if a non-null non-empty-string
> > value was
> > > > returned by evaluating the expression.
> > > >
> > >
> > > That's a interesting idea. Or, we might be able to use a new
> > "bindingType" in the "set" node. But, a "set-if" might be more
> descriptive.
> > >
> > <snap/>
> >
> > Does that mean there are scenarios where one wouldn't want the
> > behavior in Craig's first suggestions (a "smart" if)? If there aren't,
> > IMO, it makes sense to do that since this is one of the cases where
> > less is more and not having to remember to differentiate between <set>
> > and <set-if> is a good thing while authoring.
>
>
> Good point. I cannot think of any use cases for the non-conditional
> setting
> off the top of my head, but a "conditional pass-through only if the origin
> is not null" seems like a very common case.
>
> Craig
>
>
> -Rahul
> >
> >
> > > > Craig
> > > >
> > >
> > > Gary
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>

Reply via email to