Don't use screen objects, use pull tool(s). Read the pull-tool docs on the
Turbine site.  The only reason left for needing a screen object is security.
Name your screen template the same as the layout you want to use: 

       /layouts
           Printable.vm
           Default.vm
       /screens 
           Printable.vm
           Index.vm
           Other.vm  

When Index.vm and Other.vm are rendered, turbine will use Default.vm.  When
the Printable.vm screen is rendered, it will use the Printable.vm layout.

-----Original Message-----
From: Terry McBride
To: Turbine Users List
Sent: 11/16/01 4:00 PM
Subject: Pull Tool Re: Cannot get correct Layout with my Reflect(ing) Screen


Dookie!

After reading the NumberFormatter Pull Tool thread,
maybe I should be making this a pull tool.

BUT, I'm still tired of having a bazillion Screen
classes that are the same thing over and over.  How
can I have one Screen serve different screen templates
AND LAYOUT TEMPLATES and have it work correctly (not
use Layout DefaultLayout - during my investigation I
had set default.layout to DefaultLayout it TR.props;
this is the layout I'm seeing).

--- Terry McBride <[EMAIL PROTECTED]> wrote:
> Hi, 
> 
> I'm trying to write a VelocityScreen that allows me
> to
> set the velocity templates to use as layout and
> screen
> from parameters.  I get the appropriate object
> passed
> to the appropriate screen, but the layout is screwed
> up.  No matter what I do I keep getting a/the
> DefaultLayout with top and bottomg containing the
> text: 
>      "Turbine - A Servlet Framework for building
> Secure Dynamic Websites."
> 
> In my screen $data.getLayout() returns
> VelocityECSLayout and $data.getLayoutTemplate()
> returns the outline parameter ("/Display.vm") but
> the
> appropriate layout is not used.
> 
> Can anyone shed some light?
> 
> I've had data.setScreenTemplate() in place of
> setTemplate() as well.
> 
> 
> extends VelocityScreen CODE:
> 
>     /**
>      * Place the componenet in the context
>      * for use in the template. 
>      * Uses OMUtils to locate the componenent.
>      * expect component=Class of the component and
> the
> component id to be placed in params
>      */
>     public void doBuildTemplate( RunData data,
> Context
> context )
>     {
> 
>       // get the component (ie. Quote, Organization,
> Image)
>       String className =
> data.getParameters().get("component");
> 
>       if (className != null && className != "")
>       {
> 
>               BaseObject object = null;
> 
>               try 
>               {
> 
>                       // Find the appropriate method in OMUtils and
> invoke it
>                       String methodName = "find" + className;
> 
>                       Class[] paramTypes = {
> Class.forName("org.apache.turbine.util.RunData") };
>                       Object[] paramList = { data };
> 
>                       Class OMClass =
>
Class.forName("edu.stanford.mlkpp.launchpads.utils.OMUtils");
>                       Method finder = OMClass.getMethod(methodName,
> paramTypes);
>                       object = (BaseObject) finder.invoke(null,
> paramList);
>               }
>               catch (Exception e)
>               {
>                       data.setMessage("Error finding component with
> className " + className);
>                       e.printStackTrace();
>                       setTemplate(data, "Error.vm");
>               }
> 
>               if (object != null)
>                       context.put(className.toLowerCase(),
> object);
> 
>       }
>       else
>       {
>                       data.setMessage("No component parameter found");
>                       setTemplate(data, "Error.vm");
>       }
> 
>       // set template and layout      
>       String view = data.getParameters().get("view");
>       String outline =
> data.getParameters().get("outline");
> 
> System.out.println(" found view " + view + " and
> outline " + outline);
> 
>       try {
>               if (view != null) {
>                       setTemplate(data, view);
>               }
> 
>               if (outline != null) {
>                       setLayout(data, "VelocityECSLayout");
>                       data.setLayoutTemplate(outline);
>               }
>       } catch (Exception e) {
>               e.printStackTrace();
>       }
>     }
> 
> 
> 
> =====
> "I'm concerned about a better world. I'm concerned
> about justice; I'm concerned about brotherhood; I'm
> concerned about truth. And when one is concerned
> about that, he can never advocate violence. For
> through violence you may murder a murderer, but you
> can't murder murder. Through violence you may murder
> a liar, but you can't establish truth. Through
> violence you may murder a hater, but you can't
> murder hate through violence. Darkness cannot put
> out darkness; only light can do that."
> 
> -M. L. King, Jr., 16 August 1967
> 
> __________________________________________________
> Do You Yahoo!?
> Find the one for you at Yahoo! Personals
> http://personals.yahoo.com
> 
> --
> To unsubscribe, e-mail:  
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 


=====
"I'm concerned about a better world. I'm concerned about justice; I'm
concerned about brotherhood; I'm concerned about truth. And when one is
concerned about that, he can never advocate violence. For through
violence you may murder a murderer, but you can't murder murder. Through
violence you may murder a liar, but you can't establish truth. Through
violence you may murder a hater, but you can't murder hate through
violence. Darkness cannot put out darkness; only light can do that."

-M. L. King, Jr., 16 August 1967

__________________________________________________
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com

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

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

Reply via email to