From: "Dan Bachelder" <[EMAIL PROTECTED]>
> If I want to use velocity in a scheduled job, how do I get a handle in such
> a way as to still have my context tools in scope?

You ask a good question - I would like an answer too.

> 
>             TurbineVelocityService vs = new TurbineVelocityService();
>             Context ctx = vs.getContext();
>             .
>             .
>             .
>             String myOutput = vs.handleRequest( ctx,
> "screens/RemMail.vm" ) );
> 
> myOutput in this case is good except things like $ui and $link are giving:
> 
> $ui.sansSerifFonts is not a valid reference.
> 
> type errors in my velocity log.
> 
> thanks

Here is what I currently do to work around this:

Instantiate UIManager manually and then stuff whatever you need 
from it into the context:

        Context context = TurbineVelocity.getContext();

        UIManager ui = new UIManager();
        ui.init(null);
        ui.setSkin(); // will use TR.props

        context.put("systemname", ui.get("systemNamePlain"));

Doing the same for TemplateLink ($link) is much harder (I have given
up for the moment) as you need a ServletData object in order to 
initialise this which in turn requires a bunch of methods in TurbineServlet
to work when they don't.

You will need to check back in the mail archive as I cannot remember 
where the discussion ended - I think a fix had been committed for 3.0,
but not 2.1.  I think I chased this for a while but reached a dead end
somewhere.

Look at:
http://www.mail-archive.com/[email protected]/msg02783.html

I actually ended up breaking the rules by including a URL to use as the
basis of any links I need in the ui skin file.

        context.put("systemurl", ui.get("systemURL"));

Its a hack, but it works as long as you edit the skin file when you move 
it between systems (I just code the production system address in my 
development system).

HTH

Scott


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

Reply via email to