isUserInRole() - return boolean from custom tag?

Hello

Im writing some custom tags extending TagSupport. At the moment my tags just create some collection and put it in the page scope for the jsp to access. (see example below)

I have a tag however that I would like to return a boolean for. This is specifically for checking isUserInRole();

I cant quite get my head around the idea of manipulating the page body or not and how this impacts writing the custom tags. If I want to return some value directly from my tag ie. a boolean value from isUserInRole(); is this manipulating the page body?

Is TagSupport the correct class to extend if I want to return a boolean value from my tag call.

Id appreciate any advice.

Thanks

Jon

-

public class refSuppliersTag extends TagSupport {

public int doStartTag() throws JspException {

try {

.................

HashMap supplierMap = new HashMap();

supplierMap = (HashMap) referenceData.getSuppliers();

pageContext.setAttribute("suppliers", supplierMap);

} catch (Exception e) {

throw new JspException(e.toString());

}

return EVAL_PAGE;

}

.................

[1179 byte] By [Jonathan14a] at [2007-11-26 16:04:40]
# 1

this is one way of designing your tag:

In JSTL

<my:login var="isAdminRole" role="admin"/>

<!-- test for it -->

<c:if test="${isAdminRole}">

yeah, you are admin user!

</c:if>

In Java

//...

boolean isLoggedin = login();

session.setAttribute(var,isLoggedin);

// where "var" is a String tag attribute!

//...

put the "boolean" result in "var", which is a session's parameter, request's parameter or whatever!

by Avatar Ng

[blog http://avatar21.superihost.com/ ]

Message was edited by:

Avatar_Ng

Avatar_Nga at 2007-7-8 22:26:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...