The excludeIf tag

Overview

This tag is used to conditional exclude a part of a JSP page.

Tag Usage

This tag is used as follows:

<jee:excludeIf [condition="some boolean value"] | [name="beanInstanceName"
property="boolean property or property returning object"] | [name="beanInstanceName"
property="some property" value="true value for property"] | [role="role
name"] | [resource="resource name] >

Elements exclude if tag is ‘true’</jee:excludeIf>·

condition – This attribute must be a boolean expression. If it equates to true, the conditional block is excluded.

name & property – If these two attributes are set on the tag then the tag evaluates the property on the specified bean. This property should return a boolean or an object. If the property returns a boolean and it’s true the conditional block is excluded. If the property returns an object, the conditional block is excluded if the property does not return null.

name & property & value – If these three attributes are set on the tag then tag evaluates the property on the specified bean. If the property’s value matches the value specified in the value attribute then the conditional block is excluded.

role – If this attribute is set on the tag, then the tag queries the security provider to set if the current user has the specified role. If they do then the conditional block is excluded. This attribute requires that the user to be logged in. The enforceLogin tag should be used before an includeIf tag with a role attribute.

resource – If this attribute is set on the tag, then the tag queries the security provider to set if the current user has access to the specified resource. If they do then the conditional block is excluded. This attribute requires that the user to be logged in. The enforceLogin tag should be used before an includeIf tag with a resource attribute.

Example

The following code shows an example of using this tag:

<%@ taglib uri="jeenius" prefix="jee" %> 
<jsp:enforceLogin redirectUrl="not_logged_in.jsp"/> <jsp:useBean
id="myBean" class="example.MyBean"/> <html>  <head>
<title>excludeIf example</title>  <head>  
 <body>  
<jee:excludeIf condition="<%= 1=1 %>"> <p>One equals
One !</p> </jee:excludeIf >  
<jee:excludeIf name="myBean" property="booleanValue">
<p>mybean.getBooleanValue() returned true !</p> </jee:excludeIf>
<jee:excludeIf name="myBean" property="objectValue">
<p>mybean.getObjectValue() returned non null !</p>
</jee:excludeIf >  
<jee:excludeIf name="myBean" property="someValue" value="xyz">
<p>mybean.getSomeValue() returned "xyz"</p>
</jee:excludeIf>  
<jee:excludeIf role="xyz"> <p>Current user has role "xyz"</p>
</jee:excludeIf >  
<jee:excludeIf resource="abc"> <p>Current user has access to resource "abc"</p> </jee:excludeIf >  
 </body>
</html>