You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Eduardo Pelegri--Llopart <Ed...@eng.sun.com> on 2000/06/14 18:07:51 UTC

if syntax...

Craig proposes...

    <struts:ifCondition ...>
        ...
    </struts:ifCondition>
    <struts:else>
        ...
    </struts:else>

I think it will be hard to describe the exact semantics of this
construct.  E.g. what happens to the text between the IfCondition and
the else?  What happens if you have another ifCondition? what happens if
you have an else with no ifCondition...

The "traditional" approaches use nested tags and I think are not that
bad looking.  What about any of the following?  THe first two are
generic select mechanisms, the third one is a plain if.  You can have
more than one.

<!-- this one will choose the first condition that is true.  THis is a
typical lisp-like construct -->

<s:when>
  <s:test cond=" "> ... </s:test>
  <s:test cond="theother"> ... </s:test>
</s:when>

or

<!-- this is a typical case construct; values in the case values are
intended to be non-overlapping.  There may be a default value -->

<s:select selector="condition">
  <s:case value="true">....</s:case>
  <s:case value="false">...</s:case>
</s:select>

or

<!-- this is a plain if-then-else.  The false branch is optional.  -->

<s:if condition="condition">
  <s:true>....</s:true>
  <s:false>...</s:false>
</s:if>


	- eduard/o