How to combine History and URL Parameters?

259 views
Skip to first unread message

markww

unread,
Jun 26, 2009, 2:56:37 PM6/26/09
to Google Web Toolkit
Hi,

I'm not sure how we use history and parameters in GWT. For example,
when my user wants to go to a login page, I do this:

History.newItem("login");

which makes the url:

www.mysite.com/myproject.html#login

that's ok, if they copy and paste that url to another browser
instance, my app knows to automatically show the login "page".

But what if we want to add some parameters, for instance, if we wanted
to create a chat room page, something like:

History.newItem("chat");
URL.addParameter("id", "1234");
URL.addParameter("color", "red");

to make something like:

www.mysite.com/myproject.html#chat?id=1234&color=red

I'm not sure how we can do that in GWT, but basically it would let the
user copy and paste that url into another instance, and my app would
be able to know to load page chat, with parameters 1234 and red.

Thanks

Mark

unread,
Jun 26, 2009, 3:06:36 PM6/26/09
to Google Web Toolkit
I guess I could kind of cheat and stick it all in the History call?:

History.newItem("chat?id=1234&color=red");

this will kind of make sense to end users, and I can just parse the
history item myself for all the parameters - anything horribly wrong
with this, or any easier way?

Thanks

Ian Bambury

unread,
Jun 26, 2009, 3:38:00 PM6/26/09
to Google-We...@googlegroups.com
Personally, I use history for menu structure. In your case I would imagine that #chat would take you to a list and #chat/123 would take you to an actual room. 'color=red' would either be kept in the user's settings, or possibly in a cookie for users who don't log on. But I'd probably think 'if they can't be bothered to log on, then stuff it - one more reason to sign up.' :-)


Ian

http://examples.roughian.com


2009/6/26 Mark <mar...@gmail.com>

Mark

unread,
Jun 26, 2009, 4:35:02 PM6/26/09
to Google Web Toolkit
Thanks Ian - that forward slash you have though - that's just created
in a call like:

String chatRoomId = "123";
History.newItem("chat/" + chatRoomId);

right? There's not some other special GWT method for appending those
sorts of 'parameters', delimited by forward slash?

Thanks

Ian Bambury

unread,
Jun 26, 2009, 8:47:38 PM6/26/09
to Google-We...@googlegroups.com
No. You have to roll your own using some character that you are not going to use in the actual string. My current site uses the tilde (~) but the new version will probably use the forward slash. I also to a bit of replacing to get rid of anything that turns into %nn so it is still readable, e.g. http://examples.roughian.com/#Tutorials~Custom_Event 

Piotr Kirklewski

unread,
Jun 26, 2009, 11:30:47 PM6/26/09
to Google-We...@googlegroups.com
Hi

I'm getting some values from Postgres database.
The First column is Date in the following format: 2008-01-01 01:00:00

But when i put the results int the array by this command: dt[m]= new
Date(res.getTimestamp(1).getNanos());
Then I get : Wed Dec 31 19:00:00 EST 1969

What's going on ?

Regards

PEter


Mark

unread,
Jun 27, 2009, 9:09:35 AM6/27/09
to Google Web Toolkit
Ok thanks Ian, makes sense,

Mark

On Jun 26, 11:30 pm, Piotr Kirklewski
Reply all
Reply to author
Forward
0 new messages