velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <nbu...@gmail.com>
Subject Re: How to output a tab from a velocity template?
Date Thu, 15 Dec 2005 03:25:43 GMT
On 12/14/05, Bryce Nesbitt <bryce1@obviously.com> wrote:
> Nathan Bubna wrote:
> >    if actual tabs aren't icky in the output, then i don't see why they're
> > icky in the input.  Velocity doesn't do anything special for or with
> > tab characters.
> Because the source code is in a multiplatform multideveloper environment
> that does not preserve (or allow,
> or tolerate) tabs.
> The export is in user-land.

ah, that makes sense.

> >   if you want a tab character in the output, the
> > simplest thing is to put it in the input.  but if you really don't
> > like that, you can always put a string containing just a tab in the
> > context:
> >
> > context.put("tab", "\t");
> >
> > and then use
> >
> > ${tab} in your template.
> >
> >
> Cool, could you give me one more hint on where to find the right
> context? I did this, without joy:

looks like some sort of WebWork context.  you want to get it into the
Velocity context.  i don't know much about WebWork's Velocity
integration...

>  // Action.java
> ...extends ActionSupport...
>
>  public String execute() throws Exception {
>         ActionContext.getContext().put("tab","\t");
>         return "tabexport";
>     }
>
>
> <!-- something.vm -->
> $res.setHeader("content-type", "text/plain")
> $res.setHeader("Content-Disposition", "attachment;
> filename=cust_-xxxxxx.txt")TFLD4
> TEST$tab${tab}TEST
> TEST$tab${tab}TEST

if the response is available as $res, perhaps the request is available
as $req (old VelocityServlet style).  if so, then at worst you could
do:

request.setAttribute("tab", "\t")

and

#set( $tab = $req.getAttribute('tab') )
TEST${tab}${tab}TEST

> ---------------------------------------------------------------------
> 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


Mime
View raw message