Tuesday, September 7, 2010

Liferay Struts Portlet: Usage of SessionErrors class...

This is very common issues we come across when we want to change portal code with extension environment. Mostly we do is, copying the code from portal to ext and making new struts portlet.

And for sending errors to pages, we use SessionErrors.add(...) method, which will eventually forward to default error.jsp file. So you will never find what is happening. Simple thing, to make this working fine, is...

- Make new empty page named error.jsp in your portlet.
- Make new Struts-config and tiles-def entry of your new JSP in ext.
- From your render method, forward to the new file when you have SessionErrors filled with errors like,

 if (!SessionErrors.isEmpty(req)) {
  return mapping.findForward("portlet.portlet_name.error");
 }
 

See this link to understand the detailed problem...

0 Comments: