Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
6 replies Latest Post - ‏2014-04-14T17:02:06Z by george.baker
SystemAdmin
SystemAdmin
1192 Posts
ACCEPTED ANSWER

Pinned topic setting properties in Extending the Entry portlet (i retry)

‏2012-09-12T21:45:56Z |
Hi all

Premised that I know very little java, I’m tryng to follow the instruction at this page http://publib.boulder.ibm.com/infocenter/hatshelp/v80/index.jsp?topic=%2Fcom.ibm.hats.doc%2Fdoc%2Fpgportal.htm “Extending the Entry portlet”; I have written the following java class: but I don’t understand how can I provide the parameter connection. Particularly I would like to provide in the workstationID a my value so when Hats run the iSeries Job, use as device name the value that I forced. The source java class is the following but I don’t understand how to “Override the getInitParameters() method” as my code it seems not to run/work, because in my console I don’t se the message “=== initParams ====”.
Could you please tell me how run the getInitParameters() ? Could you please tell me how can move a my value in the “workstationID” parameter , so Hats use it as device name in iSeries Job ?
Thanks in advance
package myP;
import java.io.IOException;
import java.util.Properties;
import java.util.*;
import javax.servlet.ServletContext;
import org.apache.jetspeed.portlet.PortletConfig;
import org.apache.jetspeed.portlet.PortletException;
import org.apache.jetspeed.portlet.PortletRequest;
import org.apache.jetspeed.portlet.PortletResponse;
import org.apache.jetspeed.portlet.UnavailableException;
import com.ibm.hats.runtime.EntryPortlet;
import com.ibm.hats.runtime.IContext;
import com.ibm.hats.runtime.IRequest;
import com.ibm.hats.runtime.IRequestDispatcher;
import com.ibm.websphere.validation.base.config.level51.requestmetricsvalidation_51_NLS;
import com.ibm.ws.webservices.xml.wassysapp.systemApp;
public class Ws_is extends EntryPortlet {
@Override
public void doView(PortletRequest arg0, PortletResponse arg1)
throws PortletException, IOException {
String PublicIP = arg0.getRemoteAddr();
+System.out.println("=====> My Ip Adr " + PublicIP );+
super.doView(arg0, arg1);
}
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");

System.out.println("====>> initParams <===== " );

return initParams;
}

}
Updated on 2012-10-02T21:16:19Z at 2012-10-02T21:16:19Z by tmparker
  • SystemAdmin
    SystemAdmin
    1192 Posts
    ACCEPTED ANSWER

    Re: setting properties in Extending the Entry portlet (i retry)

    ‏2012-09-25T16:33:44Z  in response to SystemAdmin
    Hi all

    any idea how to solve my problem ?? pheraps Tim Parker ??!!

    Thanks all
    • tmparker
      tmparker
      518 Posts
      ACCEPTED ANSWER

      Re: setting properties in Extending the Entry portlet (i retry)

      ‏2012-09-26T13:20:00Z  in response to SystemAdmin
      The getInitParameters method is called automatically by HATS when the servlet is run. All you need to do is follow the instructions for setting you entry portlet to be used in the web.xml. To set the workstation id you would simply add a line of code like this:
      
      
      
      public Properties getInitParameters(IRequest request) 
      { Properties initParams = 
      
      new Properties(); initParams.setProperty(
      "workstationID", 
      "testID"); 
      
      return initParams; 
      }
      


      Also, you need to make sure you follow the directions for enabling connection parameter overrides in a project. Read the section entitled "Connection parameter overrides" here to enable this for your project, http://publib.boulder.ibm.com/infocenter/hatshelp/v80/topic/com.ibm.hats.doc/doc/ugprject.htm.

      That's all there is to it.

      Thanks
      Tim
      • SystemAdmin
        SystemAdmin
        1192 Posts
        ACCEPTED ANSWER

        Re: setting properties in Extending the Entry portlet (i retry)

        ‏2012-09-28T07:08:36Z  in response to tmparker
        Hi Tim, thank you for your reply.

        Pheraph I have not well explained my problem, I retry here:
        1 - i have created a new class file in this way :
        Click File > New > Java > Class file. Your new class must extend com.ibm.hats.runtime.EntryPortlet.

        2- i have executed the "Extending the Entry portlet" in this way :
        Opened the web.xml file and replaced "com.ibm.hats.runtime.EntryPortlet" at the line <servlet- class>com.ibm.hats.runtime.EntryPortlet</servlet-class> with my class created in step 1

        3- After that if i run my project, my class came executed, as i can see in the console the string "System.out.println("=====> My Ip Adr " + PublicIP "

        4- The problem is that in the console i DO NOT see the string "====>> initParams <===== " that came printed in the console when run the getInitParameters method.
        So my doubt/question is why the getInitParameters method is not called ? where i'm wrong ?

        Thanks in advance

        P.S. see above (im my first post) the source of my java class
        • SystemAdmin
          SystemAdmin
          1192 Posts
          ACCEPTED ANSWER

          Re: setting properties in Extending the Entry portlet (i retry)

          ‏2012-10-02T21:04:53Z  in response to SystemAdmin
          Hi Tim

          Did you have the opportunity to read my previous post of Sept 28 ? what do you think ?
          i would be you gratefull if you could help me to understand to where i'm wrong

          Thanks
          • tmparker
            tmparker
            518 Posts
            ACCEPTED ANSWER

            Re: setting properties in Extending the Entry portlet (i retry)

            ‏2012-10-02T21:16:19Z  in response to SystemAdmin
            Looking at your code I am a little confused what you did. It looks like you extended the EntryPortlet class; however, if you read the documentation I pasted below it says you need to extend either the Jsr168EntryPortlet or Jsr286EntryPortlet class.


            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.
            • george.baker
              george.baker
              314 Posts
              ACCEPTED ANSWER

              Re: setting properties in Extending the Entry portlet (i retry)

              ‏2014-04-14T17:02:06Z  in response to tmparker

              I followed your instructions  and created the following class:

              package lSOPortlet.businessLogic;

              import java.util.Properties;

              import com.ibm.hats.portlet.Jsr286EntryPortlet;

              import com.ibm.hats.runtime.IRequest;

              public class Overrides extends Jsr286EntryPortlet {

              public Properties getInitParameters(IRequest request)

              Properties initParams = new Properties();

                  initParams.setProperty("workstationID", "TX====");

              return initParams;

              }

              }

              I also modified the portlet.xml as you indicated in the above post.  

              Good news:  The override of the workstationID works

              Bad news: The WEL macro fails and prompts the user.  

              I thought that EXTENDING the EntryPortlet would allow BOTH of the functions to work.  

              How do I resolve this conflict?

              I'm working with HATS 9.0 and Portal 8.0.