Redirect to place

50 views
Skip to first unread message

Juan Pablo Gardella

unread,
Jun 9, 2011, 12:22:30 AM6/9/11
to google-we...@googlegroups.com
Hi folks,

I have a problem with places. For example I have the URL  "http://mysite/myapp#editrecordd:10" and I want with this URLgo to place EditRecordPlace (OK!), but if I have this URL  "http://mysite/myapp#editrecordd:10asiuo" (the id can't cast to a number) I want to go to another place, for example newRecordPlace.

I can do that in this manner:

public Activity getActivity(Place place) {
                       ...
if (place instanceof EditRecordPlace && ((EditRecordPlace )place).getId()==null){
return appPlaceFactory.getNewRecordPlace().getActivity();
}
...
}

But the problem is that no refresh the URL, I want display in the URL newRecord and start the activity. If I invoque the placecontroller.goTo(appPlaceFactory.getNewRecordPlace()) don 't works. 

Regards,
Juan

A. Stevko

unread,
Jun 9, 2011, 2:25:36 AM6/9/11
to google-we...@googlegroups.com
I suggest you put the logic for parsing the place token within the Activity.start() and if it does not parse then use placeController.goTo() to load the NewRecordPlace. That way the association between activity and place is relatively constant and the validation of the token is determined by the layer that has the best access to the data model.


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
-- A. Stevko
===========
"If everything seems under control, you're just not going fast enough." M. Andretti





Juan Pablo Gardella

unread,
Jun 9, 2011, 8:10:46 AM6/9/11
to google-we...@googlegroups.com
Thanks Andy,

If I put placeController.goTo(aPlace) in the start method works partially. Show me the correct screen, but not the URL. It's strange what do.

For example I put in URL:


In view1Activity start() i invoque:

   placeController.goTo(place2);

Then in the browser show me the correct screen but in the URL put http://host/myApp#view1Place but if I press backbutton show me the correct URL http://host/myApp#view1Place2.

Is this an issue? I can make a sample to reproduce and open an issue with this problem

Thanks,
Juan


2011/6/9 A. Stevko <andy....@gmail.com>

mram

unread,
Jun 9, 2011, 10:23:45 AM6/9/11
to Google Web Toolkit
Hola Juan Pablo,
Pienso que tu problema tiene que ver con el HistoryMapper.
I think that you're problem could be in the HistoryMapper. Look up the
configuration of the tokenizers if you're using the MVP directives for
GWT.
Hope this helps. Espero haber sido de ayuda.
Saludos

On 9 jun, 14:10, Juan Pablo Gardella <gardellajuanpa...@gmail.com>
wrote:
> Thanks Andy,
>
> If I put placeController.goTo(aPlace) in the start method works partially.
> Show me the correct screen, but not the URL. It's strange what do.
>
> For example I put in URL:
>
> *http://host/myApp#view1Place*
>
> In view1Activity start() i invoque:
>
>    placeController.goTo(place2);
>
> Then in the browser show me the correct screen but in the URL put *http://host/myApp#view1Place**but *if I press backbutton show me the
> correct URL *http://host/myApp#view1Place2.*
> *
> *
> Is this an issue? I can make a sample to reproduce and open an issue with
> this problem
>
> Thanks,
> Juan
>
> 2011/6/9 A. Stevko <andy.ste...@gmail.com>
>
> > I suggest you put the logic for parsing the place token within the
> > Activity.start() and if it does not parse then use placeController.goTo() to
> > load the NewRecordPlace. That way the association between activity and place
> > is relatively constant and the validation of the token is determined by the
> > layer that has the best access to the data model.
>
> > On Wed, Jun 8, 2011 at 9:22 PM, Juan Pablo Gardella <
> > gardellajuanpa...@gmail.com> wrote:
>
> >> Hi folks,
>
> >> I have a problem with places. For example I have the URL  "
> >>http://mysite/myapp#editrecordd:10" and I want with this URLgo to place
> >> EditRecordPlace (OK!), but if I have this URL  "
> >>http://mysite/myapp#editrecordd:10asiuo" (the id can't cast to a number)
> >> I want to go to another place, for example newRecordPlace.
>
> >> I can do that in this manner:
>
> >> public Activity getActivity(Place place) {
> >>                         ...
> >>  if (place instanceof EditRecordPlace &&
> >> ((EditRecordPlace )place).getId()==null){
> >> return appPlaceFactory.getNewRecordPlace().getActivity();
> >>  }
> >> ...
> >> }
>
> >> But the problem is that no refresh the URL, I want display in the URL *
> >> newRecord* and start the activity. If I invoque the

Juan Pablo Gardella

unread,
Jun 9, 2011, 10:41:03 AM6/9/11
to google-we...@googlegroups.com
Hi,

Thanks for your time!! The history mapper is right becouse it works. The problem is when I call placeControler.goTo inner the start() method. I think queue the event, but works as a LIFO with respect URL becouse for one side show correct screen but not URL, show the first.

PlaceController pc= ...;

1) In some side in the code I call: pc.goTo(place1);
2) In the activity associate with place1:
    start(..){ pc.goTo(place2));

RESULT:

1) show in screen place2.
2) show the url correspond to place1.

Juan

2011/6/9 mram <mra...@gmail.com>

Jens

unread,
Jun 9, 2011, 1:30:50 PM6/9/11
to google-we...@googlegroups.com
Seems like an event handling problem. Maybe this problem is by design as you fire a PlaceChangeEvent while the first one is still dispatched by the eventbus or its just a bug. So maybe you can create an issue for it...just to be sure.

In the meantime in you Activity's start method something like

Scheduler.get().scheduleDeferred(new ScheduledCommand() {

  @Override

  public void execute() {

    placeController.goTo(new YourNewPlace());

  }

});


should work. This will make sure that the redirect will be executed after everything else is done.


-- J.

Juan Pablo Gardella

unread,
Jun 9, 2011, 1:51:15 PM6/9/11
to google-we...@googlegroups.com
Thanks Jens!!! It works!!! I'll open an issue

Juan

2011/6/9 Jens <jens.ne...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.

Zdenek

unread,
Jan 20, 2012, 9:14:04 AM1/20/12
to google-we...@googlegroups.com
Did you open the issue? I'm having same problem.

Scheduling the change event works fine.

Juan Pablo Gardella

unread,
Jan 20, 2012, 7:40:44 PM1/20/12
to google-we...@googlegroups.com
No, I didn't open an issue.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
Reply all
Reply to author
Forward
0 new messages