You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by nb...@apache.org on 2004/11/11 07:22:45 UTC
cvs commit: jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/i18n MultiViewsTool.java
nbubna 2004/11/10 22:22:45
Modified: src/java/org/apache/velocity/tools/view/i18n
MultiViewsTool.java
Log:
use VelocityEngine instead of singleton
Revision Changes Path
1.5 +8 -7 jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/i18n/MultiViewsTool.java
Index: MultiViewsTool.java
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/i18n/MultiViewsTool.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MultiViewsTool.java 12 Mar 2004 20:30:32 -0000 1.4
+++ MultiViewsTool.java 11 Nov 2004 06:22:45 -0000 1.5
@@ -19,10 +19,8 @@
import java.util.Locale;
import javax.servlet.ServletContext;
-
-import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.context.Context;
-
import org.apache.velocity.tools.view.context.ViewContext;
import org.apache.velocity.tools.view.tools.ViewTool;
@@ -54,6 +52,8 @@
*/
protected String defaultLanguage;
+ protected VelocityEngine engine;
+
/**
* Creates a new uninitialized instance. Call {@link #init}
* to initialize it.
@@ -82,6 +82,8 @@
ViewContext context = (ViewContext)obj;
Context vc = context.getVelocityContext();
+ this.engine = context.getVelocityEngine();
+
defaultLanguage = (String) vc.get(DEFAULT_LANGUAGE_KEY);
if (defaultLanguage == null || defaultLanguage.trim().equals(""))
{
@@ -143,7 +145,7 @@
{
String localizedName = name + '.' + language;
// templateExists() checks for static content as well
- if (!Velocity.templateExists(localizedName))
+ if (!engine.templateExists(localizedName))
{
// Fall back to the default lanaguage.
String defaultLangSuffix = '.' + defaultLanguage;
@@ -155,7 +157,7 @@
else
{
localizedName = name + defaultLangSuffix;
- if (!Velocity.templateExists(localizedName))
+ if (!engine.templateExists(localizedName))
{
localizedName = name;
}
@@ -163,6 +165,5 @@
}
return localizedName;
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org