Thanks for the input Claude. It wasn't so much being able to access the incit parameter, just that it seems confusing to put it in the web.xml file, when the tool is only referenced in the toolbox.xml. It would seem to make more sense to allow something along the lines of:

  <tool>
     <key>google</key>
     <class>org.apache.velocity.tool.GoogleTool</class>
     <param>
        <key>org.apache.velocity.tool.google.key</jey>
        <value>3172893712389127837128</value>
     </param>
  </tool>

- simon


Claude Brisson wrote:
Hi,

for now, you have to put the config value in the deployment descriptor (web.xml) as a context param :

    <context-param>
                    <param-name>org.apache.velocity.tool.google.key</param-name>
                    <param-value>324525SDFDSQZ34</param-value>
    </context-param>

next, for the java, I would suggest something like :

public class GoogleTool implements ViewTool
{
 /** key to access init property */
 private static final String GOOGLE_KEY = "org.apache.velocity.tool.google.key";

 /* key value */
 private String googleKey = null;

 /** init method
 *
 * @arg inViewContext either a ServletContext or a ViewContext depending on the scope 
of the tool
 */
 public void init(Object inViewContext)
 {
  ServletContext ctx = null;
  if (inViewContext instanceof ServletContext) ctx = (ServletContext)inViewContext;
  else if (inViewContext instanceof ViewContext) ctx = 
((ViewContext)inViewContext).getServletContext();
  else
  {
   Velocity.error("GoogleTool : Initialization : no valid initialization data found 
!");
   return;
  }

  /* now get the config param */
  googleKey = ctx.getInitParameter(GOOGLE_KEY);
  if (key == null)
  {
   Velocity.error("GoogleTool : Initialization : no valid initialization data found 
!");
   return;
  }

// ... other init stuff

}

}


Hope that'll help
CloD




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to