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]>