Specifying values for builder inputs
In this topic ...
Creating References to Methods
Nesting and Concatenating Indirect References
Combining Indirect Reference Types
Related Topics ...
We can specify values for builder inputs in several ways, such as using the input's select box or text input control. Specifying values using these controls is straightforward.
The designer tool also uses several types of chooser controls for specifying input values. This page describes these types of dialogs used to help you select resources.
Dialogs for choosing input
These dialogs display selectable elements as a tree from which we can choose. For example, the Choose File dialog displays a list of files and/or directories that contains files. Use these dialogs to navigate to the appropriate resource.
The designer tool uses these chooser types:
- Select Action lets you select a method or page as the action to execute for an input. The Select Action dialog in the action list builder also allows you to select special actions.
- Data Page Field Chooser lets you select the form elements whose fields will be formatted, such as fields provided by a date/time formatter builder.
- Choose File lets you select a file, for example in selecting a page to be imported in an imported page builder call.
- Choose Model lets you select a model, for example in selecting a model to be imported in an imported model builder call.
- Choose Reference lets you select a variety of input values. The sections in the rest of this page provide instructions on how to use this dialog.
- Profile Input lets you select a profile.
- Choose Variable or Schema lets you select a schema.
- Choose Class lets you select a fully qualified Java class name. This chooser displays classes from non-factory jars in
/WEB-INF/lib
, as well as from jars and directories contained in the directories specified in thebowstreet.dynamic.class.load.path
property.- Choose Variable Type lets you select a variable type (String, XML, Object, Boolean, Double, Float, Integer, Short, or Long) as a value for the variable builder.
Using the Choose Reference dialog
The Choose Reference dialog allows you to specify the value of a model entity as the value for a builder input. The Choose Reference dialog displays model elements as a tree, allowing you to navigate to the model element whose value you want to supply to the builder input. The syntax that the Choose Reference dialog produces is displayed in the builder input's text box and is called an indirect reference. We can also use indirect reference syntax to specify the value returned by a Java expression as the value for the builder input.
The Choose Reference dialog displays all the variables, methods, inputs, and pages from which we can choose to map the output value of the selected element to the input value for the builder call. For references to XML structures associated with a schema, the Choose Reference dialog displays all the elements as well as any attributes associated with those elements. Attributes are differentiated by an @ symbol preceding their name in the dialog tree.
The Choose Reference dialog does filter out non-valid possibilities. For example, we can set the Label input value for the button builder to be the output of a method, the value of a variable, or the value from an input on the previously submitted page. When you display the Choose Reference dialog for the Label input, it does not show the pages in the model because they are not a valid means of deriving a label for the button.
For more examples of complex indirect references, see Using indirect references.
Creating references to methods
The Choose Reference dialog only shows methods that do not take arguments. When trying to supply an input with a value returned by a method, keep in mind that some builders do not support specifying arguments to a method selected in the Choose Reference dialog. If you want to supply a builder call input with the value returned from a method that takes arguments, add a method call builder call to your model, calling the method and supplying arguments there. Set the input value by using the Choose Reference dialog and selecting the method call that you just created.
Nesting and concatenating indirect references
We can also concatenate indirect references or nest them as needed. For example, if the index of an XML element to use as the value for the builder call input is determined by another variable, the nested indirect reference would be:
${Variables/MyXML/XmlElement[${Variables/IndexValue}]}
To create nested indirect references:
- Use the Choose Reference dialog to populate the input box with the beginning of the indirect reference.
- Place the cursor in the spot at which you want to insert another indirect reference.
- Click
to display the Choose Reference dialog.
- Select the desired model element.
The Choose Reference dialog inserts the new indirect reference at the cursor location.
Using Java expressions
We can also enter Java syntax for the input to a builder. The factory runtime evaluates the Java expression at generation time, and supplies the input to the builder call with the value. We can use a Java expression for indirect references when you want to specify an element in the Web application that the chooser or Builder Call Editor does not directly support. For example, if you wanted to supply the input with the URL to the factory runtime, you could use the following Java expression:
${Java/webAppAccess.getRequestData().getContextURL()}
To set a text input value to the value returned by a method that takes arguments:
${Java/webAppAccess.callMethod("MethodName", arg1, arg2)}
Pre-defined Java expressions
The Java node of the Choose Reference dialog also offers you some pre-defined expressions we can use. To insert an expression you merely select one from the chooser. The following expressions are available:
- HttpServletRequest calls
webAppAccess.getHttpServletRequest()
- HttpServletResponse calls
webAppAccess.getHttpServletResponse()
- HTMLRoot calls
com.bowstreet.BSConfig.getHtmlRootDir()
- Request calls
webAppAccess.getRequestData()
- ServerURL calls
webAppAccess.getRequestData().getServerURL()
- ServletURL calls
webAppAccess.getRequestData().getServletURL()
- StaticContentURL calls
webAppAccess.getURLMapper().getStaticContentURL("","http")
- WEB-INF calls
com.bowstreet.BSConfig.getHomedir()
Once you select an expression from the Choose Reference dialog it is placed in the builder input field. At this point we can edit the expression if we need to add arguments or otherwise modify it.
Add expressions to the Choose Reference dialog
We can add your own expressions to the Java node of the Choose Reference dialog. You might want to do this to keep frequently used expressions available from within the dialog. To populate the Choose Reference dialog with an expression, add a line defining the expression to the
../WEB-INF/config/IndirectJavaExpressions.config
file. For example:To add your own expression that displays at the top level of the Java node tree, you might add the following line to this file:
MyExpressionName=webAppAccess.getMyExpressionData()
To add expressions that display one level down in the expression tree you might enter:
MyExpressionCollection/MyExpressionName1=webAppAccess.getMyExpressionData1()
MyExpressionCollection/MyExpressionName2=webAppAccess.getMyExpressionData2()
Combining indirect reference types
We can use combinations of indirect reference types. For example, you could combine a Java expression and a variable reference to derive the URL for an image:
${Java/webAppAccess.getRequestData().getContextURL()}/${Variables/ImageFileName}
where the
ImageFileName
variable contains the file name of an image.For more information on using indirect references, see
Using indirect references.