Friday, December 9, 2016

How to set Custom Attribute for SmartGWT Widget

I want to get the attribute of the smartgwt widget which i am setting like the way in GWT. For example in GWT:

//Button creation
 Button btn1 = new Button(" Button 1");   Button btn2 = new Button("Button 2");   Button btn3 = new Button("Button 3");    //setting the attribute to button doms   btn1.getElement().setAttribute("data-tracking", "Button 1 clicked");   btn2.getElement().setAttribute("data-tracking", "Button 2 clicked");   btn3.getElement().setAttribute("data-tracking", "Button 3 clicked");        //Global handler to catch all the event in my application          Event.addNativePreviewHandler(new NativePreviewHandler() {                public void onPreviewNativeEvent(final NativePreviewEvent event) {                  final int eventType = event.getTypeInt();                  switch (eventType) {                      case Event.ONCLICK:                       System.out.println("on clikc clicked"+Element.as(event.getNativeEvent().getEventTarget()).getAttribute("data-tracking"));  //getting the button attribute                        if(Element.as(event.getNativeEvent().getEventTarget()).getAttribute("data-tracking")!=null && !Element.as(event.getNativeEvent().getEventTarget()).getAttribute("data-tracking").equals("")){                       googleAnalyticsTrackPageView(Element.as(event.getNativeEvent().getEventTarget()).getAttribute("data-tracking"));                       }                      break;                    }                }              });

But in SmartGWT, i was not able to set/get this attribute. Is there a way to solve this problem?

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment