On Fri, Dec 21, 2012 at 4:39 PM, Paul Libbrecht <[email protected]> wrote:

> Thomas, all,
>
> would I have a way to invoke velocity using the scope being run but
> without the rendering?
> I guess that would be the exact use case here and it is likely to be so
> for other people; for example to generate xml documents, json documents...
>

Not sure I fully undertand what you ask, when you use
$xcontext.setFinished(true) you will get only when you wrote directly to
the output stream. I'm using it to generate translation packages in
l10n.xwiki.org for example.


>
> thanks in advance.
>
> paul
>
>
> Le 20 déc. 2012 à 12:46, Paul Libbrecht a écrit :
>
> > great, that worked.
> >
> > However, it means the velocity output is forgotten so I'd have to call
> velocity at places where it makes sense.
> >
> > I'm also caught by this kind of things, the "eat all exceptions" type of
> approach of velocity is not a charm!
> >
> > It's good to know as a strategy for the future.
> >
> > paul
> >
> >
> > Le 20 déc. 2012 à 12:00, Thomas Mortagne a écrit :
> >
> >> On Thu, Dec 20, 2012 at 11:00 AM, Paul Libbrecht <[email protected]>
> wrote:
> >>
> >>>>
> >>>> That's true but it does not prevent you to write directly in the
> response
> >>>> if you want.
> >>>>
> >>>> Something like:
> >>>>
> >>>> ## Get the response buffer/stream
> >>>> #set($out = $response.outputStream())
> >>>>
> >>>> ## Write some content to the response buffer
> >>>> $out.print("some content")
> >>>>
> >>>> ## Make sure everything is sent
> >>>> $out.flush()
> >>>>
> >>>> ## Indicate XWiki that you already sent the answer
> >>>> $xcontext.setFinished(true)
> >>>
> >>> Hey, we're getting closer!
> >>>
> >>> How does this play with the velocity execution? Would its output be
> >>> discarded then?
> >>>
> >>> I've tried this:
> >>>
> >>> $response.setContentType("text/plain")##
> >>> #set($out = $response.outputStream())##
> >>> ## Write some content to the response buffer
> >>> $out.println("some content")##
> >>> $out.println("some content")##
> >>> $out.println("some content")##
> >>> $out.println("some content")##
> >>> $out.println("some content")##
> >>> $out.println("some content")##
> >>> $out.println("some content")##
> >>> $out.println("some content")##
> >>> $out.println("some content")##
> >>> $out.println("some content")
> >>> ## Make sure everything is sent
> >>> $out.flush()##
> >>> ## Indicate XWiki that you already sent the answer
> >>> $xcontext.setFinished(true)##
> >>>
> >>> and had only blank pages/
> >>>
> >>
> >> That's because you did not really wrote anything ;)
> >>
> >> I made a mistake in my example, it's
> >>
> >> #set($out = $response.outputStream)
> >>
> >> without the parentheses.
> >>
> >>
> >>>
> >>> Paul
> >>> _______________________________________________
> >>> users mailing list
> >>> [email protected]
> >>> http://lists.xwiki.org/mailman/listinfo/users
> >>>
> >>
> >>
> >>
> >> --
> >> Thomas Mortagne
> >> _______________________________________________
> >> users mailing list
> >> [email protected]
> >> http://lists.xwiki.org/mailman/listinfo/users
> >
> > _______________________________________________
> > users mailing list
> > [email protected]
> > http://lists.xwiki.org/mailman/listinfo/users
>
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users
>



-- 
Thomas Mortagne
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to