smartGWT 复制按钮
smartGWT duplicate buttons
我有 2 个包含保存和取消按钮的 smartGWT 按钮布局。为方便起见,一个在 UI 的顶部,一个在底部,因此用户不必一直滚动 up/down 到 save/cancel 一个表单。
当用户在任一位置选择 save/cancel 时,所有按钮都应禁用,直到后台操作完成。
处理此问题的最佳方法是什么?
如果我这样做:
private Layout buildTopButtonBar() {
saveButton = new Button("Save");
saveButton.addClickHandler( ... );
buttonLayout.addMember(saveButton);
}
private Layout buildBottomButtonBar() {
saveButton = new Button("Save");
saveButton.addClickHandler( ... );
buttonLayout.addMember(saveButton);
}
我的 clickHandler 中的保存按钮操作(当用户选择保存时,保存按钮应该被禁用)仅针对底部栏中的按钮执行,尽管所有其他后台操作都有效。
如果我这样做:
saveButton = new Button("Save");
saveButton.addClickHandler( ... );
buildTopButtonBar(); // adds saveButton to top bar
buildBottomButtonBar(); // adds saveButton to bottom bar
只显示底栏。
我可以创建 4 个单独的按钮:
topSaveButton = new Button("Save");
bottomSaveButton = new Button("Save");
... // add all required functionality and clickHandlers
但这感觉很糟糕。
我还有其他选择吗?
这是 smartGWT 4.
您不能重复使用小部件的实例。
Button saveButton = new Button("Save");
// some more code
saveButton.addClickHandler( ... );
buildTopButtonBar(); // adds saveButton to top bar
buildBottomButtonBar(); // adds saveButton to bottom bar
;
将不起作用。
Button topSaveButton = new Button("Save");
Button bottomSaveButton = new Button("Save");
... // add all required functionality and clickHandlers
会起作用。
每个小部件代表 DOM 树中的一个节点。您可以通过调用 getElement()
来访问该节点。再次添加按钮将删除顶部的按钮并将其添加到底部。
如果顶部和末尾都有一个保存按钮,则需要两个实例。
我有 2 个包含保存和取消按钮的 smartGWT 按钮布局。为方便起见,一个在 UI 的顶部,一个在底部,因此用户不必一直滚动 up/down 到 save/cancel 一个表单。
当用户在任一位置选择 save/cancel 时,所有按钮都应禁用,直到后台操作完成。
处理此问题的最佳方法是什么?
如果我这样做:
private Layout buildTopButtonBar() {
saveButton = new Button("Save");
saveButton.addClickHandler( ... );
buttonLayout.addMember(saveButton);
}
private Layout buildBottomButtonBar() {
saveButton = new Button("Save");
saveButton.addClickHandler( ... );
buttonLayout.addMember(saveButton);
}
我的 clickHandler 中的保存按钮操作(当用户选择保存时,保存按钮应该被禁用)仅针对底部栏中的按钮执行,尽管所有其他后台操作都有效。
如果我这样做:
saveButton = new Button("Save");
saveButton.addClickHandler( ... );
buildTopButtonBar(); // adds saveButton to top bar
buildBottomButtonBar(); // adds saveButton to bottom bar
只显示底栏。
我可以创建 4 个单独的按钮:
topSaveButton = new Button("Save");
bottomSaveButton = new Button("Save");
... // add all required functionality and clickHandlers
但这感觉很糟糕。 我还有其他选择吗? 这是 smartGWT 4.
您不能重复使用小部件的实例。
Button saveButton = new Button("Save");
// some more code
saveButton.addClickHandler( ... );
buildTopButtonBar(); // adds saveButton to top bar
buildBottomButtonBar(); // adds saveButton to bottom bar
;
将不起作用。
Button topSaveButton = new Button("Save");
Button bottomSaveButton = new Button("Save");
... // add all required functionality and clickHandlers
会起作用。
每个小部件代表 DOM 树中的一个节点。您可以通过调用 getElement()
来访问该节点。再次添加按钮将删除顶部的按钮并将其添加到底部。
如果顶部和末尾都有一个保存按钮,则需要两个实例。