struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Butash, Bob" <bob.but...@eds.com>
Subject RE: what's the best way to have an if/else clause?
Date Fri, 02 Apr 2004 15:18:39 GMT
Jay,

Have you looked into JSTL's choose tag?

<core:choose>
<core:when test='${ empty requestScope.activeMenu || requestScope.activeMenu
== "displayHome"}'>
	<tr class="Selected">
	<td class="LeftNavigation">
		<bean-el:message key="navigation.left.home"/>
	</td>
	</tr>
</core:when>
<core:otherwise>
	<tr class="NotSelected">
	<td class="LeftNavigation">
	<html-el:link action="displayHome">
		<bean-el:message key="navigation.left.home"/>
	</html-el:link>
	</td>
	</tr>
</core:otherwise>
</core:choose>

Hope this helps

-----Original Message-----
From: Glanville, Jay [mailto:Jay.Glanville@NaturalConvergence.com] 
Sent: Friday, April 02, 2004 10:10 AM
To: user@struts.apache.org
Subject: what's the best way to have an if/else clause?


I want to iterate over a set of beans, creating widget A if property is set,
widget B if not.  Therefore, I'm looking for an "if/else" structure.  The
closest thing I can find is <logic:equal> and <logic:notEqual>.  I'm
assuming that there is no straight forward way to implement an 'else' clause
in tags, so I'm thinking that I need to so something like the following:

<logic:iterate name="SearchForm" 
    property="tableDesc.batchAction" 
    id="element" >
  <logic:equal name="id" parameter="isSubmit" value="true">
    <!-- insert <html:button> here -->
  </logic:equal>
  <logic:notEqual name="id" parameter="isSubmit" value="true">
    <!-- insert <html:submit> here -->
  </logic:equal>
</logic:iterate>

Basically, to implement the else clause by performing a second if statement.

Is this the correct way to do things?  Is there a better way?  Would I be
better off using scriptlet code?

JDG

--
Jay Glanville

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message