3/21/2011

Creating a URL for an MVC Portlet

I (sadly) have to work with JSPs at the moment, so I can´t use ICEfaces and I can´t use all the benefits JSF brought into this world. 
When you have to develop with JSPs it´s like going back to the stoneage of web development. But one thing, I just found out, works pretty well. It´s the calling of backing bean methods from a JSP.


If you have created an MVCPortlet (never, ever use the GenericPortlet !!!), then you can create a link, that relates directly to a backing bean method by doing this:


PortletURL url = renderResponse.createActionURL();

url.setParameter("javax.portlet.action","methodName");

url.setParameter("parameter","value");

This relates to a method in your backing bean that looks like this, where you can access your parameters:


public void 
methodName 
(ActionRequest actionRequest, ActionResponse actionResponse) 
throws IOException, PortletException{

String parameter = actionRequest.getParameter("parameter");
System.out.println(parameter);



}



If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.