Hi,
I am almost new to Wicket so I hope it's not a stupid question. I am
encountering an odd problem when adding two links to a single page in a
single DataView: for some reason clicking on the second link gets to the
onClick of the first one.
When I removed the first one from the page, clicking on the second worked
ok.
The reason i am doing this is that I need each row in a table to include 2
links that do different things.
Any ideas?
Thanks,
Guy
------------------------------------------
HTML:
<tr wicket:id="polls">
<td> # [id] </td>
<td>[name]</td>
<td>[description]</td>
<td>[question]</td>
<td>[answer 1]</td>
<td>[answer 2]</td>
<td>[answer 3]</td>
<td>[start time]</td>
<td>[end time]</td>
<td> # [active] </td>
</tr>
-----------------------------------------------------
JAVA:
protected void populateItem(final Item item) {
Poll poll = (Poll) item.getModelObject();
//first link
Link link = new Link("edit-link", item.getModel()) {
public void onClick() {
onEditPoll((Poll) getModelObject());
}
};
link.add(new Label("poll.id",
String.valueOf(poll.getId())));
item.add(link);
item.add(new Label("poll.name", poll.getName()));
item.add(new Label("poll.description",
poll.getDescription()));
item.add(new Label("poll.question", poll.getQuestion()));
item.add(new Label("poll.ans1", poll.getAns1()));
item.add(new Label("poll.ans2", poll.getAns2()));
item.add(new Label("poll.ans3", poll.getAns3()));
DateFormat dateFormatter = new
SimpleDateFormat("MM/dd/yyyy");
if (poll.getStartTime() != null) {
item.add(new Label("poll.startTime", dateFormatter
.format(poll.getStartTime())));
} else {
item.add(new Label("poll.startTime", ""));
}
if (poll.getEndTime() != null) {
item.add(new Label("poll.endTime", dateFormatter
.format(poll.getEndTime())));
} else {
item.add(new Label("poll.endTime", ""));
}
//second link
Link activeLink = new Link("active-link", item.getModel()) {
public void onClick() {
onActivePoll((Poll) getModelObject());
}
};
if (poll.isActive())
activeLink.add(new Label("poll.active", "deactivate"));
else
activeLink.add(new Label("poll.active", "activate"));
item.add(activeLink);
item.add(new AttributeModifier("class", true,
new LoadableDetachableModel() {
protected Object load() {
return (item.getIndex() % 2 == 1) ? "even"
: "odd";
}
}));
}
--
View this message in context:
http://www.nabble.com/problem-adding-two-links-to-a-page-tp16185819p16185819.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]