5 Replies Latest reply on Aug 14, 2006 4:39 PM by Rob

    Question on portlet

    Rob Newbie

      I built a portlet using the Hellow World as the example. Here is my code

      import java.io.PrintWriter;
      import java.io.IOException;

      import javax.portlet.GenericPortlet;
      import javax.portlet.PortletConfig;
      import javax.portlet.PortletSecurityException;
      import javax.portlet.RenderRequest;
      import javax.portlet.RenderResponse;
      import javax.portlet.PortletException;

      import com.ibm.as400.access.AS400;
      import com.ibm.as400.access.AS400SecurityException;
      import com.ibm.as400.access.ErrorCompletingRequestException;
      import com.ibm.as400.access.ObjectDoesNotExistException;
      import com.ibm.as400.access.SystemStatus;

      public class SimpleaspPortlet extends GenericPortlet
      {

      public void init(PortletConfig config) throws PortletException
      {
      // TODO Auto-generated method stub
      super.init(config);
      }
      protected void doView(RenderRequest rRequest, RenderResponse rResponse) throws PortletException, PortletSecurityException, IOException
      {
      // TODO Auto-generated method stub
      rResponse.setContentType("text/html");
      PrintWriter writer = rResponse.getWriter();
      AS400 as400 = new AS400("*", "*", "*");
      SystemStatus status = new SystemStatus(as400);
      try {
      writer.write(status.getBatchJobsRunning());
      // writer.write(status.getPercentProcessingUnitUsed());
      writer.write(status.getUsersCurrentSignedOn());
      // writer.write(status.getPercentSystemASPUsed());
      writer.close();
      } catch (AS400SecurityException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (ErrorCompletingRequestException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (ObjectDoesNotExistException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } finally {
      as400.disconnectAllServices();
      }
      }
      }


      When I go to the portal and look at the portlet I get the page but no information is it. Except random Chars.

      Any help would be great

        • 1. Re: Question on portlet
          Peter Johnson Master

          What kind of output is generated by the methods on AS400? Did you also look at the HTML source for the displayed page? I am asking because if the output contains characters or text that is interpreted by the browser as HTML markup, you could see some wierd things (though the expected text would appear just fine in the HTML source). I have run into a similar situation with trying to display a regular expression within a form field.

          • 2. Re: Question on portlet
            Rob Newbie

            Here is the html source I get


            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


            JBoss Portal 2.4.0-CR3
            <meta http-equiv="Content-Type" content="text/html;"/>
            <!-- to correct the unsightly Flash of Unstyled Content. -->

            <!-- inject the theme; default to the Nphalanx theme if nothing is selected for the portal or the page -->





            <!-- insert header content that was possibly set by portlets on the page -->


















            <!-- insert the content of the 'left' region of the page, and assign the css selector id 'regionA' -->


            <!-- insert the content of the 'center' region of the page, and assign the css selector id 'regionB' -->
            SimpleASPPortlet<div class="portlet-mode-minimized" onClick="location.href='/portal/auth/portal/default/SimpleASPPortlet/simpleaspportletWindow?action=a&windowstate=minimized';" title="minimized"><div class="portlet-mode-maximized" onClick="location.href='/portal/auth/portal/default/SimpleASPPortlet/simpleaspportletWindow?action=a&windowstate=maximized';" title="maximized">Ph


            Powered by JBoss
            Portal











            I never get anything back from the AS400 from what I can tell

            • 3. Re: Question on portlet
              Peter Johnson Master

              You should have enclosed the HTML source within

              ...
              brackets.

              • 4. Re: Question on portlet
                Peter Johnson Master

                OK. let me try this again. When you click on the posrtreply button, above the text box there is a Code button. Paste the HTML source into the text box, select the HTML source, and then click on the Code button. This place code backets around the text and prevents the forum post from looking wierd.

                • 5. Re: Question on portlet
                  Rob Newbie

                  Peter

                  Thanks for the reply's I was able to figure it out. I was calling the wrong thing. I am starting to get the hang of this now again thank you