这并不完全正确,您可以向应用程序添加隐藏元素。只需通过使用 createHidden 而不是 createTextBox 来采用下面的 axmaple。
function doGet() {
var app = UiApp.createApplication();
var textBox1 = app.createTextBox().setName("textBox1");
var textBox2 = app.createTextBox().setId("textBox2");
app.add(textBox1);
app.add(textBox2);
var textBox3 = app.createTextBox().setName("textBox3");
var panel = app.createFlowPanel();
panel.add(textBox3);
app.add(panel);
var button = app.createButton("a button");
var handler = app.createServerHandler("handlerFunction");
handler.addCallbackElement(textBox1)
.addCallbackElement(textBox2)
.addCallbackElement(panel)
button.addClickHandler(handler);
app.add(button);
return app;
}
function handlerFunction(eventInfo) {
var parameter = eventInfo.parameter;
// There's a lot of information in 'parameter' about the event too, but we'll focus here
// only on the callback elements.
var textBox1 = parameter.textBox1; // the value of textBox1
var textBox2 = parameter.textBox2; // undefined! setId is not the same as setName
var textBox3 = parameter.textBox3; // works! the parent "panel" was a callback element
}
来源:https ://developers.google.com/apps-script/class_serverhandler#addCallbackElement