On Feb 12, 2010, at 4:41 PM, Arul Dhesiaseelan wrote:
> Thanks Paul for the example.
>
> I believe it would be a similar approach to implement a
> VelocityViewProcessor, which uses Velocity to apply templates to a
> HTML file, right?
>
Yes. I did find the following from the Atlassian folks:
http://docs.atlassian.com/atlassian-rest/1.1.0.beta3/atlassian-rest-module/xref/
Not sure if that directly helps or not, but it shows such integration
is possible :-)
Paul.
> I started working on the VelocityViewProcessor, which basically does
> what VelocityViewServlet does for the most part. I will see if I can
> make this work. I will keep you posted.
>
> -Arul
> On Feb 12, 2010, at 7:32 AM, Paul Sandoz wrote:
>
>>
>> On Feb 11, 2010, at 8:18 PM, Arul Dhesiaseelan wrote:
>>
>>> I am using velocity. I would like to get rid of the Velocity
>>> servlet and use the template processor instead.
>>>
>>> I hope this is possible.
>>>
>>
>> Yes, it is possible. You can easily write a template processor that
>> simply spits out the contents of a resource:
>>
>> public class HTMLViewProcessor implements ViewProcessor<URL> {
>>
>> public URL resolve(String path) {
>> Classloader c = .... // use thread context class loader
>> // Perhaps check if path is an HTML file
>> return c.getResource(path);
>>
>> // Or if you want things picked up from the Web area inject
>> ServletContext
>> // ServletContext sc = ...
>> // return sc.getResource(path); // catch MalformedURLException
>> }
>>
>> public void writeTo(URL resource, Viewable viewable, OutputStream
>> out) throws IOException {
>> ReaderWriter.writeTo(resource.openStream(), out);
>> }
>> }
>>
>> This has the advantage that it will also work with templates
>> located according to the rules of Jersey MVC.
>>
>> Note that ViewProcessor was introduced as the replacement for
>> TemplateProcessor in Jersey 1.1.5.
>>
>> I think i will change Viewable such that you can do:
>>
>> public Viewable getHomePage() {
>> return new Viewable("/home.html");
>> }
>>
>>
>> However, as Jan says you can also place stuff directly to be served
>> by the servlet container if you so wish.
>>
>> Paul.
>>
>>> On Feb 11, 2010, at 12:05 PM, Jan Algermissen wrote:
>>>
>>>>
>>>> On Feb 11, 2010, at 7:54 PM, Arul Dhesiaseelan wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> Is it possible to serve static content from a resource?
>>>>>
>>>>> I would like to render HTML from a resource method using
>>>>> explicit MVC, something like:
>>>>>
>>>>> @Path("/")
>>>>> public class RootResource {
>>>>>
>>>>> @Produces(MediaType.TEXT_HTML)
>>>>> @GET
>>>>> public Viewable getHomePage() {
>>>>> return new Viewable("/home.html", null);
>>>>
>>>>
>>>> Why don't you put that HTML file in a static loocation of your WAR?
>>>>
>>>> Jan
>>>>
>>>>
>>>>> }
>>>>> }
>>>>>
>>>>> Would this work?
>>>>>
>>>>> Thank you,
>>>>> Arul
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>>>
>>>>
>>>> -----------------------------------
>>>> Jan Algermissen, Consultant
>>>> NORD Software Consulting
>>>>
>>>> Mail: algermissen_at_acm.org
>>>> Blog: http://www.nordsc.com/blog/
>>>> Work: http://www.nordsc.com/
>>>> -----------------------------------
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>