Resourced Text Builder Sample
This sample builder lets you apply text from a resource bundle to any number of page locations in a model. This can let you use a single Resourced Text builder in place of a potentially large number of Text builders. The Resourced Text builder looks through all the pages in a model and finds elements with “name” attributes that match identifiers in the properties file, and for each one it then automatically invokes the Text builder.
In the attached sample, the ResourcedText1 model uses seven Text builders to apply text from the resource bundle Variable. In the ResourcedText2 model, a single Resourced Text builder takes the place of all of those Text builders.
Here is one of the pages of the running application, where the circled text items are set by the builder.
The screenshot below shows the builder inputs. The option for “Use Runtime References” determines whether the resource text is applied directly to the page during the regeneration process or if a runtime reference to the resource bundle variable is used. The runtime reference option must be used in cases where the resource bundle language may change during a single user session.
Here are the files contained in the sample package:
• ResourcedTextBuilder.bdef – the BuilderDef for the custom builder.
• ResourcedTextBuilder.java – the Java regeneration class for the builder.
• ResourcedText1.model – the sample model implemented using Text builders (without the custom builder).
• ResourcedText2.model – the sample model that uses the Resourced Text builder.
• ResourcedTextProvider.model – the simple service provider model used in the sample.
• ResourcedTextLayout1.html, ResourcedTextLayout2.html – the two HTML files that define the layout for the two pages in the model.
• resourced_text.properties – the resource bundle file containing the text for this sample.
Note that the two HTML pages are brought into the model using Imported Page, using the Overwriting option for “Replace Existing Page”. This is a new builder option introduced in WEF 8.0 which is required in order to run this sample. The custom builder itself can be used on earlier versions of WEF.