DOM events don't work in nested uibinder

62 views
Skip to first unread message

Deepak Singh

unread,
Feb 1, 2012, 2:57:10 PM2/1/12
to google-we...@googlegroups.com
Hi All,

With respect to GWT 2.4

I have to add many objects of a uibinder widgets(e.g.inner Uibinder) at a particular location in another uibinder(e.g. outer uibinder).
So the DOM events associated with fields in inner uibinder does not work.

Here is the clear picture,

html:-
<div id="myHtml"></div>


outer uibinder

<g:HTMLPanel ui:field="outerHtmlPanel"> 
     <div ui:field="placeholder">  </div>
</g:HTMLPanel> 

inner uibinder

<g:HTMLPanel ui:field="innerHtmlPanel"> 
     <g:Button ui:field="innerBtn"></g:Button>
</g:HTMLPanel> 

Java code for inner ui binder

@uifield Button innerBtn;

inner() {
 innerBtn.addClickHandler() {
    // some event
}
}



Now,

onModuleLoad() {
  
Outeruibinder out = new Outeruibinder();   
out.placehoplder.appendChild(new innerUiBinder());
out.placehoplder.appendChild(new innerUiBinder());
out.placehoplder.appendChild(new innerUiBinder());

RootPanel.get("myHtml").add(out);
}


Now, while rendering, three innerUiBinder objects appear properly but the event associated with button in innerUiBinder does not fire.

Can someone pls guide on this.

Thanks
Deepak

--
Deepak Singh

Thomas Broyer

unread,
Feb 1, 2012, 5:18:24 PM2/1/12
to google-we...@googlegroups.com
Widgets have to be "attached" for their events to work, so use outerHtmlPanel.add(innerWidget, placeholder);

The fact that innerWidget is built with UiBinder has no consequence at all.

Clint Checketts

unread,
Feb 1, 2012, 11:30:36 PM2/1/12
to google-we...@googlegroups.com
Oh this is exactly my same problem.

I've inherited code that has this same issue (and it is thousands of lines of various widgets). So far folks had hacked around the problem by using JQuery.live() method.

Are you saying that Deepak's code should work if he removed the appendChild calls and instead uses add() as you indicated?

Should it be outerHtmlPanel.add(innerWidget.asWidget())?

Thanks,

-Clint

--
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/-/bthFbBx8xxgJ.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Thomas Broyer

unread,
Feb 2, 2012, 4:58:24 AM2/2/12
to google-we...@googlegroups.com


On Thursday, February 2, 2012 5:30:36 AM UTC+1, Clint wrote:
Are you saying that Deepak's code should work if he removed the appendChild calls and instead uses add() as you indicated?

Yes.

There are really very few cases where you need to call getElement() on a widget. Stay away from it as a rule of thumb, and all will be well.

Deepak Singh

unread,
Feb 2, 2012, 1:07:21 PM2/2/12
to google-we...@googlegroups.com
Thanks a lot Thomas. It works now.

Thanks
Deepak

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
Deepak Singh
Reply all
Reply to author
Forward
0 new messages