You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ashutosh Satyam <as...@alopa.com> on 2005/02/23 11:19:48 UTC

Clarrifications on Usage of logic tag library

Hi,
 Can you suggest how to use the logic tag library to achieve the following scenario.
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 In my Action class I expect few Exceptions to be thrown. Incase if any exception 
 is throw it's always redirected to a common 'error.jsp' page.

 In this page I wanted to use 'logic' taglibrary to present a different content in the 
 page based on the Exception thrown.
 
 Something like - 
  if( Exception1) {
    some html contents
} else if(Exception2) {
    some html contents
} else {
   some html contents
}
 
Also how do we achieve logical AND and logical OR condtion using logic tag library

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 I hope we can use the logic taglibrary in the scenario what I pointed out. An example 
 for the same would suffice my requirement.

Regards,
Ashutosh



Re: Antwort: Clarrifications on Usage of logic tag library

Posted by Joe Germuska <Jo...@Germuska.com>.
At 11:40 AM +0100 2/23/05, Karsten Krieg wrote:
>Hi!
>
>It's been suggested to not continue using the Struts own tag libraries and
>instead move on to the JSTL. With them, I'd construct the following for
>your scenario:

while this is a good general suggestion, neither tag library makes it 
easy to deal with the class of an exception.  I suppose technically 
you could use bean properties to test against the string form of an 
exceptions' class name:
<c:if test="${ex.class.name == 'java.lang.IllegalStateException'}">..</c:if>

but you might simply find Struts' own declarative exception handling 
to be a more straightforward way to deal with this...

Joe


><%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
>
><c:choose>
>       <c:when test="${exception1}">
>             your content
>       </c:when>
>       <c:when test="${exception2}">
>             your content
>       </c:when>
></c:choose>
>
>You can nest the c:when and c:choose, so AND and OR constructs are
>possible.
>
>With regards
>Karsten Krieg
>intarsys consulting GmbH
>----------------------------------------
>Fon +49 (0)721 3 84 79 - 28
>Fax +49 (0)721 3 84 79 - 60
>e-mail kkrieg@intarsys.de
>http://www.intarsys.de
>----------------------------------------
>
>"Ashutosh Satyam" <as...@alopa.com> schrieb am 23.02.2005 11:19:48:
>
>>  Hi,
>>   Can you suggest how to use the logic tag library to achieve the
>>  following scenario.
>>
>>  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>
>>   In my Action class I expect few Exceptions to be thrown. Incase if
>>  any exception
>>   is throw it's always redirected to a common 'error.jsp' page.
>>
>>   In this page I wanted to use 'logic' taglibrary to present a
>>  different content in the
>>   page based on the Exception thrown.
>>
>>   Something like -
>>    if( Exception1) {
>>      some html contents
>>  } else if(Exception2) {
>>      some html contents
>>  } else {
>>     some html contents
>>  }
>>
>>  Also how do we achieve logical AND and logical OR condtion using
>>  logic tag library
>>
>>  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>
>>   I hope we can use the logic taglibrary in the scenario what I
>>  pointed out. An example
>>   for the same would suffice my requirement.
>>
>>  Regards,
>>  Ashutosh
>>
>>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org


-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex

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


Antwort: Clarrifications on Usage of logic tag library

Posted by Karsten Krieg <kk...@intarsys.de>.
Hi!

It's been suggested to not continue using the Struts own tag libraries and
instead move on to the JSTL. With them, I'd construct the following for
your scenario:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

<c:choose>
      <c:when test="${exception1}">
            your content
      </c:when>
      <c:when test="${exception2}">
            your content
      </c:when>
</c:choose>

You can nest the c:when and c:choose, so AND and OR constructs are
possible.

With regards
Karsten Krieg
intarsys consulting GmbH
----------------------------------------
Fon +49 (0)721 3 84 79 - 28
Fax +49 (0)721 3 84 79 - 60
e-mail kkrieg@intarsys.de
http://www.intarsys.de
----------------------------------------

"Ashutosh Satyam" <as...@alopa.com> schrieb am 23.02.2005 11:19:48:

> Hi,
>  Can you suggest how to use the logic tag library to achieve the
> following scenario.
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>
>  In my Action class I expect few Exceptions to be thrown. Incase if
> any exception
>  is throw it's always redirected to a common 'error.jsp' page.
>
>  In this page I wanted to use 'logic' taglibrary to present a
> different content in the
>  page based on the Exception thrown.
>
>  Something like -
>   if( Exception1) {
>     some html contents
> } else if(Exception2) {
>     some html contents
> } else {
>    some html contents
> }
>
> Also how do we achieve logical AND and logical OR condtion using
> logic tag library
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>
>  I hope we can use the logic taglibrary in the scenario what I
> pointed out. An example
>  for the same would suffice my requirement.
>
> Regards,
> Ashutosh
>
>




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