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:26:28 UTC
cvs commit: jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/tools ImportTool.java LinkTool.java
nbubna 2004/11/10 22:26:28
Modified: src/java/org/apache/velocity/tools/struts
ActionMessagesTool.java MessageResourcesTool.java
StrutsLinkTool.java TilesTool.java
src/java/org/apache/velocity/tools/view ViewToolInfo.java
XMLToolboxManager.java
src/java/org/apache/velocity/tools/view/servlet
ServletToolboxManager.java
src/java/org/apache/velocity/tools/view/tools
ImportTool.java LinkTool.java
Log:
use commons-logging instead of velocity singleton
Revision Changes Path
1.10 +7 -7 jakarta-velocity-tools/src/java/org/apache/velocity/tools/struts/ActionMessagesTool.java
Index: ActionMessagesTool.java
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/src/java/org/apache/velocity/tools/struts/ActionMessagesTool.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ActionMessagesTool.java 12 Mar 2004 23:43:08 -0000 1.9
+++ ActionMessagesTool.java 11 Nov 2004 06:26:27 -0000 1.10
@@ -19,12 +19,11 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.struts.util.MessageResources;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
-
-import org.apache.velocity.app.Velocity;
import org.apache.velocity.tools.struts.StrutsUtils;
/**
@@ -56,6 +55,8 @@
public class ActionMessagesTool extends MessageResourcesTool
{
+ protected static final Log LOG = LogFactory.getLog(ActionMessagesTool.class);
+
/** A reference to the queued action messages. */
protected ActionMessages actionMsgs;
@@ -254,9 +255,8 @@
if (message == null)
{
- Velocity.warn("ActionMessagesTool: Message for key " +
- msg.getKey() +
- " could not be found in message resources.");
+ LOG.warn("Message for key " + msg.getKey() +
+ " could not be found in message resources.");
}
}
else
1.4 +7 -5 jakarta-velocity-tools/src/java/org/apache/velocity/tools/struts/MessageResourcesTool.java
Index: MessageResourcesTool.java
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/src/java/org/apache/velocity/tools/struts/MessageResourcesTool.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MessageResourcesTool.java 18 Feb 2004 20:09:51 -0000 1.3
+++ MessageResourcesTool.java 11 Nov 2004 06:26:27 -0000 1.4
@@ -19,8 +19,9 @@
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.struts.util.MessageResources;
-import org.apache.velocity.app.Velocity;
import org.apache.velocity.tools.view.context.ViewContext;
import org.apache.velocity.tools.view.tools.ViewTool;
@@ -34,6 +35,8 @@
public abstract class MessageResourcesTool implements ViewTool
{
+ protected static final Log LOG = LogFactory.getLog(MessageResourcesTool.class);
+
protected ServletContext application;
protected HttpServletRequest request;
protected Locale locale;
@@ -74,7 +77,7 @@
{
if (resources == null)
{
- Velocity.error("MessageResourcesTool: Message resources are not available.");
+ LOG.error("Message resources are not available.");
}
return resources;
}
@@ -83,8 +86,7 @@
StrutsUtils.getMessageResources(request, application, bundle);
if (res == null)
{
- Velocity.error("MessageResourcesTool: MessageResources bundle '"
- + bundle + "' is not available.");
+ LOG.error("MessageResources bundle '" + bundle + "' is not available.");
}
return res;
}
1.8 +7 -4 jakarta-velocity-tools/src/java/org/apache/velocity/tools/struts/StrutsLinkTool.java
Index: StrutsLinkTool.java
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/src/java/org/apache/velocity/tools/struts/StrutsLinkTool.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- StrutsLinkTool.java 18 Feb 2004 20:09:51 -0000 1.7
+++ StrutsLinkTool.java 11 Nov 2004 06:26:27 -0000 1.8
@@ -16,7 +16,8 @@
package org.apache.velocity.tools.struts;
-import org.apache.velocity.app.Velocity;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.velocity.tools.view.tools.LinkTool;
import org.apache.velocity.tools.struts.StrutsUtils;
@@ -47,6 +48,8 @@
public class StrutsLinkTool extends LinkTool
{
+ protected static final Log LOG = LogFactory.getLog(StrutsLinkTool.class);
+
/**
* <p>Returns a copy of the link with the given action name
@@ -82,8 +85,8 @@
String url = StrutsUtils.getForwardURL(request, application, forward);
if (url == null)
{
- Velocity.warn("StrutsLinkTool: In method setForward(" + forward +
- "): Parameter does not map to a valid forward.");
+ LOG.warn("In method setForward(" + forward +
+ "): Parameter does not map to a valid forward.");
return null;
}
return (StrutsLinkTool)copyWith(url);
1.14 +10 -8 jakarta-velocity-tools/src/java/org/apache/velocity/tools/struts/TilesTool.java
Index: TilesTool.java
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/src/java/org/apache/velocity/tools/struts/TilesTool.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- TilesTool.java 14 Apr 2004 20:08:28 -0000 1.13
+++ TilesTool.java 11 Nov 2004 06:26:27 -0000 1.14
@@ -22,6 +22,9 @@
import javax.servlet.http.HttpSession;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.apache.struts.tiles.ComponentContext;
import org.apache.struts.tiles.ComponentDefinition;
import org.apache.struts.tiles.AttributeDefinition;
@@ -33,7 +36,6 @@
import org.apache.struts.tiles.DefinitionsFactoryException;
import org.apache.struts.tiles.Controller;
-import org.apache.velocity.app.Velocity;
import org.apache.velocity.context.Context;
import org.apache.velocity.tools.view.ImportSupport;
import org.apache.velocity.tools.view.context.ViewContext;
@@ -68,6 +70,8 @@
*/
public class TilesTool extends ImportSupport implements ViewTool
{
+ protected static final Log LOG = LogFactory.getLog(TilesTool.class);
+
static final String PAGE_SCOPE = "page";
static final String REQUEST_SCOPE = "request";
static final String SESSION_SCOPE = "session";
@@ -138,8 +142,8 @@
}
catch (Exception e)
{
- Velocity.error("TilesTool: Exeption while rendering Tile "
- + obj + ": " + e.getMessage());
+ LOG.error("Exeption while rendering Tile "
+ + obj + ": " + e.getMessage());
return null;
}
}
@@ -158,8 +162,7 @@
Object value = getCurrentContext().getAttribute(name);
if (value == null)
{
- Velocity.warn("TilesTool: Tile attribute '"
- + name + "' was not found in context.");
+ LOG.warn("Tile attribute '" + name + "' wasn't found in context.");
}
return value;
}
@@ -193,8 +196,7 @@
Object value = getCurrentContext().getAttribute(name);
if (value == null)
{
- Velocity.warn("TilesTool: Tile attribute '"
- + name + "' was not found in context.");
+ LOG.warn("Tile attribute '" + name + "' wasn't found in context.");
}
if (scope.equals(PAGE_SCOPE))
1.10 +8 -6 jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/ViewToolInfo.java
Index: ViewToolInfo.java
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/ViewToolInfo.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ViewToolInfo.java 16 Apr 2004 20:36:12 -0000 1.9
+++ ViewToolInfo.java 11 Nov 2004 06:26:27 -0000 1.10
@@ -18,9 +18,10 @@
import java.util.HashMap;
import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.velocity.tools.view.tools.Configurable;
import org.apache.velocity.tools.view.tools.ViewTool;
-import org.apache.velocity.app.Velocity;
/**
* ToolInfo implementation for view tools. New instances
@@ -34,6 +35,7 @@
*/
public class ViewToolInfo implements ToolInfo
{
+ protected static final Log LOG = LogFactory.getLog(ViewToolInfo.class);
private String key;
private Class clazz;
@@ -162,13 +164,13 @@
* notice of them, and let other exceptions slip by. */
catch (IllegalAccessException e)
{
- Velocity.error("Exception while instantiating instance of \"" +
- getClassname() + "\": " + e);
+ LOG.error("Exception while instantiating instance of \"" +
+ getClassname() + "\": " + e);
}
catch (InstantiationException e)
{
- Velocity.error("Exception while instantiating instance of \"" +
- getClassname() + "\": " + e);
+ LOG.error("Exception while instantiating instance of \"" +
+ getClassname() + "\": " + e);
}
if (configurable)
{
1.13 +7 -5 jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/XMLToolboxManager.java
Index: XMLToolboxManager.java
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/XMLToolboxManager.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XMLToolboxManager.java 11 Nov 2004 04:02:03 -0000 1.12
+++ XMLToolboxManager.java 11 Nov 2004 06:26:27 -0000 1.13
@@ -27,7 +27,8 @@
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.RuleSet;
-import org.apache.velocity.app.Velocity;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.velocity.tools.view.ToolboxRuleSet;
import org.apache.velocity.tools.view.context.ToolboxContext;
@@ -77,6 +78,7 @@
*/
public class XMLToolboxManager implements ToolboxManager
{
+ protected static final Log LOG = LogFactory.getLog(XMLToolboxManager.class);
private List toolinfo;
private Map data;
@@ -106,7 +108,7 @@
{
toolinfo.add(info);
}
- Velocity.info("Added "+info.getKey()+" ("+info.getClassname()+") to the toolbox.");
+ LOG.info("Added "+info.getKey()+" ("+info.getClassname()+") to the toolbox.");
}
@@ -142,7 +144,7 @@
*/
public void load(InputStream input) throws Exception
{
- Velocity.debug("XMLToolboxManager: Loading toolbox...");
+ LOG.trace("Loading toolbox...");
Digester digester = new Digester();
digester.setValidating(false);
@@ -151,7 +153,7 @@
digester.addRuleSet(getRuleSet());
digester.parse(input);
- Velocity.debug("XMLToolboxManager: Toolbox loaded.");
+ LOG.trace("Toolbox loaded.");
}
1.16 +13 -13 jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/servlet/ServletToolboxManager.java
Index: ServletToolboxManager.java
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/servlet/ServletToolboxManager.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ServletToolboxManager.java 11 Nov 2004 04:04:42 -0000 1.15
+++ ServletToolboxManager.java 11 Nov 2004 06:26:27 -0000 1.16
@@ -33,7 +33,8 @@
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.RuleSet;
-import org.apache.velocity.app.Velocity;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.velocity.tools.view.DataInfo;
import org.apache.velocity.tools.view.ToolInfo;
import org.apache.velocity.tools.view.XMLToolboxManager;
@@ -104,6 +105,8 @@
public static final String SESSION_TOOLS_KEY =
ServletToolboxManager.class.getName() + ":session-tools";
+ protected static final Log LOG = LogFactory.getLog(ServletToolboxManager.class);
+
private ServletContext servletContext;
private Map appTools;
private ArrayList sessionToolInfo;
@@ -165,8 +168,7 @@
if (is != null)
{
- Velocity.info("ServletToolboxManager: Using config file '" +
- toolboxFile +"'");
+ LOG.info("Using config file '" + toolboxFile +"'");
toolboxManager = new ServletToolboxManager(servletContext);
toolboxManager.load(is);
@@ -174,18 +176,18 @@
// remember it
managersMap.put(pathname, toolboxManager);
- Velocity.info("ServletToolboxManager: Toolbox setup complete.");
+ LOG.info("Toolbox setup complete.");
}
}
catch(Exception e)
{
- Velocity.error("Problem loading toolbox '" + toolboxFile +"' : " + e);
+ LOG.error("Problem loading toolbox '" + toolboxFile +"' : " + e);
// if this happens, it probably deserves
// to have the stack trace logged
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
- Velocity.error(sw.toString());
+ LOG.error(sw.toString());
}
finally
{
@@ -223,7 +225,7 @@
public void setCreateSession(boolean b)
{
createSession = b;
- Velocity.debug("ServletToolboxManager: create-session is set to " + b);
+ LOG.debug("create-session is set to " + b);
}
@@ -237,8 +239,7 @@
public void setXhtml(Boolean value)
{
servletContext.setAttribute(ViewContext.XHTML, value);
- Velocity.info("ServletToolboxManager: " + ViewContext.XHTML +
- " is set to " + value);
+ LOG.info(ViewContext.XHTML + " is set to " + value);
}
@@ -305,9 +306,8 @@
}
else
{
- Velocity.warn("ServletToolboxManager: Unknown scope '" +
- sti.getScope() + "' - " + sti.getKey() +
- " will be request scoped.");
+ LOG.warn("Unknown scope '" + sti.getScope() + "' - " +
+ sti.getKey() + " will be request scoped.");
requestToolInfo.add(sti);
}
}
1.7 +8 -7 jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/tools/ImportTool.java
Index: ImportTool.java
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/tools/ImportTool.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ImportTool.java 12 Mar 2004 20:30:32 -0000 1.6
+++ ImportTool.java 11 Nov 2004 06:26:27 -0000 1.7
@@ -20,8 +20,8 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletContext;
-
-import org.apache.velocity.app.Velocity;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.velocity.tools.view.ImportSupport;
import org.apache.velocity.tools.view.context.ViewContext;
import org.apache.velocity.tools.view.tools.ViewTool;
@@ -45,8 +45,9 @@
* @since VelocityTools 1.1
* @version $Revision$ $Date$
*/
-public class ImportTool extends ImportSupport
- implements ViewTool {
+public class ImportTool extends ImportSupport implements ViewTool {
+
+ protected static final Log LOG = LogFactory.getLog(ImportTool.class);
/**
* Default constructor. Tool must be initialized before use.
@@ -80,14 +81,14 @@
try {
// check the URL
if (url == null || url.equals("")) {
- Velocity.warn("ImportTool: import URL is null or empty");
+ LOG.warn("Import URL is null or empty");
return null;
}
return acquireString(url);
}
catch (Exception ex) {
- Velocity.error("Exception while importing URL: " + ex.getMessage());
+ LOG.error("Exception while importing URL: " + ex.getMessage());
return null;
}
}
1.17 +10 -12 jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/tools/LinkTool.java
Index: LinkTool.java
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/tools/LinkTool.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- LinkTool.java 11 Nov 2004 03:54:55 -0000 1.16
+++ LinkTool.java 11 Nov 2004 06:26:27 -0000 1.17
@@ -21,13 +21,12 @@
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletContext;
-
-import org.apache.velocity.app.Velocity;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.velocity.tools.view.context.ViewContext;
import org.apache.velocity.tools.view.tools.ViewTool;
@@ -56,7 +55,7 @@
*/
public class LinkTool implements ViewTool, Cloneable
{
-
+ protected static final Log LOG = LogFactory.getLog(LinkTool.class);
/** Standard HTML delimiter for query data ('&') */
public static final String HTML_QUERY_DELIMITER = "&";
@@ -103,7 +102,7 @@
}
catch (NoSuchMethodException e)
{
- Velocity.debug("LinkTool: Can't find JDK 1.4 encode method. Using JDK 1.3 version.");
+ LOG.debug("Can't find JDK 1.4 encode method. Using JDK 1.3 version.");
}
}
@@ -209,8 +208,7 @@
}
catch (CloneNotSupportedException e)
{
- Velocity.warn("LinkTool: could not properly clone " + getClass() +
- " - " + e);
+ LOG.warn("Could not properly clone " + getClass() + " - " + e);
// "clone" manually
LinkTool copy;
@@ -525,13 +523,13 @@
// don't keep trying if we get one of these
encode = null;
- Velocity.debug("LinkTool: Can't access JDK 1.4 encode method ("
- + e + "). Using deprecated version from now on.");
+ LOG.debug("Can't access JDK 1.4 encode method ("
+ + e + "). Using deprecated version from now on.");
}
catch (InvocationTargetException e)
{
- Velocity.debug("LinkTool: Error using JDK 1.4 encode method ("
- + e + "). Using deprecated version.");
+ LOG.debug("Error using JDK 1.4 encode method ("
+ + e + "). Using deprecated version.");
}
}
return URLEncoder.encode(url);
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
RE: AbstractSearchTool + Struts
Posted by Matthew Van Horn <ma...@ashleyassociates.co.jp>.
That's what I was talking about - I didn't realize it was in the CVS
already.
> -----Original Message-----
> From: Shinobu Kawai [mailto:shinobu.kawai@gmail.com]
> Sent: Monday, November 15, 2004 4:40 PM
> To: Velocity Users List
> Subject: Re: AbstractSearchTool + Struts
>
>
>
> Hi Matthew,
>
> > I split the paging work from the search work into a different tool.
> > This may be more along the lines of what you want. I can
> send you the
> > code, if you like,
> > or you can work it out yourself - it is not that difficult.
> Could it be something like the AbstractPagerTool in the latest CVS?
>
> http://cvs.apache.org/viewcvs.cgi/jakarta-velocity-tools/src/j
ava/org/apache/velocity/tools/view/tools/AbstractPagerTool.java?rev=1.1&
view=auto
Best regards,
-- Shinobu Kawai
--
Shinobu Kawai <sh...@gmail.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: AbstractSearchTool + Struts
Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Matthew,
> I split the paging work from the search work into a different tool.
> This may be more along the lines of what you want. I can send you the
> code, if you like,
> or you can work it out yourself - it is not that difficult.
Could it be something like the AbstractPagerTool in the latest CVS?
http://cvs.apache.org/viewcvs.cgi/jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/tools/AbstractPagerTool.java?rev=1.1&view=auto
Best regards,
-- Shinobu Kawai
--
Shinobu Kawai <sh...@gmail.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
RE: AbstractSearchTool + Struts
Posted by Matthew Van Horn <ma...@ashleyassociates.co.jp>.
I split the paging work from the search work into a different tool.
This may be more along the lines of what you want. I can send you the
code, if you like,
or you can work it out yourself - it is not that difficult.
> -----Original Message-----
> From: Eric Fixler [mailto:fix@fixler.com]
> Sent: Friday, November 12, 2004 7:46 AM
> To: Velocity Users List
> Subject: Re: AbstractSearchTool + Struts
>
>
> Thanks Shinobu.
>
> I think I didn't phrase what I was asking so well. In my
> understanding
> of the way VelocityStruts works, a request goes
>
> request->Struts Actions->VelocityViewServlet->vtl template
>
> And what I really wanted to do was parse my query and manipulate my
> AbstractSearchTool inside the relevant Struts Action, and then let
> control get passed to VelocityViewServlet, etc.
>
> I can see that VelocityViewServlet gets a ToolboxManager using
> ServletToolboxManager.getInstance(servletContext, file), but there
> doesn't seem to a way to share the tools easily elsewhere.
>
> OTOH, looking at the docs again, maybe the way I pictured it
> just isn't
> the way to do it. It looks like the only way to have interaction
> between the Struts action and the tool is to do a
> request.setAttribute() in the preceding action and then look for an
> attribute in the tool's setup() method.
>
>
> thanks again, and sorry if I'm being thick
> eric
>
>
>
> On Nov 11, 2004, at 1:39 PM, Shinobu Kawai wrote:
>
> > Hi Eric,
> >
> >> Hi. I'd like to use AbstractSearchTool (or it's
> apparently incipient
> >> replacements), and I'm also using Struts. I think I understand all
> >> the
> >> individual pieces, but I'm missing part of the big
> picture, i.e. where
> >> does the SearchTool get instantiated.
> >>
> >> Let's say I've done the following -
> >
> > ## snip
> >
> >> How does (Or how would I make sure that) my SearchTool get
> >> instantiated, executed, and placed in the context at the key
> >> designated
> >> in the toolbox file?
> >>
> >> If there's a doc page on this, please point me to it...
> > AbstractSearchTool is the same as any other tool.
> >
> > http://jakarta.apache.org/velocity/tools/view/
> > index.html#Toolbox%20Configuration
> >
> > For an example of toolbox.xml entry,
> >
> >
> http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocit>
y/
> > tools/view/tools/AbstractSearchTool.html
> >
> > For the actual code,
> >
> >
> http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocit>
y/
> > tools/view/servlet/
> > VelocityViewServlet.html#initToolbox(javax.servlet.ServletConfig)
> >
> >
> http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocit>
y/
> > tools/view/ViewToolInfo.html#getInstance(java.lang.Object)
> >
> > Best regards,
> > -- Shinobu Kawai
> >
> > --
> > Shinobu Kawai <sh...@gmail.com>
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> velocity-user-help@jakarta.apache.org
> >
> >
> ---------------------------------------------------------------------
> Eric Fixler
> fix@fixler.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: AbstractSearchTool + Struts
Posted by Eric Fixler <fi...@fixler.com>.
Thanks Shinobu.
I think I didn't phrase what I was asking so well. In my understanding
of the way VelocityStruts works, a request goes
request->Struts Actions->VelocityViewServlet->vtl template
And what I really wanted to do was parse my query and manipulate my
AbstractSearchTool inside the relevant Struts Action, and then let
control get passed to VelocityViewServlet, etc.
I can see that VelocityViewServlet gets a ToolboxManager using
ServletToolboxManager.getInstance(servletContext, file), but there
doesn't seem to a way to share the tools easily elsewhere.
OTOH, looking at the docs again, maybe the way I pictured it just isn't
the way to do it. It looks like the only way to have interaction
between the Struts action and the tool is to do a
request.setAttribute() in the preceding action and then look for an
attribute in the tool's setup() method.
thanks again, and sorry if I'm being thick
eric
On Nov 11, 2004, at 1:39 PM, Shinobu Kawai wrote:
> Hi Eric,
>
>> Hi. I'd like to use AbstractSearchTool (or it's apparently incipient
>> replacements), and I'm also using Struts. I think I understand all
>> the
>> individual pieces, but I'm missing part of the big picture, i.e. where
>> does the SearchTool get instantiated.
>>
>> Let's say I've done the following -
>
> ## snip
>
>> How does (Or how would I make sure that) my SearchTool get
>> instantiated, executed, and placed in the context at the key
>> designated
>> in the toolbox file?
>>
>> If there's a doc page on this, please point me to it...
> AbstractSearchTool is the same as any other tool.
>
> http://jakarta.apache.org/velocity/tools/view/
> index.html#Toolbox%20Configuration
>
> For an example of toolbox.xml entry,
>
> http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/
> tools/view/tools/AbstractSearchTool.html
>
> For the actual code,
>
> http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/
> tools/view/servlet/
> VelocityViewServlet.html#initToolbox(javax.servlet.ServletConfig)
>
> http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/
> tools/view/ViewToolInfo.html#getInstance(java.lang.Object)
>
> Best regards,
> -- Shinobu Kawai
>
> --
> Shinobu Kawai <sh...@gmail.com>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
Eric Fixler
fix@fixler.com
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: AbstractSearchTool + Struts
Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Eric,
> Hi. I'd like to use AbstractSearchTool (or it's apparently incipient
> replacements), and I'm also using Struts. I think I understand all the
> individual pieces, but I'm missing part of the big picture, i.e. where
> does the SearchTool get instantiated.
>
> Let's say I've done the following -
## snip
> How does (Or how would I make sure that) my SearchTool get
> instantiated, executed, and placed in the context at the key designated
> in the toolbox file?
>
> If there's a doc page on this, please point me to it...
AbstractSearchTool is the same as any other tool.
http://jakarta.apache.org/velocity/tools/view/index.html#Toolbox%20Configuration
For an example of toolbox.xml entry,
http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/view/tools/AbstractSearchTool.html
For the actual code,
http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/view/servlet/VelocityViewServlet.html#initToolbox(javax.servlet.ServletConfig)
http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/view/ViewToolInfo.html#getInstance(java.lang.Object)
Best regards,
-- Shinobu Kawai
--
Shinobu Kawai <sh...@gmail.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
AbstractSearchTool + Struts
Posted by Eric Fixler <fi...@fixler.com>.
Hi. I'd like to use AbstractSearchTool (or it's apparently incipient
replacements), and I'm also using Struts. I think I understand all the
individual pieces, but I'm missing part of the big picture, i.e. where
does the SearchTool get instantiated.
Let's say I've done the following -
1) Subclassed AbstractSearchTool
2) Added an entry for it in the toolbox.xml
3) Set up a [struts] action called '/search'
4) Written a velocity template
How does (Or how would I make sure that) my SearchTool get
instantiated, executed, and placed in the context at the key designated
in the toolbox file?
If there's a doc page on this, please point me to it...
thanks
eric
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org