6 Replies Latest reply: Jun 10, 2012 10:34 PM by Minh Hoang TO RSS

Portlet doHeaders method does not work on jBoss 7

donino doninos Newbie

Hi,

 

The very simple 'HelloWorldPortlet' code below works on all Gatein versions with Tomcat 6&7 and Jboss 6.

 

But with the jBoss7 bundle (3.3 and 3.2), when the helloworldportlet is added on a Gatein page,  it makes the session crash: the portal pages are blank and we must logout. And if we come back on the page where the portlet has been added, the session is destroyed again. If the doHeaders code is commented, then it works. 

 

This issue only happens when there is at least a 'script' element added in the doHeaders, with only a 'link' element (a css file) it works. I did not see any error messages in the jBoss server log. 

 

Is it a known issue?

 

Thanks

 

package com.test;

 

import javax.portlet.GenericPortlet;

import javax.portlet.ActionRequest;

import javax.portlet.RenderRequest;

import javax.portlet.ActionResponse;

import javax.portlet.RenderResponse;

import javax.portlet.PortletException;

import java.io.IOException;

import javax.portlet.PortletRequestDispatcher;

import org.w3c.dom.Element;

import javax.portlet.MimeResponse;

 

public class HelloWorldPortlet

extends GenericPortlet {

 

 

    @Override

public void processAction(ActionRequest request, ActionResponse response) throws PortletException,IOException {

    }

   

    @Override

    public void doView(RenderRequest request,RenderResponse response) throws PortletException,IOException {

       response.setContentType("text/html");       

        PortletRequestDispatcher dispatcher =

        getPortletContext().getRequestDispatcher("/WEB-INF/jsp/helloworldportlet_view.jsp");

        dispatcher.include(request, response);

    }

   

    @Override

    public void doEdit(RenderRequest request,RenderResponse response) throws PortletException,IOException {

    response.setContentType("text/html");       

        PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/helloworldportlet_edit.jsp");

        dispatcher.include(request, response);

    }  

   

@Override

  public void doHeaders(RenderRequest request, RenderResponse response)

  {

    Element myscript = response.createElement("script");

    myscript.setAttribute("type", "text/javascript");

    myscript.setAttribute("src", request.getContextPath() + "/js/myscript.js");

    response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, myscript);

  }   

   

}