使用rpc将表单参数传递给服务实现的步骤是什么? Bassicaly现在我有这些步骤,但我总是为调用时传递的p1(用户名)和p2(用于密码)值为空
userService.createUser(p1,p2,callback):
我的代码:
/**
* Overlay form
*
* @return
*/
public Canvas getViewPanel() {
IButton buttonShowWindow = new IButton("Show Window");
final DynamicForm form = new DynamicForm();
final TextItem emailItem = new TextItem();
final PasswordItem passwordItem = new PasswordItem();
final PasswordItem password2Item = new PasswordItem();
buttonShowWindow.setShowRollOver(true);
buttonShowWindow.setShowDown(true);
buttonShowWindow.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final Window winModal = new Window();
winModal.setWidth(360);
winModal.setHeight(200);
winModal.setTitle("Modal Window");
winModal.setShowMinimizeButton(false);
winModal.setIsModal(true);
winModal.setShowModalMask(true);
winModal.centerInPage();
winModal.addCloseClickHandler(new CloseClickHandler() {
public void onCloseClick(CloseClickEvent event) {
winModal.destroy();
}
});
HLayout layout = new HLayout(20);
form.setWidth(250);
final TextItem usernameItem = new TextItem();
usernameItem.setTitle("Username");
usernameItem.setRequired(true);
emailItem.setTitle("Email");
emailItem.setRequired(true);
passwordItem.setTitle("Password");
passwordItem.setRequired(true);
password2Item.setTitle("Password again");
password2Item.setRequired(true);
password2Item.setType("password");
IButton submit = new IButton();
submit.setTitle("subscribe");
final AsyncCallback callback = new AsyncCallback<String>() {
public void onSuccess(String result) {
// TODO Auto-generated method stub
}
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
};
submit.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// vm.validate();
if (form.hasErrors()) {
// TODO some message to the user
} else {
userService.createUser(usernameItem.getValueField(), passwordItem.getValueField(),callback);
}
}
});
form.setFields(new FormItem[] { usernameItem, emailItem, passwordItem, password2Item });
winModal.addItem(form);
winModal.addItem(submit);
winModal.show();
}
});
HStack layoutTopRow = new HStack(10);
layoutTopRow.setHeight(50);
VLayout layoutMain = new VLayout();
layoutMain.addMember(layoutTopRow);
layoutMain.addMember(buttonShowWindow);
return layoutMain;
}
由于
答案 0 :(得分:0)
使用
userService.createUser(usernameItem.getValue(), passwordItem.getValue(),callback);
而不是
userService.createUser(usernameItem.getValueField(), passwordItem.getValueField(),callback);
有关FormItem.getValueField()的更多信息,请阅读