Nathan Green said:
> For a tool to use at the application level, use RenderTool.  The other
> Nathan (Bubna)'s javadoc comments are pretty explicit in both tools,
> though they are sort of a footnote...  Perhaps the following change
> could be made to ViewRenderTool?
>
>      public void init(Object obj)
>      {
>          try {
>              context = (Context) obj;
>          } catch (ClassCastException cce) {
>              throw new ClassCastException (
>                  "ViewRenderTool cannot initialize: "
>                  + "scope in toolbox config may be invalid"
>                  + System.getProperty("line.separator") +
>                  + cce.getMessage());
>          }
>      }

yeah, this is an understandable and easy error to make (using ViewRenderTool
in application scope), and this (or something like it) would certainly make
the error message more intelligible.

> I have not tested the above code, so I may have screwed something up.
> HTH,

no worries.  i'll probably go with an instanceof check instead of a try-catch
anyway. :)

Nathan Bubna
[EMAIL PROTECTED]

> Nathan
>
>
> Shinobu Kawai wrote:
>
> > Hi Timo,
> >
> >
> >><tool>
> >>  <key>render</key>
> >>  <scope>application</scope>
> >>  <class>org.apache.velocity.tools.view.tools.ViewRenderTool</class>
> >></tool>
> >>
> >>And I get a Digester error (below), which sounds like bad XML... but the
XML
> >>looks okay to me.
> >>
> >>Looking closer -- I see that the example on the web-page has
scope==request.
> >>When I modify the XML snippet, it works fine. So apparently the tool
doesn't
> >>like being in App scope? If so -- kind of ugly error mesg for that.
> >>
> >>Just curious what's going on here?
> >
> > Take a look at
> >     http://jakarta.apache.org/velocity/tools/view/
> > under "Tool Scopes".  You will notice that request and session scopes
> > are set the ViewContext, whereas application scopes are set the
> > ServletContext.  This causes the following to happen:
> >
> >
> >>Caused by: java.lang.ClassCastException
> >> at
>
>>org.apache.velocity.tools.view.tools.ViewRenderTool.init(ViewRenderTool.java
> >>:99)
> >
> >
> > Best regards,
> > -- Shinobu Kawai
> >
> > --
> > Shinobu Kawai <[EMAIL PROTECTED]>
> >
> >
> > ---------------------------------------------------------------------
> > 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]
>


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

Reply via email to