Thursday, September 26, 2013

Re: How to create event on safe html

I have added event as below:

SafeHtmlBuilder builder = new SafeHtmlBuilder();      builder.appendHtmlConstant("<input type=\"text\" id=\"nameInput\" /><br/><br/><select><option>one</option></select><br/><center><b>Name</b></center>");      SafeHtml html= builder.toSafeHtml();      cell.addColumn(namecolumn,builder.toSafeHtml());      SafeHtmlBuilder builder1 = new SafeHtmlBuilder();      builder1.appendHtmlConstant("<input type=\"text\"/><br/><br/><select><option>one</option></select><br/><center><b>Last name</b></center>");      cell.addColumn(lastNameColumn,builder1.toSafeHtml());      SafeHtmlBuilder builder2 = new SafeHtmlBuilder();      builder2.appendHtmlConstant("<input type=\"text\"/><br/><br/><select><option>one</option></select><br/><center><b>Age</b></center>");      cell.addColumn(ageColumn,builder2.toSafeHtml());      personCollection.addDataDisplay(cell);      verticalPanel.add(searchpanel);      verticalPanel.add(cell);        final Element nameInput = DOM.getElementById("nameInput");      if(nameInput!=null)      {      Event.sinkEvents(nameInput, Event.ONCHANGE);      Event.setEventListener(nameInput, new EventListener() {            @Override          public void onBrowserEvent(Event event) {              personCollection.setFilter(nameInput.getInnerText());              personCollection.refresh();          }      });

First problem I am getting nameInput is null every time.

and Second that This is just sample. I want to create this column dynamically. so is it possible to add DOM event dynamically for run time generated DOM element?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" 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 http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment