For this purpose, ADF provides EL functions which support both positional and named parameters.
- af:formatString : for formatting a string with a positional parameter.
- af:formatString2 : for formatting a string with two positional parameters.
- af:formatString3 : for formatting a string with three positional parameters.
- af:formatString4 : for formatting a string with four positional parameters.
- af:formatNamed : for formatting a string with a named parameter.
- af:formatNamed2 : formatting a string with two named parameters.
- af:formatNamed3 : for formatting a string with three named parameters.
- af:formatNamed4 : for formatting a string with four named parameters.
If we use named parameters in our resource bundles:
SCAN_DURATION_VALUE={HOURS} hours, {MINS} minutes
We can use the formatNamed functions:
<af:outputText value="#{af:formatNamed2(myBundle.SCAN_DURATION_VALUE, 'HOURS', varHours, 'MINS', varMins)}"/>
If we use positional parameters instead:
TASK_CURRENT_STEP=Currently executing step {0} of {1}
Then we can use the formatString functions:
<af:outputText value="#{af:format2(myBundle.TASK_CURRENT_STEP, var1, var2)}"/>
In alternative, we can use the JSF outputformat component, which uses a positional approach:
<h:outputFormat value="#{myBundle.TASK_CURRENT_STEP}" id="of2"> <f:param value="#{pageFlowScope.var1}" id="p1"/> <f:param value="#{pageFlowScope.var2}" id="p3"/> </h:outputFormat>
No comments:
Post a Comment