because I want to use the already existing parameters and add them to
the link.
Thijs
Martijn Dashorst schreef:
Why don't you create a new PageParameters object in each populateItem?
Martijn
On 3/13/08, Thijs <[EMAIL PROTECTED]> wrote:
I'm having troubles with pageparameters.
when I use Page.getPageParameters() they are always null untill I call
super(paramters) in my constructor.
But when I then add a BookmarkablePageLink I get very strange behavior.
See the following example code:
public HomePage(final PageParameters parameters) {
super(parameters);
ArrayList list = new ArrayList();
list.add("aaa");
list.add("bbb");
list.add("ccc");
list.add("ddd");
add(new ListView("test", list ){
protected void populateItem(ListItem item) {
PageParameters p = item.getPage().getPageParameters(); //
getPage().getPageParameters();
if(p==null) p = new PageParameters();
String key = (String)item.getModelObject();
p.add("key", key);
BookmarkablePageLink lnk = new BookmarkablePageLink("link",
HomePage.class, p);
item.add(lnk);
}
});
}
this results in a page that constructs links that look like:
<li wicket:id="test">
<a href="?key=aaa" wicket:id="link"> test </a>
</li>
<li wicket:id="test">
<a href="?key=aaa&key=bbb" wicket:id="link"> test </a>
</li>
<li wicket:id="test">
<a href="?key=aaa&key=bbb&key=ccc" wicket:id="link"> test </a>
</li>
<li wicket:id="test">
<a href="?key=aaa&key=bbb&key=ccc&key=ddd"
wicket:id="link"> test </a>
</li>
As you can see the pageparameters are added to the previously created
pageparameters.
While I was expecting that every link had it's own key, and that when I
click the link, the previous parameters would be added to the new link.
Debugging shows that for every loop over populateItem,
getPage().getPageParameters() returns the newly created PageParameters
instead of the current PageParameters.
Am I doing something wrong?
Thijs
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]