All,
This is in all likelihood a newb question, but I'm having trouble with
events on nested composites created using the uibinder.
The code and templates below produce the simple DOM structure shown
here. Neigher a UiHander nor adding click handers to the first anchor
receive click events. The second anchor works just fine.
Please take a look and see if anything jumps out. Thanks!
- Michael
** DOM result
<div>
<h2>List Group</h2>
<ul>
<div>
<li> ## THIS ANCHOR DOES NOT RECEIVE EVENTS ??
<a tabindex="0" class="gwt-Anchor">
<div>View Item</div>
</a>
</li>
</div>
<li> ## THIS ANCHOR RECEIVES EVENTS
<a tabindex="0" class="gwt-Anchor">
<div>View All</div>
</a>
</li>
</ul>
</div>
** GroupItem.ui.xml
<ui:UiBinder
xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<g:HTMLPanel>
<li>
<g:Anchor ui:field='anchorItem'>
<div>View Item</div>
</g:Anchor>
</li>
</g:HTMLPanel>
</ui:UiBinder>
** GroupItem.java
class GroupItem extends Composite {
@UiTemplate("GroupItem.ui.xml")
interface Binder extends UiBinder<Widget, GroupItem> {}
private static final Binder binder = GWT.create(Binder.class);
@UiField Anchor anchorItem;
public GroupItem()
{
initWidget(binder.createAndBindUi(this));
}
@UiHandler("anchorItem")
void onAnchorClick( ClickEvent event )
{
Window.alert( "Clicked" );
System.out.println( "clicked" );
}
}
** Group.ui.xml
<ui:UiBinder
xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<g:HTMLPanel>
<h2 ui:field='title'>Untitled</h2>
<ul ui:field='list'>
<li ui:field='moreItem'>
<g:Anchor ui:field='moreLink'>
<div>View All</div>
</g:Anchor>
</li>
</ul>
</g:HTMLPanel>
</ui:UiBinder>
** Group.java
class Group extends Composite {
@UiTemplate("Group.ui.xml")
interface Binder extends UiBinder<Widget, Group> { }
private static final Binder binder = GWT.create(Binder.class);
@UiField Element title;
@UiField UListElement list;
@UiField Element moreItem;
public Group() {
initWidget(binder.createAndBindUi(this));
}
public void setTitle( String inTitle )
{
title.setInnerText( inTitle );
}
public void addItem( GroupItem inItem )
{
list.insertBefore(inItem.getElement(), moreItem );
}
@UiHandler("moreLink")
void onAnchorClick( ClickEvent event )
{
Window.alert( "Clicked" );
System.out.println( "clicked" );
}
--
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.