All pastes #396060 Raw Edit

Stuff

public java v1 · immutable
·published 2007-03-15 13:55 UTC
rendered paste body
/** * Copyright (c) 2000-2006 Liferay, LLC. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */package de.tobi.testing.portlets;import java.io.IOException;import javax.portlet.PortletException;import javax.portlet.PortletMode;import javax.portlet.PortletSession;import javax.portlet.RenderRequest;import javax.portlet.RenderResponse;import javax.portlet.UnavailableException;public class Testing_Portlets_Facelets	extends org.apache.myfaces.portlet.MyFacesGenericPortlet {		private String viewPage = null;	private String editPage = null;	private String helpPage = null;		public void init() throws UnavailableException, PortletException {		viewPage = (String) this.getInitParameter("ViewPage");		editPage = (String) this.getInitParameter("EditPage");		helpPage = (String) this.getInitParameter("HelpPage");		super.init();	}		public void render(RenderRequest request, RenderResponse response)			throws PortletException, IOException {		PortletSession session = request.getPortletSession();		PortletMode mode = (PortletMode) session				.getAttribute("CurrentPortletMode");		if (mode == null) {			mode = request.getPortletMode();		}		if (mode != request.getPortletMode()) {			request.setAttribute("isPortletModeChanged", Boolean.TRUE);		} else {			request.setAttribute("isPortletModeChanged", Boolean.FALSE);		}		session.setAttribute("CurrentPortletMode", mode);		super.render(request, response);	}		protected void setDefaultView() throws UnavailableException {        this.defaultView = getPortletConfig().getInitParameter(DEFAULT_VIEW);        if (defaultView == null) {        	this.defaultView = this.viewPage;        }        if (defaultView == null) {            String msg = "Fatal2: must specify a JSF view id as the default view in portlet.xml";            throw new UnavailableException(msg);        }    }	protected void doEdit(RenderRequest request, RenderResponse response)			throws PortletException, IOException {		Boolean isPortletModeChanged = (Boolean) request.getAttribute("isPortletModeChanged");		if (isPortletModeChanged.booleanValue()) {			setPortletRequestFlag(request);			nonFacesRequest(request, response, editPage);			return;		}		facesRender(request, response);	}	protected void doHelp(RenderRequest request, RenderResponse response)			throws PortletException, IOException {		Boolean isPortletModeChanged = (Boolean) request.getAttribute("isPortletModeChanged");		if (isPortletModeChanged.booleanValue()) {			setPortletRequestFlag(request);			nonFacesRequest(request, response, helpPage);			return;		}		facesRender(request, response);	}}