users@jersey.java.net

Question on Xhr ajax requests

From: Dinesh Narayanan <ndchandar_at_gmail.com>
Date: Mon, 5 Oct 2009 23:08:17 -0700

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