javahtmlwebobjects

WebObjects: Using WOConditional inside <div>


I am in a situation where the "class" attribute of a div tag should be dependent on the value of a java binding. This can be easily done by moving the associated logic to the java class, but at this moment we are not allowed to change anything at the Java component.

I am trying out the following to resolve the problem (using WOOGNL):

<div class="<wo:WOConditional condition = \"[cssClassDecider]\">classToUse</wo:WOConditiona>" > 
HTML Static Content
</div>

As it can be seen, i am trying to use value of "cssClassDecider" to set the class.

Can anybody tell if any has solved a similar problem or one is available at WO.


Solution

  • It's not clear to me whether cssClassDecider is providing the string content for the class attribute, or a boolean to drive a conditional. In any case, the usual pattern would be:

    <wo:WOGenericContainer elementName="div" class="$methodReturningClassNames">
      ...
    </wo:WOGenericContainer>
    

    If cssClassDecider returns a conditional, you could do something like this:

    <wo:WOConditional condition="$cssClassDecider">
      <div class="classWhenTrue">
        ...
      </div>
    </wo:WOConditional>
    <wo:WOConditional condition="$cssClassDecider" negate="$true">
      <div class="classWhenFalse">
        ...
      </div>
    </wo:WOConditional>
    

    If neither of those solve your problem, provide some more information.