You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "M. Hossein Amerkashi" <kk...@yahoo.com> on 2006/01/03 16:53:08 UTC

toolbox.xml

Hi,

I am having difficulty loading custom tools using
toolbox. Basically I have a simple java class that
performs some action and am attempting to load it on
start-up. The reference is not getting processed. All
help is appreciated. 

<?xml version="1.0"?>
<toolbox>
<!-- other tools 
  ...
  ...
-->
    <tool>
        <key>airportTools</key>
        <scope>application</scope>
        <class>package.AirportTools</class>
    </tool>
</toolbox>

template:
$airportTools.getHciForArtcc($ARTCC_ID)


	
		
__________________________________ 
Yahoo! for Good - Make a difference this year. 
http://brand.yahoo.com/cybergivingweek2005/

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: toolbox.xml

Posted by Stas Ostapenko <st...@gmail.com>.
It is not enough information to determine where problem is. Provide
your class and probably some errors which you got. But probably you
should try to make your class public.

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: toolbox.xml

Posted by Nathan Bubna <nb...@gmail.com>.
please use the mailing list for questions so that others can both help
answer them and learn from them.

and yes, if you are processing templates apart from the
VelocityViewServlet and wish to have the same toolbox as though you
are using the VVS, then you must use the Context created by the
VelocityViewServlet's createContext() method or one much like it.

however, accessing the VVS's createContext() method in a Struts Action
is likely to be difficult, if not impossible.  so, you will probably
need to spend some time understanding how the VelocityViewServlet sets
up the toolbox and creates its special Context.

here's a quick guide to it, and then i must get on with my work for the day...

in your Struts Action:
1.  get the right toolbox manager using ServletToolboxManager.getInstance(...)
2.  in your action, mimic what VelocityViewServlet.createContext(...)
does to create your context.
3.  use that context to process your templates in the Struts Action

good luck.

http://svn.apache.org/viewcvs.cgi/jakarta/velocity/tools/trunk/src/java/org/apache/velocity/tools/view/servlet/VelocityViewServlet.java?rev=321237&view=markup
http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/view/context/ChainedContext.html
http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/view/servlet/VelocityViewServlet.html
http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/view/servlet/ServletToolboxManager.html

On 1/4/06, M. Hossein Amerkashi <kk...@yahoo.com> wrote:
> Hi Nathan,
>
> I appreciate all your help.
> My welcome.vm is configured thru struts, like so:
> <action path="/welcome"
> type="gov.faa.tfmm.adaptation.struts.actions.BaseAction"
>      scope="session"
>      input="/adaptation/welcome.vm">
>      <forward name="success"
> path="/adaptation/welcome.vm" />
>      <forward name="listFiles"
> path="/adaptation/files_to_process.vm" />
> </action>
> <action path="/listFiles"
> type="gov.faa.tfmm.adaptation.struts.actions.FilesListAction"
>
> input="/adaptation/files_to_process.vm">
> <forward name="success"
> path="/adaptation/files_to_process.vm" />
> <forward name="cancel" path="/adaptation/bye.vm" />
> <forward name="initiate"
> path="/adaptation/processedFiles.vm" />
> </action>
>
> files_to_process.vm properly renders with correct
> data. Action class is FilesListAction. It is in this
> class that I call my engine to start code generation.
> the Engine class is the class that initializes
> velocity and gets a new VelocityContext. From this
> point on, any velocity templates will lose the loaded
> toolbox tools. It seems like I should somehow retrieve
> the existing context (in FilesListAction) and then
> pass the context to the Engine?
>
> All help is appreciated.
>
>
>
> --- Nathan Bubna <nb...@gmail.com> wrote:
>
> > ok, so you are using the VelocityViewServlet
> > directly, not a subclass.
> >
> > so what class is your initVelocity() method in?  and
> > how is it being called?
> >
> > it looks to me like you are having the
> > VelocityViewServlet process the
> > welcome.vm page, but then using something else with
> > this
> > initVelocity() method to process the runway.vm file.
> >    if you want
> > your tools to be available, you should use a Context
> > that has been
> > created by the createContext() method of the
> > VelocityViewServlet when
> > processing runway.vm.
> >
> > On 1/3/06, M. Hossein Amerkashi <kk...@yahoo.com>
> > wrote:
> > > ----> Using velocity-tools-1.2.jar
> > >
> > > ----> Log file:
> > >
> >
> org.apache.velocity.runtime.exception.ReferenceException:
> > > reference : template = runway.vm [line 4,column
> > 179] :
> > > $dmsTools.dmsToDegWithDir($LAT_ARR_END,7) is not a
> > > valid reference.
> > >
> > > ---->web.xml
> > > <servlet>
> > >    <servlet-name>velocity</servlet-name>
> > >
> >
> <servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
> > >      <init-param>
> > >
> > >
> > <param-name>org.apache.velocity.toolbox</param-name>
> > >
> > > <param-value>/WEB-INF/toolbox.xml</param-value>
> > >      </init-param>
> > >      <load-on-startup>10</load-on-startup>
> > > </servlet>
> > > <servlet-mapping>
> > >      <servlet-name>velocity</servlet-name>
> > >      <url-pattern>*.vm</url-pattern>
> > >  </servlet-mapping>
> > >
> > > --------> templates:
> > > Initially, when welcome.vm page is loaded for
> > testing,
> > > I added the $dmsTool to my template and @ runtime,
> > I
> > > can see that Velocity has loaded the tool into the
> > > context ( package.tools.DMSTools@123defe ). I
> > later
> > > provide a link to user to initiate processing.
> > This
> > > action will call the initVelocity() (see below)
> > and
> > > will start loading data into velocityContext. It
> > is at
> > > this time that I get ReferenceException.
> > >
> > >
> > >
> > >
> > > --- Nathan Bubna <nb...@gmail.com> wrote:
> > >
> > > > so, you are using a subclass of
> > VelocityViewServlet,
> > > > right?  what
> > > > version of VelocityTools are you using?  are you
> > > > getting any relevant
> > > > error messages in your logs?
> > > >
> > > > i'm not sure i understand what you mean when you
> > say
> > > > the tools are
> > > > available on start-up, but not later.  what do
> > your
> > > > logs say at
> > > > startup?  what do they say later?
> > > >
> > > > overriding initVelocity() should not affect the
> > > > context that is
> > > > created.  what are you doing with the
> > > > velocityContext object you are
> > > > creating and why are you creating it when you
> > > > initialize your velocity
> > > > engine?  that doesn't seem appropriate to me.
> > if
> > > > you must mess with
> > > > the context, it is best to do so when overriding
> > the
> > > > createContext()
> > > > method.  are you overriding createContext()?
> > > >
> > > > On 1/3/06, M. Hossein Amerkashi
> > <kk...@yahoo.com>
> > > > wrote:
> > > > > Thx for replies.
> > > > > Class / method are public. Using velocity with
> > > > struts.
> > > > >
> > > > >
> > > > > My app is a code generator. On start-up, tools
> > are
> > > > > available, but later are not. Reason is that I
> > do
> > > > > initVelocity (see below) which resets the
> > Context.
> > > > > What needs to be done? Do I need to do context
> > > > > chaining?
> > > > >
> > > > > Thanks
> > > > >
> > > > > private static void initVelocity() throws
> > > > Exception {
> > > > >         if (velocityEngine == null) {
> > > > >             velocityContext = new
> > > > VelocityContext();
> > > > >             Properties velocityProps = new
> > > > > Properties();
> > > > >
> > > > >             velocityEngine = new
> > VelocityEngine();
> > > > >
> > > > >             InputStream inputStream =
> > > > >
> > > >
> > >
> >
> Engine.class.getResourceAsStream(Constants.VELOCITY_PEROPERTIES_FILE);
> > > > >             velocityProps.load(inputStream);
> > > > >
> > velocityEngine.init(velocityProps);
> > > > >         }
> > > > >     }
> > > > >
> > > > >
> > > > > --- Nathan Bubna <nb...@gmail.com> wrote:
> > > > >
> > > > > > as Stas said, make sure that both your tool
> > > > class
> > > > > > and the methods you
> > > > > > wish to call from the template are declared
> > > > public.
> > > > > >
> > > > > > and yeah, more info would be nice.  are you
> > > > using
> > > > > > the
> > > > > > VelocityViewServlet?  are you sure your
> > > > toolbox.xml
> > > > > > is being read?
> > > > > >
> > > > > > On 1/3/06, M. Hossein Amerkashi
> > > > <kk...@yahoo.com>
> > > > > > wrote:
> > > > > > > Hi,
> > > > > > >
> > > > > > > I am having difficulty loading custom
> > tools
> > > > using
> > > > > > > toolbox. Basically I have a simple java
> > class
> > > > that
> > > > > > > performs some action and am attempting to
> > load
> > > > it
> > > > > > on
> > > > > > > start-up. The reference is not getting
> > > > processed.
> > > > > > All
> > > > > > > help is appreciated.
> > > > > > >
> > > > > > > <?xml version="1.0"?>
> > > > > > > <toolbox>
> > > > > > > <!-- other tools
> > > > > > >   ...
> > > > > > >   ...
> > > > > > > -->
> > > > > > >     <tool>
> > > > > > >         <key>airportTools</key>
> > > > > > >         <scope>application</scope>
> > > > > > >
> > <class>package.AirportTools</class>
> > > > > > >     </tool>
> > > > > > > </toolbox>
> > > > > > >
> > > > > > > template:
> > > > > > > $airportTools.getHciForArtcc($ARTCC_ID)
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > __________________________________
> > > > > > > Yahoo! for Good - Make a difference this
> > year.
> > > > > > >
> > http://brand.yahoo.com/cybergivingweek2005/
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> ---------------------------------------------------------------------
> > > > > > > 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
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > __________________________________
> > > > > Yahoo! for Good - Make a difference this year.
> > > > > http://brand.yahoo.com/cybergivingweek2005/
> > > > >
> > > > >
> > > >
> > >
> >
> ---------------------------------------------------------------------
> > > > > 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
> > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> > > __________________________________
> > > Yahoo! for Good - Make a difference this year.
> > > http://brand.yahoo.com/cybergivingweek2005/
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > 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
> >
> >
>
>
>
>
> __________________________________________
> Yahoo! DSL – Something to write home about.
> Just $16.99/mo. or less.
> dsl.yahoo.com
>
>

Re: toolbox.xml

Posted by Nathan Bubna <nb...@gmail.com>.
ok, so you are using the VelocityViewServlet directly, not a subclass.

so what class is your initVelocity() method in?  and how is it being called?

it looks to me like you are having the VelocityViewServlet process the
welcome.vm page, but then using something else with this
initVelocity() method to process the runway.vm file.    if you want
your tools to be available, you should use a Context that has been
created by the createContext() method of the VelocityViewServlet when
processing runway.vm.

On 1/3/06, M. Hossein Amerkashi <kk...@yahoo.com> wrote:
> ----> Using velocity-tools-1.2.jar
>
> ----> Log file:
> org.apache.velocity.runtime.exception.ReferenceException:
> reference : template = runway.vm [line 4,column 179] :
> $dmsTools.dmsToDegWithDir($LAT_ARR_END,7) is not a
> valid reference.
>
> ---->web.xml
> <servlet>
>    <servlet-name>velocity</servlet-name>
> <servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
>      <init-param>
>
> <param-name>org.apache.velocity.toolbox</param-name>
>
> <param-value>/WEB-INF/toolbox.xml</param-value>
>      </init-param>
>      <load-on-startup>10</load-on-startup>
> </servlet>
> <servlet-mapping>
>      <servlet-name>velocity</servlet-name>
>      <url-pattern>*.vm</url-pattern>
>  </servlet-mapping>
>
> --------> templates:
> Initially, when welcome.vm page is loaded for testing,
> I added the $dmsTool to my template and @ runtime, I
> can see that Velocity has loaded the tool into the
> context ( package.tools.DMSTools@123defe ). I later
> provide a link to user to initiate processing. This
> action will call the initVelocity() (see below) and
> will start loading data into velocityContext. It is at
> this time that I get ReferenceException.
>
>
>
>
> --- Nathan Bubna <nb...@gmail.com> wrote:
>
> > so, you are using a subclass of VelocityViewServlet,
> > right?  what
> > version of VelocityTools are you using?  are you
> > getting any relevant
> > error messages in your logs?
> >
> > i'm not sure i understand what you mean when you say
> > the tools are
> > available on start-up, but not later.  what do your
> > logs say at
> > startup?  what do they say later?
> >
> > overriding initVelocity() should not affect the
> > context that is
> > created.  what are you doing with the
> > velocityContext object you are
> > creating and why are you creating it when you
> > initialize your velocity
> > engine?  that doesn't seem appropriate to me.  if
> > you must mess with
> > the context, it is best to do so when overriding the
> > createContext()
> > method.  are you overriding createContext()?
> >
> > On 1/3/06, M. Hossein Amerkashi <kk...@yahoo.com>
> > wrote:
> > > Thx for replies.
> > > Class / method are public. Using velocity with
> > struts.
> > >
> > >
> > > My app is a code generator. On start-up, tools are
> > > available, but later are not. Reason is that I do
> > > initVelocity (see below) which resets the Context.
> > > What needs to be done? Do I need to do context
> > > chaining?
> > >
> > > Thanks
> > >
> > > private static void initVelocity() throws
> > Exception {
> > >         if (velocityEngine == null) {
> > >             velocityContext = new
> > VelocityContext();
> > >             Properties velocityProps = new
> > > Properties();
> > >
> > >             velocityEngine = new VelocityEngine();
> > >
> > >             InputStream inputStream =
> > >
> >
> Engine.class.getResourceAsStream(Constants.VELOCITY_PEROPERTIES_FILE);
> > >             velocityProps.load(inputStream);
> > >             velocityEngine.init(velocityProps);
> > >         }
> > >     }
> > >
> > >
> > > --- Nathan Bubna <nb...@gmail.com> wrote:
> > >
> > > > as Stas said, make sure that both your tool
> > class
> > > > and the methods you
> > > > wish to call from the template are declared
> > public.
> > > >
> > > > and yeah, more info would be nice.  are you
> > using
> > > > the
> > > > VelocityViewServlet?  are you sure your
> > toolbox.xml
> > > > is being read?
> > > >
> > > > On 1/3/06, M. Hossein Amerkashi
> > <kk...@yahoo.com>
> > > > wrote:
> > > > > Hi,
> > > > >
> > > > > I am having difficulty loading custom tools
> > using
> > > > > toolbox. Basically I have a simple java class
> > that
> > > > > performs some action and am attempting to load
> > it
> > > > on
> > > > > start-up. The reference is not getting
> > processed.
> > > > All
> > > > > help is appreciated.
> > > > >
> > > > > <?xml version="1.0"?>
> > > > > <toolbox>
> > > > > <!-- other tools
> > > > >   ...
> > > > >   ...
> > > > > -->
> > > > >     <tool>
> > > > >         <key>airportTools</key>
> > > > >         <scope>application</scope>
> > > > >         <class>package.AirportTools</class>
> > > > >     </tool>
> > > > > </toolbox>
> > > > >
> > > > > template:
> > > > > $airportTools.getHciForArtcc($ARTCC_ID)
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > __________________________________
> > > > > Yahoo! for Good - Make a difference this year.
> > > > > http://brand.yahoo.com/cybergivingweek2005/
> > > > >
> > > > >
> > > >
> > >
> >
> ---------------------------------------------------------------------
> > > > > 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
> > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> > > __________________________________
> > > Yahoo! for Good - Make a difference this year.
> > > http://brand.yahoo.com/cybergivingweek2005/
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > 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
> >
> >
>
>
>
>
>
> __________________________________
> Yahoo! for Good - Make a difference this year.
> http://brand.yahoo.com/cybergivingweek2005/
>
> ---------------------------------------------------------------------
> 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: toolbox.xml

Posted by "M. Hossein Amerkashi" <kk...@yahoo.com>.
----> Using velocity-tools-1.2.jar

----> Log file:
org.apache.velocity.runtime.exception.ReferenceException:
reference : template = runway.vm [line 4,column 179] :
$dmsTools.dmsToDegWithDir($LAT_ARR_END,7) is not a
valid reference.

---->web.xml
<servlet>
   <servlet-name>velocity</servlet-name>          
<servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
     <init-param>
        
<param-name>org.apache.velocity.toolbox</param-name>
        
<param-value>/WEB-INF/toolbox.xml</param-value>
     </init-param>
     <load-on-startup>10</load-on-startup>
</servlet>
<servlet-mapping>
     <servlet-name>velocity</servlet-name>
     <url-pattern>*.vm</url-pattern>
 </servlet-mapping>

--------> templates:
Initially, when welcome.vm page is loaded for testing,
I added the $dmsTool to my template and @ runtime, I
can see that Velocity has loaded the tool into the
context ( package.tools.DMSTools@123defe ). I later
provide a link to user to initiate processing. This
action will call the initVelocity() (see below) and
will start loading data into velocityContext. It is at
this time that I get ReferenceException.




--- Nathan Bubna <nb...@gmail.com> wrote:

> so, you are using a subclass of VelocityViewServlet,
> right?  what
> version of VelocityTools are you using?  are you
> getting any relevant
> error messages in your logs?
> 
> i'm not sure i understand what you mean when you say
> the tools are
> available on start-up, but not later.  what do your
> logs say at
> startup?  what do they say later?
> 
> overriding initVelocity() should not affect the
> context that is
> created.  what are you doing with the
> velocityContext object you are
> creating and why are you creating it when you
> initialize your velocity
> engine?  that doesn't seem appropriate to me.  if
> you must mess with
> the context, it is best to do so when overriding the
> createContext()
> method.  are you overriding createContext()?
> 
> On 1/3/06, M. Hossein Amerkashi <kk...@yahoo.com>
> wrote:
> > Thx for replies.
> > Class / method are public. Using velocity with
> struts.
> >
> >
> > My app is a code generator. On start-up, tools are
> > available, but later are not. Reason is that I do
> > initVelocity (see below) which resets the Context.
> > What needs to be done? Do I need to do context
> > chaining?
> >
> > Thanks
> >
> > private static void initVelocity() throws
> Exception {
> >         if (velocityEngine == null) {
> >             velocityContext = new
> VelocityContext();
> >             Properties velocityProps = new
> > Properties();
> >
> >             velocityEngine = new VelocityEngine();
> >
> >             InputStream inputStream =
> >
>
Engine.class.getResourceAsStream(Constants.VELOCITY_PEROPERTIES_FILE);
> >             velocityProps.load(inputStream);
> >             velocityEngine.init(velocityProps);
> >         }
> >     }
> >
> >
> > --- Nathan Bubna <nb...@gmail.com> wrote:
> >
> > > as Stas said, make sure that both your tool
> class
> > > and the methods you
> > > wish to call from the template are declared
> public.
> > >
> > > and yeah, more info would be nice.  are you
> using
> > > the
> > > VelocityViewServlet?  are you sure your
> toolbox.xml
> > > is being read?
> > >
> > > On 1/3/06, M. Hossein Amerkashi
> <kk...@yahoo.com>
> > > wrote:
> > > > Hi,
> > > >
> > > > I am having difficulty loading custom tools
> using
> > > > toolbox. Basically I have a simple java class
> that
> > > > performs some action and am attempting to load
> it
> > > on
> > > > start-up. The reference is not getting
> processed.
> > > All
> > > > help is appreciated.
> > > >
> > > > <?xml version="1.0"?>
> > > > <toolbox>
> > > > <!-- other tools
> > > >   ...
> > > >   ...
> > > > -->
> > > >     <tool>
> > > >         <key>airportTools</key>
> > > >         <scope>application</scope>
> > > >         <class>package.AirportTools</class>
> > > >     </tool>
> > > > </toolbox>
> > > >
> > > > template:
> > > > $airportTools.getHciForArtcc($ARTCC_ID)
> > > >
> > > >
> > > >
> > > >
> > > > __________________________________
> > > > Yahoo! for Good - Make a difference this year.
> > > > http://brand.yahoo.com/cybergivingweek2005/
> > > >
> > > >
> > >
> >
>
---------------------------------------------------------------------
> > > > 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
> > >
> > >
> >
> >
> >
> >
> >
> > __________________________________
> > Yahoo! for Good - Make a difference this year.
> > http://brand.yahoo.com/cybergivingweek2005/
> >
> >
>
---------------------------------------------------------------------
> > 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
> 
> 



	
		
__________________________________ 
Yahoo! for Good - Make a difference this year. 
http://brand.yahoo.com/cybergivingweek2005/

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: toolbox.xml

Posted by Nathan Bubna <nb...@gmail.com>.
so, you are using a subclass of VelocityViewServlet, right?  what
version of VelocityTools are you using?  are you getting any relevant
error messages in your logs?

i'm not sure i understand what you mean when you say the tools are
available on start-up, but not later.  what do your logs say at
startup?  what do they say later?

overriding initVelocity() should not affect the context that is
created.  what are you doing with the velocityContext object you are
creating and why are you creating it when you initialize your velocity
engine?  that doesn't seem appropriate to me.  if you must mess with
the context, it is best to do so when overriding the createContext()
method.  are you overriding createContext()?

On 1/3/06, M. Hossein Amerkashi <kk...@yahoo.com> wrote:
> Thx for replies.
> Class / method are public. Using velocity with struts.
>
>
> My app is a code generator. On start-up, tools are
> available, but later are not. Reason is that I do
> initVelocity (see below) which resets the Context.
> What needs to be done? Do I need to do context
> chaining?
>
> Thanks
>
> private static void initVelocity() throws Exception {
>         if (velocityEngine == null) {
>             velocityContext = new VelocityContext();
>             Properties velocityProps = new
> Properties();
>
>             velocityEngine = new VelocityEngine();
>
>             InputStream inputStream =
> Engine.class.getResourceAsStream(Constants.VELOCITY_PEROPERTIES_FILE);
>             velocityProps.load(inputStream);
>             velocityEngine.init(velocityProps);
>         }
>     }
>
>
> --- Nathan Bubna <nb...@gmail.com> wrote:
>
> > as Stas said, make sure that both your tool class
> > and the methods you
> > wish to call from the template are declared public.
> >
> > and yeah, more info would be nice.  are you using
> > the
> > VelocityViewServlet?  are you sure your toolbox.xml
> > is being read?
> >
> > On 1/3/06, M. Hossein Amerkashi <kk...@yahoo.com>
> > wrote:
> > > Hi,
> > >
> > > I am having difficulty loading custom tools using
> > > toolbox. Basically I have a simple java class that
> > > performs some action and am attempting to load it
> > on
> > > start-up. The reference is not getting processed.
> > All
> > > help is appreciated.
> > >
> > > <?xml version="1.0"?>
> > > <toolbox>
> > > <!-- other tools
> > >   ...
> > >   ...
> > > -->
> > >     <tool>
> > >         <key>airportTools</key>
> > >         <scope>application</scope>
> > >         <class>package.AirportTools</class>
> > >     </tool>
> > > </toolbox>
> > >
> > > template:
> > > $airportTools.getHciForArtcc($ARTCC_ID)
> > >
> > >
> > >
> > >
> > > __________________________________
> > > Yahoo! for Good - Make a difference this year.
> > > http://brand.yahoo.com/cybergivingweek2005/
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > 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
> >
> >
>
>
>
>
>
> __________________________________
> Yahoo! for Good - Make a difference this year.
> http://brand.yahoo.com/cybergivingweek2005/
>
> ---------------------------------------------------------------------
> 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: toolbox.xml

Posted by "M. Hossein Amerkashi" <kk...@yahoo.com>.
Thx for replies.
Class / method are public. Using velocity with struts.


My app is a code generator. On start-up, tools are
available, but later are not. Reason is that I do
initVelocity (see below) which resets the Context.
What needs to be done? Do I need to do context
chaining?

Thanks 

private static void initVelocity() throws Exception {
        if (velocityEngine == null) {
            velocityContext = new VelocityContext();
            Properties velocityProps = new
Properties();

            velocityEngine = new VelocityEngine();

            InputStream inputStream =
Engine.class.getResourceAsStream(Constants.VELOCITY_PEROPERTIES_FILE);
            velocityProps.load(inputStream);
            velocityEngine.init(velocityProps);
        }
    }


--- Nathan Bubna <nb...@gmail.com> wrote:

> as Stas said, make sure that both your tool class
> and the methods you
> wish to call from the template are declared public.
> 
> and yeah, more info would be nice.  are you using
> the
> VelocityViewServlet?  are you sure your toolbox.xml
> is being read?
> 
> On 1/3/06, M. Hossein Amerkashi <kk...@yahoo.com>
> wrote:
> > Hi,
> >
> > I am having difficulty loading custom tools using
> > toolbox. Basically I have a simple java class that
> > performs some action and am attempting to load it
> on
> > start-up. The reference is not getting processed.
> All
> > help is appreciated.
> >
> > <?xml version="1.0"?>
> > <toolbox>
> > <!-- other tools
> >   ...
> >   ...
> > -->
> >     <tool>
> >         <key>airportTools</key>
> >         <scope>application</scope>
> >         <class>package.AirportTools</class>
> >     </tool>
> > </toolbox>
> >
> > template:
> > $airportTools.getHciForArtcc($ARTCC_ID)
> >
> >
> >
> >
> > __________________________________
> > Yahoo! for Good - Make a difference this year.
> > http://brand.yahoo.com/cybergivingweek2005/
> >
> >
>
---------------------------------------------------------------------
> > 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
> 
> 



	
		
__________________________________ 
Yahoo! for Good - Make a difference this year. 
http://brand.yahoo.com/cybergivingweek2005/

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: toolbox.xml

Posted by Nathan Bubna <nb...@gmail.com>.
as Stas said, make sure that both your tool class and the methods you
wish to call from the template are declared public.

and yeah, more info would be nice.  are you using the
VelocityViewServlet?  are you sure your toolbox.xml is being read?

On 1/3/06, M. Hossein Amerkashi <kk...@yahoo.com> wrote:
> Hi,
>
> I am having difficulty loading custom tools using
> toolbox. Basically I have a simple java class that
> performs some action and am attempting to load it on
> start-up. The reference is not getting processed. All
> help is appreciated.
>
> <?xml version="1.0"?>
> <toolbox>
> <!-- other tools
>   ...
>   ...
> -->
>     <tool>
>         <key>airportTools</key>
>         <scope>application</scope>
>         <class>package.AirportTools</class>
>     </tool>
> </toolbox>
>
> template:
> $airportTools.getHciForArtcc($ARTCC_ID)
>
>
>
>
> __________________________________
> Yahoo! for Good - Make a difference this year.
> http://brand.yahoo.com/cybergivingweek2005/
>
> ---------------------------------------------------------------------
> 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