the label will not be updated because its model is constant.
to have it updated do this
new Label("counter", new PropertyModel(this, "count")); and add a int getCount()
also in the onclick handler remove these two lines, they are not necessary and will break your code:
RequestCycle rc = getRequestCycle();
rc.setRequestTarget(new ComponentRequestTarget(counter));
-Igor
On 2/18/06, Ayodeji Aladejebi <
[EMAIL PROTECTED]> wrote:
What may be wrong with these codepublic class MyAjaxPage extends WebPage {private int count = 0;public MyAjaxPage(){add(counter = new Label("counter", String.valueOf(count)));add(new AjaxLink("ajlink") {
public void onClick(AjaxRequestTarget target) {
// Increment count
count++;
RequestCycle rc = getRequestCycle();
rc.setRequestTarget(new ComponentRequestTarget(counter));
target.respond(rc);
}
});
}Anyway, it did not even initialize cuz, tomcat returnedjava.lang.NoSuchMethodError: wicket.ajax.markup.html.AjaxLink.add(Lwicket/behavior/IBehavior;)Lwicket/Component;
wicket.ajax.markup.html.AjaxLink.<init>(AjaxLink.java:52)
wicket.ajax.markup.html.AjaxLink .<init>(AjaxLink.java:39)
net.cowblock.developer.models.NewDeveloper$5.<init>(NewDeveloper.java:147)
net.cowblock.developer.models.NewDeveloper.<init>(NewDeveloper.java:147)
...any light?