Created
July 2, 2012 19:33
-
-
Save cab1729/3035180 to your computer and use it in GitHub Desktop.
Liferay Portlet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)