Sorry I'm not sure I follow.
What I'm trying is to add a new PageParameter to the set that the current page is created with. So I get the Page, get it's pageParameters and add a new one to the existing set and feed that to the bookmarkablepagelink.

If I would do:

protected void populateItem(ListItem item) {
 PageParameters p = new PageParameters();
 String key = (String)item.getModelObject();
 p.add("key", key);
 BookmarkablePageLink lnk = new BookmarkablePageLink("link", HomePage.class, p);
 item.add(lnk);
}


the bookmarkablepagelink would only contain the new pageparameter, not the already existing pageparameters

What happens now is that getPage().getPageParameters is not returning the PageParameters from the current page, but is returning the pageparameters I just added to the bookmarkablepagelink + the ones that are already in getPage().getPageParameters.

So if you take the example below, and say I have clicked on the first link. The output of HTML would then look like:

<li wicket:id="test">
<a href="?key=aaa&amp;key=aaa" wicket:id="link">test</a>
</li>
<li wicket:id="test">
<a href="?key=aaa&amp;key=aaa&amp;key=bbb" wicket:id="link">test</a>
</li>
<li wicket:id="test">
 <a href="?key=aaa&amp;key=aaa&amp;key=bbb&amp;key=ccc" 
wicket:id="link">test</a>
</li>
<li wicket:id="test">
 <a href="?key=aaa&amp;key=aaa&amp;key=bbb&amp;key=ccc&amp;key=ddd" 
wicket:id="link">test</a>
</li>

While I expect:

<li wicket:id="test">
<a href="?key=aaa&amp;key=aaa" wicket:id="link">test</a>
</li>
<li wicket:id="test">
<a href="?key=aaa&amp;key=bbb" wicket:id="link">test</a>
</li>
<li wicket:id="test">
<a href="?key=aaa&amp;key=ccc" wicket:id="link">test</a>
</li>
<li wicket:id="test">
<a href="?key=aaa&amp;key=ddd" wicket:id="link">test</a>
</li>

Thijs

Martijn Dashorst schreef:
So why don't you expect the loop to add them to the existing parameters?

Martijn

On 3/13/08, Thijs <[EMAIL PROTECTED]> wrote:
 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&amp;key=bbb" wicket:id="link">  test  </a>
 >>  </li>
 >>  <li wicket:id="test">
 >>     <a href="?key=aaa&amp;key=bbb&amp;key=ccc" wicket:id="link">  test </a>
 >>  </li>
 >>  <li wicket:id="test">
 >>     <a href="?key=aaa&amp;key=bbb&amp;key=ccc&amp;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]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to