Hi all,

Forgive my ignorance if this is too obvious.  I'm using DefaultDataTable to
display search results, and that's working fine.  What I'd like to do is
make each row of the table a hyperlink to the view/edit page of the record
in question.  How can I do this?

I was able to add links to a column, although they don't show up in the
browser as actual links.  Rather, they appear as text with associate
javascript to process an onclick event.  Here's the custom column I created
for this purpose:

private class IncidentLinkPropertyColumn extends PropertyColumn
<IncidentReport> {

public IncidentLinkPropertyColumn (IModel <String> nameModel, String
propertyName) {
super (nameModel, propertyName);
}
 @Override
public void populateItem (Item <ICellPopulator <IncidentReport>> item,
String componentId,
IModel <IncidentReport> model) {
PageParameters params = new PageParameters ();
params.put ("incidentId", model.getObject ().getRecordId ());
item.add (new LabelLink (componentId, CreateOrEditIncidentPage.class,
params));
}

private class LabelLink extends BookmarkablePageLink <Object> {
private static final long serialVersionUID = 3429331456890689136L;

public LabelLink (String componentId, Class <? extends Page> pageType,
PageParameters parameters) {
super (componentId, pageType, parameters);
}
 @Override
protected void onComponentTagBody (MarkupStream markupStream, ComponentTag
openTag) {
replaceComponentTagBody (markupStream, openTag, "click here!");
}
}
}

As I said, I'd like the rows to be links to the IncidentReport, but barring
that, it would be nice if the link column actually appeared as links, so
users can right-click to open in a separate tab.  If necessary, I can draft
an informational column (like ID) to serve as a link, as long as it is a
true link (so it will be visually obvious, as well as retaining right-click
functionality).

Any ideas?  Thanks in advance.

Reply via email to