Brian Ferris wrote:
I'm not sure what that Struts Taglib "way" to do the following task would look like:

I've got a bean on the ValueStack with a "boolean isActive()" getter. When active, I'd like to construct html like:

<div class="baseStyle active"><!-- complex html in here --></div>

And when in-active, I'd like to construct:

<div class="baseStyle"><!-- complex html in here --></div>

The only real difference is the class attribute, which always has a "baseStyle" class, but should also have an "active" class when the bean is active.

Using struts taglibs inside a JSP, what's the easiest way to make that construction? I have some ideas... but they all seem kind of akward.

The easiest way is using JSTL instead:

  <div class="baseStyle${active ? 'active' : ''}">...

You can do the equivalent using struts tags + OGNL, which would look something like

  <div class="baseStyle<s:property value="#{...}"/>">...

It's more cumbersome, and you'd have to work out from the OGNL docs exactly what you need to substitute for #{...} [does OGNL support the ternary operator?].

However, it may be better to introduce semantic markers for active/inactive and use something like

  <div class="${activeStyle}"...

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to