You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Dave Polito <da...@planetcad.com> on 2001/03/30 02:24:25 UTC
Patch: TurbineJspService.java
This fixes a problem with the using the TurbineJspService. The service did
not implement the TemplateEngineService, which caused a ClassCast Exception.
Adding the following line to the TR.prop file which is needed for the jsp
setup.
services.TurbineTemplateService.template.service.name=JspService
Can somebody add this to
http://jakarta.apache.org/turbine/jsp-configuration.html ?
SUMMARY:
Changes made by jvanzyl on 01/03/28 14:22:47, were not included in
TurbineJspService.java.
Change summary;
Added the implements of TemplateEngineService
Added a simple templateExists(String template) method.
Index: TurbineJspService.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine/src/java/org/apache/turbine/services/jsp/Tur
bineJspService.java,v
retrieving revision 1.9
diff -u -w -r1.9 TurbineJspService.java
--- TurbineJspService.java 2001/03/06 22:40:43 1.9
+++ TurbineJspService.java 2001/03/30 00:11:17
@@ -68,7 +68,9 @@
import org.apache.turbine.util.*;
import org.apache.turbine.om.security.*;
import org.apache.turbine.services.jsp.util.*;
+import org.apache.turbine.services.servlet.TurbineServlet;
+import org.apache.turbine.services.template.TemplateEngineService;
/**
* This is a Service that can process JSP templates from within a Turbine
* screen.
@@ -76,7 +78,7 @@
* @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
*/
public class TurbineJspService extends TurbineBaseService
- implements JspService
+implements JspService, TemplateEngineService
{
/** The base path prepended to filenames given in arguments */
private String path;
@@ -216,6 +218,32 @@
bufferSize = Integer.parseInt(props.getProperty("buffer.size",
"8192"));
}
+ /**
+ * Use the specific template engine to determine whether
+ * a given template exists. This allows Turbine the TemplateService
+ * to delegate the search for a template to the template
+ * engine being used for the view. This gives us the
+ * advantage of fully utilizing the capabilities of
+ * template engine with respect to retrieving templates
+ * from arbitrary sources.
+ *
+ * @param String template
+ * @return boolean
+ */
+ public boolean templateExists(String template)
+ {
+ /*
+ * Check to make sure the template exists.
+ * path is set in the init() method.
+ */
+
+ if (new File(TurbineServlet.getRealPath(path), template).exists())
+ {
+ return true;
+ }
+ return false;
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: Patch: TurbineJspService.java
Posted by Jason van Zyl <jv...@apache.org>.
Dave Polito wrote:
>
> This fixes a problem with the using the TurbineJspService. The service did
> not implement the TemplateEngineService, which caused a ClassCast Exception.
>
> Adding the following line to the TR.prop file which is needed for the jsp
> setup.
>
> services.TurbineTemplateService.template.service.name=JspService
Sorry I didn't document it, but everything will work just fine
if you use the template service itself to do the searching
services.TurbineTemplateService.template.service.name=TurbineTemplateService
would have done the trick. I did this so that using other template
engines wouldn't be a problem. Or until somebody implemented the
the required methods to satisfy the interface.
>
> Can somebody add this to
> http://jakarta.apache.org/turbine/jsp-configuration.html ?
>
> SUMMARY:
> Changes made by jvanzyl on 01/03/28 14:22:47, were not included in
> TurbineJspService.java.
>
> Change summary;
> Added the implements of TemplateEngineService
> Added a simple templateExists(String template) method.
>
> Index: TurbineJspService.java
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-turbine/src/java/org/apache/turbine/services/jsp/Tur
> bineJspService.java,v
> retrieving revision 1.9
> diff -u -w -r1.9 TurbineJspService.java
> --- TurbineJspService.java 2001/03/06 22:40:43 1.9
> +++ TurbineJspService.java 2001/03/30 00:11:17
> @@ -68,7 +68,9 @@
> import org.apache.turbine.util.*;
> import org.apache.turbine.om.security.*;
> import org.apache.turbine.services.jsp.util.*;
> +import org.apache.turbine.services.servlet.TurbineServlet;
>
> +import org.apache.turbine.services.template.TemplateEngineService;
> /**
> * This is a Service that can process JSP templates from within a Turbine
> * screen.
> @@ -76,7 +78,7 @@
> * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
> */
> public class TurbineJspService extends TurbineBaseService
> - implements JspService
> +implements JspService, TemplateEngineService
> {
> /** The base path prepended to filenames given in arguments */
> private String path;
> @@ -216,6 +218,32 @@
> bufferSize = Integer.parseInt(props.getProperty("buffer.size",
> "8192"));
> }
>
> + /**
> + * Use the specific template engine to determine whether
> + * a given template exists. This allows Turbine the TemplateService
> + * to delegate the search for a template to the template
> + * engine being used for the view. This gives us the
> + * advantage of fully utilizing the capabilities of
> + * template engine with respect to retrieving templates
> + * from arbitrary sources.
> + *
> + * @param String template
> + * @return boolean
> + */
> + public boolean templateExists(String template)
> + {
> + /*
> + * Check to make sure the template exists.
> + * path is set in the init() method.
> + */
> +
> + if (new File(TurbineServlet.getRealPath(path), template).exists())
> + {
> + return true;
> + }
> + return false;
> + }
> +
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
--
jvz.
Jason van Zyl
jvanzyl@apache.org
http://jakarta.apache.org/velocity
http://jakarta.apache.org/turbine
http://tambora.zenplex.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: Patch: TurbineJspService.java
Posted by Jon Stevens <jo...@latchkey.com>.
on 3/29/01 4:24 PM, "Dave Polito" <da...@planetcad.com> wrote:
> This fixes a problem with the using the TurbineJspService. The service did
> not implement the TemplateEngineService, which caused a ClassCast Exception.
>
> Adding the following line to the TR.prop file which is needed for the jsp
> setup.
>
> services.TurbineTemplateService.template.service.name=JspService
>
> Can somebody add this to
> http://jakarta.apache.org/turbine/jsp-configuration.html ?
In the future, for FYI, the source of this document is in Turbine's cvs tree
under the xdocs directory. So, also sending in a patch for that is good as
well. :-)
> SUMMARY:
> Changes made by jvanzyl on 01/03/28 14:22:47, were not included in
> TurbineJspService.java.
>
> Change summary;
> Added the implements of TemplateEngineService
> Added a simple templateExists(String template) method.
done! thanks!
-jon
--
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org