M
M
Mikhail Voitenko2013-11-22 13:33:25
Java
Mikhail Voitenko, 2013-11-22 13:33:25

How to parse parameters from URL in GWT application?

I fasten MVP to my application. It implements searching, adding and editing various users. I want to implement viewing a page with user data by specifying a URL with a user id. User page URL example:

http://127.0.0.1:8888/UsersTest.html?gwt.codesvr=127.0.0.1:9997#user:id=1385115818992

To do this, in the Place of this page, I implemented the method
@Override
        public UserFormPlace getPlace(String url) {
          long  id = Long.parseLong(Window.Location.getParameter("id"));
           return new UserFormPlace(id);
        }

But when trying to navigate to a URL like
http://127.0.0.1:8888/UsersTest.html?gwt.codesvr=127.0.0.1:9997#user:id=SOME_LONG_ID
- Throws a NumberFormatException.
Checked - Window.Location.getParameter("id")returns null.
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur, 2013-11-24
@Firehanded

In this case, your code will return the value of the parameter if it is in the form:
"?myparam=myvalue&myparam2=myvalue2". That is, in the form of normal query parameters in url . Put '?' instead of ':' .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question