users@jersey.java.net

Re: [Jersey] Question on Xhr ajax requests

From: Felipe Gaucho <fgaucho_at_gmail.com>
Date: Tue, 6 Oct 2009 08:16:04 +0200

Use ajax to hide your service calls

On 06.10.2009, at 08:08, Dinesh Narayanan <ndchandar_at_gmail.com> wrote:

> Hello,
> I am fairly new to JAX-RS and Jersey and was trying to implement
> MVCJ in my project.
>
> Here is my requirement:
> When the user logs in, he gets to see four tabs(MyHome, MyAccount,
> MyPortfolio, MyDocumentation) in the top menu bar. And each tab has
> it's own set of widgets to be displayed.
>
> One of our requirements is that we should not be doing any page
> refresh when the user clicks on any of these four tabs. When I do an
> xhrGet() on click of any of these tabs, the required resource gets
> called (MyHomeResource for MyHome tab, MyAccountResource for
> MyAccount tab etc..)
>
> However the uri in the address bar doesn't get changed even though
> the appropriate resource gets called.
>
> An example:
> -----------------
> When the user logs in the address bar shows http://localhost:8080/myBrocade/myHome
> .
> When he clicks on 'MyAccount' tab, the uri in address bar is still
> showing http://localhost:8080/myBrocade/myHome (instead of
> myAccount). But the html content for myAccount is rendered.
>
> MyAccountResource looks like
>
> @Path("/myAccount")
> public class MyAccountResource extends BaseResource{
>
> @GET
> @Produces("text/html")
> public Viewable get() {
> return new Viewable("/myAccount/myAccount.jsp",this);
> }
>
> @Path("/siteAccess")
> public SiteAccessResource getSiteAccessResource(){
> return new SiteAccessResource();
> }
>
> }
>
>
> My question is how to dynamically update the URI in the address bar
> for XHR Ajax requests?
>
> Thanks
> Dinesh