问题
We have data that is fairly static, and we load that data into an XPage for attributes or label names or combo/radio/pull-down dataValues.
Using Resource Files in the Resources section is fast and simple EL syntax.
But how to dynamically update the data in the Resource File became the challenge. This is how we gotter' done:
First, accessing a Resource File containing manually pasted key=value,[n]; paired-data, just to prove we can; we did like this:
<xp:this.resources>
<xp:bundle src="/dojoPivotData.properties" var="dojoPivotProperties"></xp:bundle>
</xp:this.resources>
The data in the 'dojoPivotProperties.properties' file looks like this:
Passing the variable name var="dojoPivotProperites"
into a Custom Property of a CustomControl is done by changing the Type:
of the Property Definition of the property by Pasting java.util.PropertyResourceBundle
into the Type: property, like so:
And passing in the Resource var
variable name to the Custom Property where the Custom Control in embedded looks like this:
How I used values from the Custom Property, defined in the Custom Control:
How is used the .properties
file to find keys to get their values to use in repeat controls by doing computations on the value of the passed in .property
file in a DataContext
:
To get the Finále where the data is driving the design elements that get generated in the UI:
**
- Special Note
**
The voyages associated with each Destination cell above is generated at load by using the same java.util.ResourceBundle
.property file to grab each Destination keyName from the .properties
file. Each keyName in the .properties
file has a list of voyages associated with that keyName like so:
And those voyages associated with Africa
are generated into an attribute-list for "Africa" square like this:
To get this HTML result in the browser:
Question: How do we load the keyName=Value pairs into the Resource File on the Fly?
Ans: See* "Dynamic .property Resources File on the Fly" I will show how I did it in a post by that title
来源:https://stackoverflow.com/questions/48591870/using-properties-resource-file-resourcebundle-in-an-xpage