#field
This object is available only within the parameter information of the FS_BUTTON definitions in forms. |
The #field object can be used in conjunction with FS_BUTTON instances in forms to obtain content from and information about input components within the form and to process it within scripts, for instance.
#field in this case is used in the XML form within the <PARAMS/> block of an FS_BUTTON definition.
Using this system object, a single input component is called using its variable name (name attribute in the XML definition form of the component):
#field.st_headline
This call returns the input component called “st_headline” as a FormField type object; using the methods of the object, properties and content of the current element's input component can then be read out.
Example
In this example the #field system object is used to pass the “st_headline” input component to the “clickhandlerscript” script and to use some properties of the component within this script.
<!-- Template form definition -->
<CMS_MODULE>
<!-- Define a text box with name "st_headline" -->
<CMS_INPUT_TEXT name="st_headline" >
<LANGINFOS>
<LANGINFO lang="*" label="Headline" />
</LANGINFOS>
</CMS_INPUT_TEXT>
<FS_BUTTON name="st_button" onClick="script:clickhandlerscript">
<LANGINFOS>
<LANGINFO lang="*" label="Button" />
</LANGINFOS>
<PARAMS>
<!-- Pass the component named "st_headline" as a parameter -->
<PARAM name="form_headline">#field.st_headline</PARAM>
</PARAMS>
</FS_BUTTON>
</CMS_MODULE>
This example defines a text input component called “st_headline”. Within the <PARAMS/> block of the FS_BUTTON definition, this input component is passed as a parameter called form_headline using the #field object.
If the button script is executed, this input component is passed to the script as the form_headline variable, and current attributes and content of the input component can be further processed in the script:
// Script clickhandlerscript
operationAgent = context.requireSpecialist(de.espirit.firstspirit.agency.OperationAgent.TYPE);
requestOperation = operationAgent.getOperation(de.espirit.firstspirit.ui.operations.RequestOperation.TYPE);
if (form_headline != null) {
requestOperation.perform(
"Information about component: " + form_headline.getName() +
", current value: " + form_headline.get() +
", is this a default? " + form_headline.isDefault()
);
}
If an input component is passed to a script or a Java class using the #field system object, this is provided using the parameter name (name attribute of the <PARAM/> tag) - in the case of scripts, directly as a variable, and in the case of executable classes, via the Map<String, String> object, which is passed to the execute() methods.
Each input component object is of the de.espirit.firstspirit.forms.FormField