-
Notifications
You must be signed in to change notification settings - Fork 18
rad var
Attribute that can be added to any component in a RAD view, which adds a reference to the component as a member variable on the view. This is an easy way to access the component from Java expressions in the page. E.g. inside <script>
tags, and attributes with Java expressions.
<someComponent rad-var="[+|-]varName" …/>
The varName can be optionally prefixed with -
or +
to make the variable either public or private. Default scope is package private.
Consider the following:
<textField rad-var="usernameField"/>
This would result in the following member variable being defined in the view’s class:
TextField usernameField;
And this would be set to a reference to the given <textField>
when it is created.
You could then access the text field from within a script tag on the page:
<script><![CDATA[
usernameField.addActionListener(evt->{
System.out.println("Username is "+usernameField.getText());
});
]]></script>
To make the variable private, just prefix the var name with -
. E.g.
<textField rad-var="-usernameField"/>
This would result in the following member variable being defined in the view’s class:
private TextField usernameField;