On Thursday, August 23, 2012 4:16:25 PM UTC+2, Magnus wrote:
>
> @Override
> public void render (Context context,Game value,SafeHtmlBuilder sb)
> {
> String t = renderCommand ("O","Open");
> sb.appendHtmlConstant(t);
>
> sb.appendHtmlConstant(" ");
>
> t = renderCommand ("E","Edit");
> sb.appendHtmlConstant(t);
> }
>
> public String renderCommand (String cmd,String lbl)
> {
> String t = "<a href='javascript:;' style='cursor: hand;' cmd='" + cmd +
> "'>" + lbl + "</a>";
>
> return (t);
> }
>
> @Override
> public void onBrowserEvent (Context context, Element parent,Game
> value,NativeEvent event, ValueUpdater<Game> valueUpdater)
> {
> super.onBrowserEvent(context, parent, value, event, valueUpdater);
>
> EventTarget tgt = event.getEventTarget();
> Element e = Element.as(tgt);
> String c = e.getAttribute("cmd");
> Window.alert("Command: " + c);
> }
> }
>
FYI, that'd be even easier (and possibly faster) with UiRenderer. Event
handling would be much easier, unless you really need that "command
identifier as a string" approach.
https://developers.google.com/web-toolkit/doc/latest/DevGuideUiBinder#Rendering_HTML_for_Cells
And as Juan Pablo said, you shouldn't use <a> for actions, use a <button>
or a <span> and style it like a link if you wish, but do not abuse <a>.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/I807ix1DQX4J.
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.