setRenderParameters method problem

Hi,

I am writing a portlet that use the setRenderParameters(Map m) method inside the processAction() in the Portlet class. However, when the program came to this line, it seems to be crash itself out without leaving any error logs. Only the Porlet display the message: ERROR: Content not available.

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

HashMap m =new HashMap();

m.put("1","1");

m.put("2","2");

m.put("3","3");

response.setRenderParameter("name","Hello " + request.getParameter("name"));

System.err.println("setMap");

response.setRenderParameters((Map)m);

System.err.println("endProcessAction");

}

Does anybody have used these method with any success and any suggestion to tackle the problem.

Thanks in advance.

[1335 byte] By [novicessa] at [2007-11-27 11:33:14]
# 1

You may want to use Portlet Container(http://portlet-container.dev.java.net) to test portlets. After its working fine you can deploy in on the Portal Server.

You can also use Netbeans Plugin(portalpack.netbeans.org) to create and test portlets.

In the following case, check the logs. By the default the log level is SEVERE. Decrease it to INFO using psconsole, access the portal page and check logs in psconsole. It will give information of the actual error.

dgothea at 2007-7-29 16:50:08 > top of Java-index,Web & Directory Servers,Portal Servers...
# 2

Thnaks for your suggestion, I will try it on Portlet Container. However, I have use the portlet on Portal 6 as well as running it through the Sun Java Studio Entriprise and both works fine.

My log level setting is already set to fine on both Portal server and Web Server.

novicessa at 2007-7-29 16:50:08 > top of Java-index,Web & Directory Servers,Portal Servers...
# 3

Seems like the code has been changed here. as now the type for the values in the map only allows String[] and not Object anymore. I bit of a bugger for me as it is running just fine on Portal 6.

novicessa at 2007-7-29 16:50:08 > top of Java-index,Web & Directory Servers,Portal Servers...
# 4

It was a bug in Portal Server 6 and was fixed in Portal Server 7

Here is javadoc for ActionResponse.setRenderParameters ( as you can see..if you are using Map, the values have to String array)

public void setRenderParameters(java.util.Map parameters)

Sets a parameter map for the render request.

All previously set render parameters are cleared.

These parameters will be accessible in all sub-sequent render calls via the PortletRequest.getParameter call until a new request is targeted to the portlet.

The given parameters do not need to be encoded prior to calling this method.

Parameters:

parameters - Map containing parameter names for the render phase as keys and parameter values as map values. The keys in the parameter map must be of type String. The values in the parameter map must be of type String array (String[]).

Throws:

java.lang.IllegalArgumentException - if parameters is null, if any of the key/values in the Map are null, if any of the keys is not a String, or if any of the values is not a String array.

java.lang.IllegalStateException - if the method is invoked after sendRedirect has been called.

dgothea at 2007-7-29 16:50:08 > top of Java-index,Web & Directory Servers,Portal Servers...