Link#onClick does not fire in specific case.
--------------------------------------------
Key: WICKET-1345
URL: https://issues.apache.org/jira/browse/WICKET-1345
Project: Wicket
Issue Type: Bug
Components: wicket
Affects Versions: 1.3.1
Environment: tested on freebsd jvm-1.6 and linux jvm-1.6
Reporter: Victor Igumnov
Priority: Critical
Here is the test case that triggers it.
LeaveGroupLink works *perfectly* if on a page as-is; it is visible and
onClick() fires. However, if I add LeaveGroupLink to a repeater (listview), the
link is visible but onClick() does not fire. I scanned around the wicket source
and noticed a comment about component callback won't execute if isVisible is
false. So the component *renders* but onClick is never fired when Link is in a
repeater component.
public class LeaveGroupLink extends Link {
private static final long serialVersionUID = 1L;
public LeaveGroupLink(final String id, final IModel model) {
super(id, model);
}
@Override
public void onClick() {
// did some basic println message to see if it fired. No message displayed
WebAppSession sess = (WebAppSession) Session.get();
Group g = (Group) getModelObject();
sess.getGroupService().leaveGroup(g, sess.getUser());
}
@Override
public boolean isVisible() {
WebAppSession sess = (WebAppSession) Session.get();
Group g = (Group) getModelObject();
// I made sure this turns true or false... not a service level issue.
return sess.getUser().getGroupMembership().contains(g);
}
}
Here is the work around that works in a repeater .
public class LeaveGroupLink extends Link {
private static final long serialVersionUID = 1L;
public LeaveGroupLink(final String id, final IModel model) {
super(id, model);
}
@Override
public void onClick() {
// did some basic println message to see if it fired. No message displayed
WebAppSession sess = (WebAppSession) Session.get();
Group g = (Group) getModelObject();
sess.getGroupService().leaveGroup(g, sess.getUser());
}
@Override
protected void onBeforeRender() {
super.onBeforeRender();
WebAppSession sess = (WebAppSession) Session.get();
Group g = (Group) getModelObject();
setVisible(sess.getUser().getGroupMembership().contains(g));
}
}
If I use it like this, it works correctly in the repeater.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.