Hi
I can see a few things gond wrong here...
1> First in the onclick method , this does not refer to the original parent
to which label was added initially as label is the component u want to
replace
2> When u want to add a new component to replace the original component
in the parent heirarchy , u need to call replace method or replaceWith
method
3> Dont create the textfield right at the beginning. Do it in the onClick
method.
Here it just hangs out there until user clicks the link
-swaroop
On 6/21/07, ccc rrr <[EMAIL PROTECTED]> wrote:
Hi,
I want to change a component in html, for example:
*1)Test.html*
<html>
<body>
<span wicket:id="label"></span>
<br/>
<a wicket:id="ajaxLink">Click here</a>
</body>
</html>
*2)Test.java*
public class Test extends WebPage {
private int count = 0;
Label label = null;
TextField textField = null;
public Login() {
super();
label = new Label("label", new PropertyModel(this, "count"));
label.setOutputMarkupId(true);
textField = new TextField("label", new PropertyModel(this,
"count"));
textField.setOutputMarkupId(true);
AjaxLink ajaxLink = new AjaxLink("ajaxLink") {
public void onClick(AjaxRequestTarget request) {
count++;
if (count % 2 == 0)
{
this.add(label);
request.addComponent (label);
}
else
{
this.add(textField);
request.addComponent(textField);
}
}
};
this.add(label);
this.add(ajaxLink);
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
}
However, when I client the link, the Ajax message shows as:
INFO:
INFO: Initiating Ajax GET request on
/wicket/mytest/?wicket:interface=:0:ajaxLink::IBehaviorListener&wicket:behaviorId=0&random=
0.17448336090136768
INFO: Invoking pre-call handler(s)...
INFO: Received ajax response (53 characters)
INFO:
<?xml version="1.0" encoding="UTF-8"?><ajax-response>
ERROR: Error while parsing response: Could not find root <ajax-response>
element
INFO: Invoking post-call handler(s)...
INFO: Invoking failure handler(s)...
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user