You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Javier Delgadillo <jd...@esri.com> on 2012/11/27 22:41:01 UTC

Custom Provider

Hello all,

I want to create HTML pages that my JAX-RS services produce.  The services are currently using JacksonJaxbJsonProvider and the CXF JAXBELementPRovider to generate JSON and XML.  We're happy with the output the produce.  I'd like to take the XML produce by the XML Provider and use XSLT to produce the final html.  I tried playing with the XsltJaxbProvider, but when I included in my list of providers, I could no longer get the XML nor JSON from my endpoints.  So I decided to try plugging in my own HTML provider.  This is working fine, but I'd like to have breadcrumbs at the top of each page to so that users can navigate the endpoints that way (similar to how nabble list breadcrumbs in sites like this http://cxf.547215.n5.nabble.com/cxf-user-f547216.html ).

What's the best way to put the breadcrumbs in there?  In the Provider's writeTo method, I don't have access to the original request so I'm not sure what the path is.  Can this be done using an Interceptor further down the chain (ie some Interceptor that case also use XSLT to insert the breadcrumbs later on)?

If someone knows of an easier way to do this, I'd appreciate that as well.

Thanks for your time.
--
Javier Delgadillo
Esri / Implementation Services


Re: Custom Provider

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 28/11/12 16:53, Javier Delgadillo wrote:
> I guess I misconfigured it the first time around. I've got it working with my own provider, so in the interest of not fixing what isn't broken, I'll probably keep it as is.
>
> As far as the breadcrumbs go, I figured out that by matching the top element I can figure out what REST endpoint was hit and build the breadcrumbs based on that assumption.
>
very good, thanks for the update; just in case: all the main request 
properties (request URI, etc) and parameters if any (path, query, etc) 
will also be available as the template parameters...

Cheers, Sergey

> Thanks for the feedback.
>
> -Javier
>
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: Wednesday, November 28, 2012 3:16 AM
> To: users@cxf.apache.org
> Subject: Re: Custom Provider
>
> Hi
> On 27/11/12 21:41, Javier Delgadillo wrote:
>> Hello all,
>>
>> I want to create HTML pages that my JAX-RS services produce.  The services are currently using JacksonJaxbJsonProvider and the CXF JAXBELementPRovider to generate JSON and XML.  We're happy with the output the produce.  I'd like to take the XML produce by the XML Provider and use XSLT to produce the final html.  I tried playing with the XsltJaxbProvider, but when I included in my list of providers, I could no longer get the XML nor JSON from my endpoints.
>
> XSLTJaxbProvider should certainly work alongside JAXB and JSON providers.
>
> You can actually have only XSLTJaxbProvider there and set its 'supportJaxbOnly' property - XSLTJaxbProvider will simply delegate to the superclass in its writeTo whenever it has no any specific work to do for a given bean; so you can configure it exactly the same way as you configure JAXBElementProvider plus all the XSLT extras...
>
> Another option is to use RequestDispatcherProvider and get the response redirected to JSP or some other view handler:
>
> http://cxf.apache.org/docs/jax-rs-redirection.html
>
> Or may try XMLInstruction annotation:
>
> http://cxf.apache.org/docs/jax-rs-advanced-xml.html#JAX-RSAdvancedXML-XMLProcessingInstructions
>
> HTH, Sergey
>
>>   So I decided to try plugging in my own HTML provider.  This is working fine, but I'd like to have breadcrumbs at the top of each page to so that users can navigate the endpoints that way (similar to how nabble list breadcrumbs in sites like this http://cxf.547215.n5.nabble.com/cxf-user-f547216.html ).
>>
>> What's the best way to put the breadcrumbs in there?  In the Provider's writeTo method, I don't have access to the original request so I'm not sure what the path is.  Can this be done using an Interceptor further down the chain (ie some Interceptor that case also use XSLT to insert the breadcrumbs later on)?
>>
>> If someone knows of an easier way to do this, I'd appreciate that as well.
>>
>> Thanks for your time.
>> --
>> Javier Delgadillo
>> Esri / Implementation Services
>>
>>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>


RE: Custom Provider

Posted by Javier Delgadillo <jd...@esri.com>.
I guess I misconfigured it the first time around. I've got it working with my own provider, so in the interest of not fixing what isn't broken, I'll probably keep it as is.

As far as the breadcrumbs go, I figured out that by matching the top element I can figure out what REST endpoint was hit and build the breadcrumbs based on that assumption.

Thanks for the feedback.

-Javier

-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozkin@gmail.com] 
Sent: Wednesday, November 28, 2012 3:16 AM
To: users@cxf.apache.org
Subject: Re: Custom Provider

Hi
On 27/11/12 21:41, Javier Delgadillo wrote:
> Hello all,
>
> I want to create HTML pages that my JAX-RS services produce.  The services are currently using JacksonJaxbJsonProvider and the CXF JAXBELementPRovider to generate JSON and XML.  We're happy with the output the produce.  I'd like to take the XML produce by the XML Provider and use XSLT to produce the final html.  I tried playing with the XsltJaxbProvider, but when I included in my list of providers, I could no longer get the XML nor JSON from my endpoints.

XSLTJaxbProvider should certainly work alongside JAXB and JSON providers.

You can actually have only XSLTJaxbProvider there and set its 'supportJaxbOnly' property - XSLTJaxbProvider will simply delegate to the superclass in its writeTo whenever it has no any specific work to do for a given bean; so you can configure it exactly the same way as you configure JAXBElementProvider plus all the XSLT extras...

Another option is to use RequestDispatcherProvider and get the response redirected to JSP or some other view handler:

http://cxf.apache.org/docs/jax-rs-redirection.html

Or may try XMLInstruction annotation:

http://cxf.apache.org/docs/jax-rs-advanced-xml.html#JAX-RSAdvancedXML-XMLProcessingInstructions

HTH, Sergey

>  So I decided to try plugging in my own HTML provider.  This is working fine, but I'd like to have breadcrumbs at the top of each page to so that users can navigate the endpoints that way (similar to how nabble list breadcrumbs in sites like this http://cxf.547215.n5.nabble.com/cxf-user-f547216.html ).
>
> What's the best way to put the breadcrumbs in there?  In the Provider's writeTo method, I don't have access to the original request so I'm not sure what the path is.  Can this be done using an Interceptor further down the chain (ie some Interceptor that case also use XSLT to insert the breadcrumbs later on)?
>
> If someone knows of an easier way to do this, I'd appreciate that as well.
>
> Thanks for your time.
> --
> Javier Delgadillo
> Esri / Implementation Services
>
>


--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com


Re: Custom Provider

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 27/11/12 21:41, Javier Delgadillo wrote:
> Hello all,
>
> I want to create HTML pages that my JAX-RS services produce.  The services are currently using JacksonJaxbJsonProvider and the CXF JAXBELementPRovider to generate JSON and XML.  We're happy with the output the produce.  I'd like to take the XML produce by the XML Provider and use XSLT to produce the final html.  I tried playing with the XsltJaxbProvider, but when I included in my list of providers, I could no longer get the XML nor JSON from my endpoints.

XSLTJaxbProvider should certainly work alongside JAXB and JSON providers.

You can actually have only XSLTJaxbProvider there and set its 
'supportJaxbOnly' property - XSLTJaxbProvider will simply delegate to 
the superclass in its writeTo whenever it has no any specific work to do 
for a given bean; so you can configure it exactly the same way as you 
configure JAXBElementProvider plus all the XSLT extras...

Another option is to use RequestDispatcherProvider and get the response 
redirected to JSP or some other view handler:

http://cxf.apache.org/docs/jax-rs-redirection.html

Or may try XMLInstruction annotation:

http://cxf.apache.org/docs/jax-rs-advanced-xml.html#JAX-RSAdvancedXML-XMLProcessingInstructions

HTH, Sergey

>  So I decided to try plugging in my own HTML provider.  This is working fine, but I'd like to have breadcrumbs at the top of each page to so that users can navigate the endpoints that way (similar to how nabble list breadcrumbs in sites like this http://cxf.547215.n5.nabble.com/cxf-user-f547216.html ).
>
> What's the best way to put the breadcrumbs in there?  In the Provider's writeTo method, I don't have access to the original request so I'm not sure what the path is.  Can this be done using an Interceptor further down the chain (ie some Interceptor that case also use XSLT to insert the breadcrumbs later on)?
>
> If someone knows of an easier way to do this, I'd appreciate that as well.
>
> Thanks for your time.
> --
> Javier Delgadillo
> Esri / Implementation Services
>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com