Hello Greg,

I am trying to have a different set of menu depending on the permission of
the user.
This was implemented by creating Default.java where isAuthorised is used to
set different layout

   protected boolean isAuthorized(RunData data)  throws Exception
    {
        boolean isAuthorized = false;

        AccessControlList acl = data.getACL();

        if (acl == null || !acl.hasRole("turbine_root"))
        {

data.setScreenTemplate(Turbine.getConfiguration().getString("template.login"
));
            isAuthorized = false;
        }
        else if (acl.hasRole("turbine_root") && acl.hasRole("admin"))
        {
            data.setLayoutTemplate("AdminDefault.vm");
            isAuthorized = true;
        }
        else if (acl.hasRole("turbine_root"))
        {
            isAuthorized = true;
        }
        return isAuthorized;
    }

This worked out nicely until I tried to change the screen template and the
layout template
reverted back to Default.vm

I prefered this way as I did not have to include the checking in every
template.

Is this going against the MVC paradigm?

Is there inheritance in Velocity Template ?

Regards,
Naree
--
Media Equation
71 - 73 Thistlethwaite Street
South Melbourne 3205
Australia
Tel:    + 613 9673 8111
Fax:   + 613 9690 4244

----- Original Message -----
From: "Greg Kerdemelidis" <[EMAIL PROTECTED]>
To: "'Turbine Users List'" <[EMAIL PROTECTED]>
Sent: Monday, November 24, 2003 9:03 AM
Subject: RE: Layout Template Change


>
> Hmm. Generally, the accepted behaviour with layouts is to set them in the
> template being rendered. It makes a degree of sense to re-initialise the
> layout when rendering a "new" template, otherwise layout changes could
> continue across all pages (whether you want it or not).
>
> If you really insist on setting the layout template in code (the MVC
police
> might get you), try re-arranging the order:
>
> data.setScreenTemplate("blah.vm");
> data.setLayoutTemplate("layout.vm");
>
> It obvious that setLayoutTemplate() reassigns the layout. A much better
> policy is something like:
>
> ------blah.vm----
>
> $data.setLayoutTemplate("/layout.vm")
>
> <p>Rest of template</p>
>
> -----------------
>
> It never hurts to be explicit about the way a page should be rendered. If
it
> has a number of different ways of being rendered, control it with a
> parameter or a key in the context.
>
> Hope this helps.
>
> Regards,
>
> Greg Kerdemelidis
>
> > -----Original Message-----
> > From: Naree Song [mailto:[EMAIL PROTECTED]
> > Sent: Friday, 21 November 2003 7:21 p.m.
> > To: Turbine Users List
> > Subject: Layout Template Change
> >
> > Hello,
> >
> > I found a strange behaviour with Layout Template.
> > It seems that when the Screen template gets changed
> > in screen class using setScreenTemplate,
> > the Layout template reverts back to the default Layout template.
> >
> > **** code *******
> >       else
> >       {
> >         log.info(data.getLayoutTemplate());
> >
> >         data.setScreenTemplate("PayMe.vm");
> >
> >         log.info(data.getLayoutTemplate());
> >       }
> >
> >
> > ***** log ***
> > 2003-11-21 17:09:59,942 [Thread-5] INFO
> > com.me.mepay.modules.screens.PayMeResult - AdminDefault.vm
> > 2003-11-21 17:09:59,947 [Thread-5] INFO
> > com.me.mepay.modules.screens.PayMeResult - Default.vm
> >
> > Is this an expected behaviour?
> >
> > Regards,
> > Naree
> > --
> > Media Equation
> > 71 - 73 Thistlethwaite Street
> > South Melbourne 3205
> > Australia
> > Tel:    + 613 9673 8111
> > Fax:   + 613 9690 4244
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



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

Reply via email to