You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jo...@apache.org on 2001/10/16 11:09:56 UTC
cvs commit: jakarta-turbine-3/src/java/org/apache/turbine/pipeline Renderer.java
jon 01/10/16 02:09:56
Modified: src/java/org/apache/turbine/pipeline Renderer.java
Log:
added javadoc
added the concept of being able to pass in a default template in case one
cannot be found. this is a pretty cool feature if you are using
navigations and you want to be able to render a specific navigation for a
specific template and if it doesn't exist, then render a specific default
navigation file.
Revision Changes Path
1.3 +37 -2 jakarta-turbine-3/src/java/org/apache/turbine/pipeline/Renderer.java
Index: Renderer.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/Renderer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Renderer.java 2001/09/01 16:58:11 1.2
+++ Renderer.java 2001/10/16 09:09:56 1.3
@@ -60,6 +60,13 @@
import org.apache.turbine.TurbineException;
import org.apache.turbine.Log;
+/**
+ * This class is used in the context to render templates.
+ *
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
+ * @version $Id: Renderer.java,v 1.3 2001/10/16 09:09:56 jon Exp $
+ */
public class Renderer
{
public String render(String moduleType, RunData data, String template)
@@ -67,8 +74,36 @@
{
Turbine.getModuleLoader().getModule(moduleType, template).execute(data);
- //!! I shouldn't need that slash in there.
return Module.handleRequest(Module.getTemplateContext(data),
- moduleType + "/" + template);
+ getFullPath(moduleType, template));
+ }
+
+ /**
+ * Attemps to locate the template and if it can't find it, then
+ * it will attempt to render the defaultTemplate
+ */
+ public String render(String moduleType, RunData data, String template,
+ String defaultTemplate)
+ throws TurbineException,Exception
+ {
+ String output = null;
+ if (Module.templateExists(getFullPath(moduleType, template)))
+ {
+ output = render(moduleType, data, template);
+ }
+ else
+ {
+ output = render(moduleType, data, defaultTemplate);
+ }
+ return output;
+ }
+
+ /**
+ * Concatinates the moduleType with the template
+ */
+ public String getFullPath(String moduleType, String template)
+ {
+ //!! I shouldn't need that slash in there.
+ return moduleType + '/' + template;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org