I am using Wicket 6.8 and have a sortable DefaultDataTable that gets its
columns programmatically. 

The markup to get this table and the dynamically generated columns simple
(I've added spaces so it all shows):

        < wicket:panel>
            < table wicket:id="dataTable" border="0" cellpadding="1"
cellspacing="1" width="90%" / >
        < /wicket:panel>

All of the columns are generated from a passed in LinkedHashMap of labels
and attributes:

    for (Entry<String, String> entry : entrySet) {
        final String label = entry.getKey();
        final String attribute = entry.getValue();
        columns.add(new PsPropertyColumn(label, attribute) {

            @Override
            public void populateItem(Item cellItem, String componentId,
IModel model)
            {
                final Object modelObject = model.getObject();
                final Object value = PropertyResolver.getValue(attribute,
modelObject);
                // Add an edit link
                BookmarkablePageLink link = new ...;
                ...
                cellItem.add(link);
            }
        }
    }

    DefaultDataTable table = new DefaultDataTable("dataTable", columns,
dataProvider, MAX_ROWS) {
        ...
    }
    add(table);

So this properly displays as a sortable table with clickable columns that
send the user to the required page.  However, as many posts have mentioned,
this is rendered as a cell with an onclick handler rather than an anchor (<
a href="..." />) tag. I want the anchor tag for a couple of reasons, one if
which is that I want to add my own onclick handler without having an
existing onclick handler in the way.

I have seen a solution that says to put an anchor tag inside a panel in the
HTML markup, and to add the link inside of a Panel subclass.  Sadly for me
the markup in the examples wasn't complete, and whatever I try (anchor tags,
tr/td tags, panel tags, etc.), I get the same error:

     Last cause: Close tag not found for tag: 
. For Components only raw markup is allow in between the tags but not other
Wicket Component. Component: [DefaultDataTable [Component id = dataTable]] 

Here is the simplest thing I've tried:

        < wicket:panel>
            < table wicket:id="dataTable" border="0" cellpadding="1"
cellspacing="1" width="90%">
                < a href="#" wicket:id="link">< /a>
            < /table>
        < /wicket:panel>

Again, no success.  I would love to see markup that allows the
BookmarkablePageLinks be rendered insided the DefaultDataTable as anchor
tags.  Thanks in advance for any help.





--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-to-dynamically-add-a-hyperlink-BookmarkablePageLink-to-DefaultDataTable-that-is-rendered-as-an-ar-tp4659502.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to