Extending the Entry portlet
You can extend the HATS standard portlet to provide additional functions or to customize the portlet. For example, you can extend the portlet to provide connection parameter and global variable overrides.
To extend the standard Entry portlet you must
customize the Java™ class file. The following steps are for extending the JSR 168 class
file (com.ibm.hats.portlet.Jsr168EntryPortlet). The same steps can
be performed to extend the JSR 286 class file (com.ibm.hats.portlet.Jsr286EntryPortlet).
- Use the new Java™ Class wizard
to create the new Java™ class
that extends com.ibm.hats.portlet.Jsr168EntryPortlet.
- Click File > New > Java > Class file.
- Provide the package and the name of the new class. Make sure the Superclass field contains the value
com.ibm.hats.portlet.Jsr168EntryPortlet.
- Modify the name of the portlet class in the portlet deployment
descriptor.
- Open the portlet.xml file in the Portlet deployment descriptor editor.
- Replace the text in the <portlet-class>
com.ibm.hats.portlet.Jsr168EntryPortlet</portlet-class> with the following: <portlet-class>myPackage.myClass</portlet-class>; where myPackage and myClass are values you entered in the new Java™ Class wizard above.
The following example shows how to provide connection
parameter and global variable overrides with the extended portlet
class:
- Edit the Java™ source file of the extended portlet class.
- Override the getInitParameters() method as follows:
public Properties getInitParameters(IRequest request) { Properties initParams = new Properties(); initParams.setProperty(com.ibm.eNetwork.beans.HOD.Session.HOST, "129.12.11.2"); initParams.setProperty(com.ibm.eNetwork.beans.HOD.Session.PORT, "623"); initParams.setProperty("hatsgv_userName", "some user"); initParams.setProperty("hatsgv_password", "xxxxx"); initParams.setProperty("hatssharedgv_someVariable", "zzzzz"); return initParams; }
Note:
If you set the connection
parameter or global variable overrides through the extended portlet
class and use the same overrides in Edit mode, the Edit mode settings
override the settings in the extended portlet class.
You must also configure the project's security settings to allow overrides of your chosen connection parameters or global variables. To do this, use the Connection Parameter Overrides panel and the Global Variable Overrides panel in the Project Settings>Other tab. If you do not allow overrides in the security panels, then any overrides set by extending the portlet class or by using the portlet Edit mode are implicitly ignored.