Skip to content

Instantly share code, notes, and snippets.

@cab1729
Created July 2, 2012 19:33
Show Gist options
  • Save cab1729/3035180 to your computer and use it in GitHub Desktop.
Save cab1729/3035180 to your computer and use it in GitHub Desktop.
Liferay Portlet
package org.cab1729.portlets;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.ParamUtil;
import java.io.IOException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.cab1729.beans.session.*;
/**
* Portlet implementation class GetEmpInfoJSPPortlet
* JSP portlet using a web service
*/
public class GetEmpInfoJSPPortlet extends GenericPortlet {
public void init() {
viewJSP = getInitParameter("view-jsp");
}
public void processAction(
ActionRequest actionRequest, ActionResponse actionResponse)
throws IOException, PortletException {
long empId = ParamUtil.getLong(actionRequest, "empId");
GetEmpInfoProxy proxy =
new GetEmpInfoProxy(new GetEmpInfoServiceLocator().getGetEmpInfoAddress());
GetEmpInfo getEmpInfo = proxy.getGetEmpInfo();
String email;
try {
email = getEmpInfo.getEmpEmail(empId);
} catch (Exception e) {
// TODO Auto-generated catch block
email = "";
}
System.out.println("email: " + email);
actionResponse.setRenderParameter("email", email);
}
public void doView(
RenderRequest renderRequest, RenderResponse renderResponse)
throws IOException, PortletException {
include(viewJSP, renderRequest, renderResponse);
}
protected void include(
String path, RenderRequest renderRequest,
RenderResponse renderResponse)
throws IOException, PortletException {
PortletRequestDispatcher portletRequestDispatcher =
getPortletContext().getRequestDispatcher(path);
if (portletRequestDispatcher == null) {
_log.error(path + " is not a valid include");
}
else {
portletRequestDispatcher.include(renderRequest, renderResponse);
}
}
protected String viewJSP;
private static Log _log = LogFactoryUtil.getLog(GetEmpInfoJSPPortlet.class);
}
@cab1729
Copy link
Author

cab1729 commented Jul 2, 2012

Liferay portlet that uses Eclipse generated client code to access the SOAP service interface in a session bean. (see: https://github.com/cab1729/Code-Samples/tree/master/stubejbproject)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment