Hi,
i asked this question on stackoverflow, but i had no luck so far. So i thought i might try here.
I have a dialog box where i try to integrate an ListItemEditor and a LeafValueEditor. I try to integrate something like this example into my project.
In my dialog box, the GroupListEditor is linked like this:
<my:GroupListEditor ui:field="groupListEditor" />This works fine so far. The "Add" button is displayed correctly. But then nothing happens. What do i miss?
My Editors look like this:
This is the parent editor in a Popup Dialog:
public class ContainerEditorDialogPresenterWidget extends PresenterWidget<ContainerEditorDialogPresenterWidget.MyView> implements
ContainerEditorDialogUiHandlers {
@Inject
ContainerEditorDialogPresenterWidget(EventBus eventBus,
MyView view) {
super(eventBus, view);
getView().setUiHandlers(this);
this.eventBus = eventBus;
}
/**
* {@link LocalDialogPresenterWidget}'s PopupView.
*/
public interface MyView extends PopupView, ContainerEditView<ContainerDto>, HasUiHandlers<ContainerEditorDialogUiHandlers> {
}
private ContainerDto currentContainerDTO = null;
private final EventBus eventBus;
private SimpleBeanEditorDriver<ContainerDto, ?> driver;
public ContainerDto getCurrentContainerDTO() {
return currentContainerDTO;
}
public void setCurrentContainerDTO(ContainerDto currentContainerDTO) {
this.currentContainerDTO = currentContainerDTO;
}
@Override
public void onReveal() {
super.onReveal();
driver.edit(currentContainerDTO); // this will populate your view with the data from your POJO
}
@Override
protected void onBind() {
super.onBind();
driver = getView().createEditorDriver();
}
@Override
public void updateContainer() {
ContainerDto dev = driver.flush();
eventBus.fireEvent(new ContainerUpdatedEvent(dev));
}
}
This is my ListEditor:
public class GroupListEditor extends Composite implements
IsEditor<ListEditor<String, GroupItemEditor>> {
private static StringListEditorUiBinder uiBinder = GWT
.create(StringListEditorUiBinder.class);
interface StringListEditorUiBinder extends
UiBinder<Widget, GroupListEditor> {
}
@UiField
FlowPanel pWidget;
@UiField
PushButton bAdd;
@UiField
FlowPanel pList;
private class StringItemEditorSource extends EditorSource<GroupItemEditor> {
@Override
public GroupItemEditor create(final int index) {
GroupItemEditor subEditor = new GroupItemEditor();
pList.insert(subEditor, index);
subEditor
.addDeleteHandler(new EditorDeleteEvent.EditorDeleteHandler() {
public void onEditorDeleteEvent(EditorDeleteEvent event) {
remove(index);
}
});
return subEditor;
}
@Override
public void dispose(GroupItemEditor subEditor) {
subEditor.removeFromParent();
}
@Override
public void setIndex(GroupItemEditor editor, int index) {
pList.insert(editor, index);
}
}
private ListEditor<String, GroupItemEditor> editor = ListEditor
.of(new StringItemEditorSource());
public GroupListEditor() {
initWidget(uiBinder.createAndBindUi(this));
}
@UiHandler("bAdd")
void onBAddClick(ClickEvent event) {
Log.debug("Add button clicked");
add();
}
private void add() {
String s = "";
editor.getList().add(s);
}
@Override
public ListEditor<String, GroupItemEditor> asEditor() {
return editor;
}
private void remove(final int index) {
editor.getList().remove(index);
}
And its ui.xml:
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:FlowPanel ui:field="pWidget">
<g:HorizontalPanel>
<g:PushButton text="Add" ui:field="bAdd"/>
<g:Cell verticalAlignment="ALIGN_MIDDLE">
<g:HTML wordWrap="true"> Todos</g:HTML>
</g:Cell>
</g:HorizontalPanel>
<g:FlowPanel ui:field="pList"/>
</g:FlowPanel>
</ui:UiBinder>
And its LeafValueEditor:
public class GroupItemEditor extends Composite implements LeafValueEditor<String> {
interface StringItemEditorUiBinder extends UiBinder<Widget, GroupItemEditor> {}
private static StringItemEditorUiBinder uiBinder = GWT.create(StringItemEditorUiBinder.class);
@UiField
TextBox tbvalue;
@UiField
PushButton bDelete;
public GroupItemEditor() {
initWidget(uiBinder.createAndBindUi(this));
}
@UiHandler("bDelete")
void onBDeleteClick(ClickEvent event) {
fireDeleteEvent();
}
private void fireDeleteEvent() {
//fireEvent(new EditorDeleteEvent());
}
public final HandlerRegistration addDeleteHandler(EditorDeleteEvent.EditorDeleteHandler handler) {
return addHandler(handler, EditorDeleteEvent.TYPE);
}
@Override
public void setValue(String value) {
tbvalue.setValue(value);
}
@Override
public String getValue() {
return tbvalue.getValue().trim();
}
}
And the corresponding ui.xml:
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:p1="urn:import:com.google.gwt.editor.ui.client">
<ui:style>
.important {
font-weight: bold;
}
</ui:style>
<g:FlowPanel>
<g:HorizontalPanel>
<g:TextBox ui:field="tbvalue"/>
<g:HTML wordWrap="true"> </g:HTML>
<g:Cell verticalAlignment="ALIGN_MIDDLE">
<g:PushButton text="X" ui:field="bDelete"/>
</g:Cell>
</g:HorizontalPanel>
</g:FlowPanel>
</ui:UiBinder>
Thanks :)
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/d/optout.
No comments:
Post a Comment