You can also make a HyperlinkCell:
/**
* {@link Cell} that wraps a {@link Hyperlink}
* WARNING: make sure the contents of your Hyperlink really are safe from
XSS!
*/
public class HyperlinkCell extends AbstractCell<Hyperlink>
{
@Override
public void render(com.google.gwt.cell.client.Cell.Context context,
Hyperlink h, SafeHtmlBuilder sb)
{
sb.append(SafeHtmlUtils.fromTrustedString(h.toString()));
}
}
and use it in a Column like this:
// Note Flyweight pattern: only one instance of HyperlinkCell passed to
the Column
Column<ItemListProxy, Hyperlink> linkColumn = new Column<ItemListProxy,
Hyperlink>(new HyperlinkCell())
{
@Override
public Hyperlink getValue(ItemListProxy list)
{
String proxyToken =
clientFactory.getRequestFactory().getHistoryToken(list.stableId());
String historyToken =
clientFactory.getHistoryMapper().getToken(newEditListPlace(proxyToken));
Hyperlink h = new Hyperlink(list.getName(),historyToken);
return h;
}
};
This code is lifted from ListsViewImpl in the listwidget sample project:
http://code.google.com/p/listwidget/
/dmc
On Mon, Mar 14, 2011 at 10:58 AM, John LaBanca <[email protected]> wrote:
> You can render an anchor tag with a no-op href:
> <a href="javascript:;">Click Me</a>
>
> In your Cell, catch the click event and call History.newItem("myToken").
> This is basically what the Hyperlink Widget does.
>
> Thanks,
> John LaBanca
> [email protected]
>
>
>
> On Sat, Mar 12, 2011 at 1:07 PM, Jake <[email protected]> wrote:
>
>> I want to create a CellTable with a column of Hyperlinks.
>> I'm trying to get the same behavior as the Hyperlink widget - e.g.: If
>> you click it, it'll call History.newItem(), but a user is also able to
>> do 'right-click, open link in new window'.
>>
>> The two possibilities seem to be
>> 1) put plain text into a column, and implement the selection model to
>> trigger History.newItem. Unfortunately, if you do this, 'right click,
>> open link in new window' does not work, as it is not a 'true'
>> hyperlink
>> 2) Put HTML into a column, using a <a> tag with a # URL.
>> Unfortunately, this causes a page reload in IE, as per Issue #2152 in
>> GWT's issue tracker.
>>
>> Has anyone found a solution to this?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Web Toolkit" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-web-toolkit?hl=en.
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
--
David Chandler
Developer Programs Engineer, Google Web Toolkit
w: http://code.google.com/
b: http://googlewebtoolkit.blogspot.com/
t: @googledevtools
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.