That worked. Thanks.
-Ramnivas
Igor Vaynberg wrote:
you didn tactually replace anything in the page hierarchy
which is where you need to do it. the components you add to the target
are only queued for rendering, nothing more.
so what you need to do in the onclick is:
public void onClick(AjaxRequestTarget target) {
System.out.println("Update Link Clicked");
Label label=new Label("updateText", new
Date().toString());
// do the actual replacement of the panel
getParent().replace(label);
// queue the new panel for ajax rendering
target.addComponent
(label);
}};
-Igor
On 4/2/06, Ramnivas
Laddad <[EMAIL PROTECTED]>
wrote:
I
am trying to use AjaxLink to replace one component with another.
However, it doesn't seem to work. In real project, I need to replace
one
panel with completely different panel, hence merely modifying the model
and invoking addComponent() with the existing component won't be
sufficient.
Here is an illustrative example. I have been trying with beta2, but
just
updated to beta3. It has somewhat different behavior, but still the same
overall effect.
Markup:
<html>
<head></head>
<body>
<a id="updateLink" wicket:id="updateLink">Click here to
update
text</a>
<span id="updateText"
wicket:id="updateText">current</span>
</body>
</html>
Java:
public class AjaxUpdatedLabelHome extends WebPage {
public AjaxUpdatedLabelHome() {
AjaxLink updateLink = new AjaxLink("updateLink") {
@Override
public void onClick(AjaxRequestTarget target) {
System.out.println
("Update Link Clicked");
target.addComponent(new Label("updateText", new
Date().toString()));
}};
add(updateLink);
add(new Label("updateText", "Current time will be displayed
here"));
}
}
I do see the "Update Link Clicked" message when I click on the link.
However, I do not see the label being replaced. The Wicket Ajax Debug
windows shows that a runtime exception is thrown --
"java.lang.IllegalArgumentException: markupId cannot be empty" (the same
behavior as beta2).
So I modified the code to explicitly provide the markup id:
target.addComponent(new Label("updateText", new
Date().toString()), "updateText");
I still do not see the label being replaced. The Wicket Ajax Debug
window shows the following output:
INFO:
INFO: initiating ajax GET request with...
INFO: url:
/quickstart/app?wicket:interface=:1:updateLink::IBehaviorListener&wicket:behaviorId=0
INFO: successHandler:function () {
}
INFO: failureHandler:function () {
}
INFO: received ajax response. 53 characters, envelope following...
INFO:
INFO: <?xml version="1.0" encoding="UTF-8"?><ajax-response>
ERROR: malformed response envelope: could not find root
<ajax-response>
element
INFO: invoking failure handler...
ERROR: error while processing response: TypeError: root has no
properties.root has no properties
INFO: invoking failure handler...
What could be going wrong? Please help.
-Ramnivas
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user
|