Google Apps Script

Class Hidden

Represents a hidden field for storing data in the user's browser that can be passed back to a handler as a "callback element".

Here is an example of how to use this widget:

 
function doGet() {
   var app = UiApp.createApplication();
   // Note that the name "appState" for callbacks, and the id "hidden" for
   // getting a reference to the widget, are not required to be the same.
   var hidden = app.createHidden("appState", "0").setId("hidden");
   app.add(hidden);
   var handler = app.createServerHandler("click").addCallbackElement(hidden);
   app.add(app.createButton("click me!", handler));
   app.add(app.createLabel("clicked 0 times").setId("label"));
   return app;
 }

 function click(eventInfo) {
   var app = UiApp.createApplication();
   // We have the value of the hidden field because it was a callback element.
   var numClicks = Number(eventInfo.parameter.appState);
   numClicks++;
   // Just store the number as a string. We could actually store arbitrarily complex data
   // here using JSON.stringify() to turn a JavaScript object into a string to store, and
   // JSON.parse() to turn the string back into an object.
   app.getElementById("hidden").setValue(String(numClicks));
   app.getElementById("label").setText("clicked " + numClicks + " times");
   return app;
 }
 

Internally, UiApp widgets are built on top of the Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation directly. You can find the Hidden documentation here.

Methods

MethodReturn typeBrief description
getId()StringReturns the id that has been assigned to this object.
getTag()StringGets the text tag of this Hidden.
getType()StringGets the type of this object.
setId(id)HiddenSets the id of this Hidden.
setName(name)HiddenSets the name of the Hidden, which is how it will be referred to when used in a FormPanel or as a callback element on an event handler.
setStyleAttributes(attributes)HiddenSets this Hidden's style attributes.
setTag(tag)HiddenSets the text tag of this Hidden.
setValue(value)HiddenSets the value of this Hidden.

Detailed documentation

getId()

Returns the id that has been assigned to this object.

This can be used in conjunction with app.getElementById() to retrieve a reference to this object.

Return

String — the id that has been assigned to this object


getTag()

Gets the text tag of this Hidden.

Return

String — the text tag.


getType()

Gets the type of this object.

Return

String — the object type


setId(id)

Sets the id of this Hidden.

Parameters

NameTypeDescription
idStringthe new id, which can be used to retrieve the Hidden from app.getElementById(id).

Return

Hidden — the Hidden itself, useful for chaining.


setName(name)

Sets the name of the Hidden, which is how it will be referred to when used in a FormPanel or as a callback element on an event handler.

Parameters

NameTypeDescription
nameStringthe new name.

Return

Hidden — the Hidden itself, useful for chaining.


setStyleAttributes(attributes)

Sets this Hidden's style attributes. This is a convenience method that is equivalent to calling setStyleAttribute with every key/value pair in the attributes object. Valid attributes are listed here; the values for each attribute are the same as those available in CSS style sheets.

 
// Change the widget's background to black and text color to green.
 widget.setStyleAttributes({background: "black", color: "green"});
 

Parameters

NameTypeDescription
attributesObjectan object of key/value pairs for the CSS attributes and values to set; valid attributes are listed here

Return

Hidden — the Hidden itself, useful for chaining.


setTag(tag)

Sets the text tag of this Hidden.

Parameters

NameTypeDescription
tagStringthe new text tag, which can be anything you wish to store with the widget.

Return

Hidden — the Hidden itself, useful for chaining.


setValue(value)

Sets the value of this Hidden.

Parameters

NameTypeDescription
valueStringthe new value.

Return

Hidden — the Hidden itself, useful for chaining.

Deprecated methods














Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.