lazydaemon
lazydaemon

Reputation: 2509

How to create restful-links with wicket dynamically?

I want to create a restful link for each user, who registered on my page. For Example: User "testuser" registered on my page and his profile should be accessible through www.mypage.com/users/testuser.

How can i realize something in wicket?

Upvotes: 0

Views: 850

Answers (3)

pushistic
pushistic

Reputation: 3396

in WebApplication implementation add to init():

mountPage("/users/${id}", UserPage.class);

and in UserPage.class :

public UserPage(PageParameters parameters) {
     String id = parameters.get("id").toString();
    ...
}

Upvotes: 3

bert
bert

Reputation: 7696

Have a look at mounting pages in wicket 1.5. It describes the methods to 'mount', aka make available, a page on a certain url. Parameters to that page (in your case, the user name) can either be via name or via index (position).

You will be interested in the positioning parameters.

Upvotes: 0

magomi
magomi

Reputation: 6685

Is it possible to introduce a additional url path element? Something like "http://server/users/userid/testuser"? If you have mount your page to the url "users" then the page will be initialized by wicket using the constructor with the PageParameters parameter:

public class UserPage extends WebPage {
    public UserPage(PageParameters pars) {
        String userId = pars.getParameterValue("userid");
        ...
    }
}

Upvotes: 0

Related Questions