views:

873

answers:

2

I asked a related question here

How do I programatically write parameters into the URL using GWT? I've learned from my previous question that parameters need to go before the anchor, but how do I do that from GWT?

Here's the code that doesn't work:

Hyperlink pg1 = new Hyperlink("Test", "?testing=abc#pg1");

It results in the following url:

http://localhost:8080/Athena.html#?testing=abc%23pg1

I was thinking about using Window.Location.assign(), but the javadoc says that will loose the state of my application.

+1  A: 

You are using this constructor which receives a history token as the second constructor argument, hence you are getting said result.

Use the setHTML() method to set the correct value on the link.

Yuval A
Can you provide any examples? I tried setHTML("<a href='?testing=abc'> test </a>") without any luck.
KevMo
+3  A: 

The object HyperLink seems to be for linking to internal states, and probably was written so that changing its href is difficult?

I suggest you use this class http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/ui/InlineHTML.html instead - obviously you are generating the href programatically, so it should be easy to generate the element to supply to the InlineHTML object.

Chii
That works, I just wish there was some easy built in way to set the parameters, just like there is for getting them.
KevMo
@KevMo - does this work without a page refresh???
cinqoTimo
I've given up trying to pass parameters using standard url parameters. GWT works much better when you just give in to their ways ;)I'm using the following in my application now: http://website.com/page.html#view~testing:abc,foo:barI then have a function that reads everything after the hash tag, and puts the parameters in a Map for easy use within my code.
KevMo