AnsweredAssumed Answered

hiding controls

Question asked by timurso on Dec 9, 2008
Latest reply on Dec 9, 2008 by timurso
Hi!
does anybody know, am I right here:

<%
<%!
  /** this function converts an array of cookies into a hashtable */
  Hashtable cookieTable(Cookie[] cookies) {
    Hashtable cookieTable = new Hashtable();
    if (cookies != null) {
      for (int i=0; i < cookies.length; i++)
        cookieTable.put(cookies[i].getName(), cookies[i].getValue());
    }
    return cookieTable;
  }
%>
<%!
  String isAdmin(HttpServletRequest request)
{
  String name = new String();
  Boolean isAdmin = new Boolean(false);
  Hashtable cookies = cookieTable(request.getCookies());

  if (cookies.containsKey("alfUser"))
  {
    name = (String)cookies.get("alfUser");
    if (name.indexOf("@")==-1)
    {
       isAdmin = true;
    }
  }
  return isAdmin;
}
%>
[…]
<a:booleanEvaluator value="<%isAdmin(request).toString()%>" id="evaluator">
   <h:outputText value="sometext" />
</a:booleanEvaluator>
[…]

this output text is not rendered as booleanEvaluator gets incorrect value! Java code itself is tested and is correct, but I'm suspicious about request parameter- maybe there are multiple requests and when booleanEvaluator is rendered, that request doesn't have specific cookie I'm looking for?
if I just put 
<%=isAdmin(request).toString%>
elsewhere, it gets correct value and if I'm logged in as admin, it shows correct boolean value!

Outcomes