You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Terry McBride <tt...@yahoo.com> on 2001/11/16 22:45:42 UTC
Cannot get correct Layout with my Reflect(ing) Screen
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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Pull Tool Re: Cannot get correct Layout with my Reflect(ing) Screen
Posted by Terry McBride <tt...@yahoo.com>.
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 <tt...@yahoo.com> 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:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
=====
"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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>