on 5/30/01 2:12 PM, "Mark Glass" <[EMAIL PROTECTED]> wrote:

> I have adapted the new app application to examine the users role and
> select a different screen according to the users role. (Actually I want
> to change the screen color depending on the users role).

First off, you shouldn't do that based on Role. You should do it based on
Permission. There is generally no need to check based on Roles.

> I created two new screens called BlueIndex.vm and  GreenIndex.vm.  by
> copying Index.vm in the Screens directory. I then added the following code

A better way to do this is to simply point at one Screen. Then, within that
Screen, do this:

    #if ($data.ACL.hasPermission("green"))
        #set ($color = "#00FF00")
    #elseif ($data.ACL.hasPermission("blue"))
        #set ($color = "#0000FF")
    #end

>  public void doBuildTemplate( RunData data, Context context )
>  {
>      context.put("entries", getEntries());
>      if ( data.getACL ().hasRole ("accounting") )
>      {
>          data.setLayout("GreenIndex");
>          data.setScreen ("GreenIndex");
> 
>      }
>      else if ( data.getACL ().hasRole ("development") )
>      {
>          data.setScreen ("/BlueIndex");
> 
>      }

This is also wrong. You need to set the template, not the Screen. Just call
setTemplate("BlueIndex.vm")

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to