users@jersey.java.net

Re: [Jersey] Question on Xhr ajax requests

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

Felipe,
Could you please elaborate on your suggestion. Currently the way I have
designed is that a) When the user logs in, he will goto MyHomeResource(
which will render html content from myHome.jsp. This also has a placeholder
for all div's for all of the widgets - div id widget1, widget2 etc..for all
tabs)
     b) Now when user clicks on 'myAccount' tab, I destroy all widgets that
were created (using Dojo) for myHome dynamically and create new widgets for
myAccount tab(by making an Xhr request to MyAccountResource).

The weird thing about this solution is that even though I have rendered for
content for MyAccount, the uri in the address bar is still showing
 '/myHome' (instead of '/myAccount') which is confusing for the end user.

What is the recommended way of doing an xhr request and still dynamically
update the uri in the address bar too?

Thanks
Dinesh


On Mon, Oct 5, 2009 at 11:16 PM, Felipe Gaucho <fgaucho_at_gmail.com> wrote:

> 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>
> http://localhost:8080/myBrocade/myHome.
>
> When he clicks on 'MyAccount' tab, the uri in address bar is still showing
> <http://localhost:8080/myBrocade/myHome>
> 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
>
>