Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Dashboard
Groovy
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<h3>Generated Object</h3> <p>An internal class that currently should not be relied on.</p> <h3>Attributes</h3> <ul> <li><strong>source</strong> <Object> The object that triggers the binding update <br class="atl-forced-newline" /></li> </ul> <ul> <li><strong>sourceProperty</strong> <String> A property that is read for the update and whose change triggers the update <br class="atl-forced-newline" /></li> </ul> <ul> <li><strong>sourceEvent</strong> <String> The event name trigger an update</li> <li><strong>sourceValue</strong> <Closure> A closure providing the value when sourceEvent triggers <br class="atl-forced-newline" /></li> </ul> <ul> <li><strong>target</strong> <Object> The object to be updated when a bound value changes</li> <li><strong>targetProperty</strong> <String> The property on the target update to which the queried value will be written <br class="atl-forced-newline" /></li> </ul> <ul> <li><strong>validator</strong> <Closure> If the closure returns null or Boolean.FALSE then a triggered binding will be canceled</li> <li><strong>converter</strong> <Closure> Takes the queried value and converts it to another object to be written to the targetProperty. The queried value is passed in "it" to the closure.</li> </ul> <h3>Content</h3> <p><em>bind</em> accepts no content</p> <h3>Usage</h3> <p><em>bind</em> can be used as a stand alone element or as a value for any attribute of any object.</p> <p>When used as an attribute value the target and targetProperty values implicitly become the current object being constructed and the property being written to.</p> <p>Until the external API is finalized, it is not recommended to use the object returned from <em>bind</em></p> <h3>Examples</h3> <p>Example binding one property to another:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> swing.frame() { panel { textField('Change Me!', id:'tf') button(text: bind(source:tf, sourceProperty:'text')) } } </pre></td></tr></table> <p>Example when triggering on a particular event with a value closure</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> swing.frame() { panel { textField('Change Me!', id:'tf') button(text: bind(source:tf.document, sourceEvent:'undoableEditHappened', sourceValue:{System.currentTimeMillis()})) } } </pre></td></tr></table> <p>Note that the source value can get any arbitrary value.</p> <p>Example with validator and converter:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> swing.frame() { panel { textField('Change Me!', id:'tf') button(text: bind(source:tf, sourceProperty:'text', validator: { tf.text.length() >= 1}, converter: { it.toLowerCase() } )) } } </pre></td></tr></table> <p>In this example the validator prevents the button text from having less than 1 char and the converter makes the button text all lowercase.</p> <p><strong>Note:</strong> Tested on Groovy 1.5.1<br class="atl-forced-newline" /></p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced