Adding default help provider to ADF application
Please read about HelpProvider documentation from ADF Docs. Now you can go and implement your default help provider in ADF App.
Whenever there is requirement to override default behavior of the help topic text and basically want to override behavior to accept any random help text from ELExpressions. Here we need to override some classes and make few configuration entries in adf-settings.xml file.
1. Extend HelpTopic class and override methods. Code should look something like below.
1 package com.custom;
2
3 import javax.faces.component.UIComponent;
4 import javax.faces.context.FacesContext;
5
6
7 import com.custom.HelpTopic;
8
9 /**
10 * EPM help provider for help topic ids.
11 */
12 public class DefaultELHelpProvider extends HelpProvider {
13 /**
14 * Default constructor.
15 */
16 public EPMELHelpProvider() {
17 super();
18 }
19
20
21 /**
22 * Resolves help topic Ids.
23 * @param facesContext faces context.
24 * @param uIComponent ui component.
25 * @param string help topic Id key.
26 * @return Help Topic ID.
27 */
28 @Override
29 public HelpTopic getHelpTopic(FacesContext facesContext, UIComponent uIComponent, String string) {
30 return DefaultHelpTopic.getEPMHelpTopic(string);
31 }
32 }
2. Extend HelpProvider class and it should look something like below.
1 package com.custom;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 import oracle.adf.view.rich.help.HelpTopic;
7
8 /**
9 * Custom Help Topic ids.
10 */
11 public class DefaultHelpTopic extends HelpTopic{
12
13 Map<String, String> helpTopicMap = new HashMap<String, String>();
14
15 private static final String _DEFINITIONS = "_DEFINITIONS";
16 /**
17 * Default Constructor.
18 */
19 public DefaultHelpTopic() {
20 super();
21 }
22
23
24 /**
25 * Help topic definitions.
26 * @param definitions definition text.
27 * @return Custom Help Topic Id.
28 */
29 protected static DefaultHelpTopic getDefaultHelpTopic(String definitions) {
30 DefaultHelpTopic helpTopic = new DefaultHelpTopic();
31 helpTopic.helpTopicMap.put(_DEFINITIONS, definitions);
32 return helpTopic;
33 }
34
35 /**
36 * Help topic definitions.
37 * @return help text.
38 */
39 public String getDefinition() {
40 return helpTopicMap.get(_DEFINITIONS);
41 }
42
43 /**
44 * Help topic instructions.
45 * @return Help topic instructions.
46 */
47 public String getInstructions() {
48 return null;
49 }
50
51 /**
52 * Help topic external URL.
53 * @return external URL.
54 */
55 public String getExternalUrl() {
56 return null;
57 }
58 }
3. Make entry of classes created in adf-settings.xml as below. This will override default help provider. Now, help text will display any other text apart from HelpTopic.xlf file or which do not have prefix HELP_.
<?xml version="1.0" encoding="UTF-8" ?>
<adf-settings xmlns="http://xmlns.oracle.com/adf/settings">
<adf-faces-config xmlns="http://xmlns.oracle.com/adf/faces/settings">
<help-provider prefix="HELP_">
<help-provider-class>
oracle.adf.view.rich.help.ELHelpProvider
</help-provider-class>
<property>
<property-name>helpSrc</property-name>
<value>#{adfBundle['HelpTopic']}</value>
</property>
</help-provider>
<help-provider>
<help-provider-class>com.company.custom.EPMELHelpProvider</help-provider-class>
</help-provider>
</adf-faces-config>
</adf-settings>
4. Last but not least UI code
<af:inputText label="My Accounts List : " id="fpdft"
helpTopicId="#{myBean.defaultHelp}"/>
This My account List will display whatever random text resolved from ELExpression.
Hope this helps. Appreciate any suggestions.
Comments
Post a Comment