From: Chad B. <cwb...@us...> - 2008-04-18 21:25:05
|
User: cwbrandon Date: 08/04/18 14:25:12 Modified: andromda-jsf2/src/main/resources/META-INF/andromda cartridge.xml namespace.xml Added: andromda-jsf2/src/main/resources/resources/lib/myfaces tomahawk-1.1.7-SNAPSHOT.jar andromda-jsf2/src/main/resources/templates/jsf2/utils/portlet GenericFaceletsPortlet.java.vsl andromda-jsf2/src/main/resources/resources/lib/portlet jsf-facelets-portlet-1.1.14.jar Log: Add default portlet class Revision Changes Path 1.26 +24 -0 cartridges/andromda-jsf2/src/main/resources/META-INF/andromda/cartridge.xml Index: cartridge.xml =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/META-INF/andromda/cartridge.xml,v retrieving revision 1.25 retrieving revision 1.26 diff -u -w -r1.25 -r1.26 --- cartridge.xml 16 Apr 2008 20:47:10 -0000 1.25 +++ cartridge.xml 18 Apr 2008 21:25:09 -0000 1.26 @@ -76,6 +76,7 @@ <property reference="portletContainer"/> <property reference="portletClass"/> <property reference="paginationResultClassName"/> + <property reference="defaultPortletClassName"/> <!-- cartridge-property merge-point --> @@ -168,6 +169,21 @@ outlet="custom-resources" overwrite="false"/> + <resource + path="resources/lib/portlet/*.*" + outputPattern="WEB-INF/lib/{0}" + outlet="libraries" + overwrite="true" + lastModifiedCheck="true" + outputCondition="portlet"/> + + <resource + path="resources/lib/myfaces/*.*" + outputPattern="WEB-INF/lib/{0}" + outlet="libraries" + overwrite="true" + lastModifiedCheck="true"/> + <!-- process templates on model elements --> <template path="templates/jsf2/configuration/web.xml.vsl" @@ -1049,6 +1065,14 @@ <!-- portlet specific support templates start here --> <template + path="templates/jsf2/utils/portlet/GenericFaceletsPortlet.java.vsl" + outputPattern="$stringUtils.replace($managedBeansPackage, '.', '/')/${className}.java" + outlet="managed-beans" + overwrite="true" + outputToSingleFile="true" + outputCondition="portlet"/> + + <template path="templates/jsf2/configuration/portlet/portlet.xml.vsl" outputPattern="WEB-INF/portlet.xml" outlet="configuration" 1.10 +7 -1 cartridges/andromda-jsf2/src/main/resources/META-INF/andromda/namespace.xml Index: namespace.xml =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/META-INF/andromda/namespace.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -r1.9 -r1.10 --- namespace.xml 16 Apr 2008 20:39:01 -0000 1.9 +++ namespace.xml 18 Apr 2008 21:25:09 -0000 1.10 @@ -308,11 +308,17 @@ </documentation> </property> <property name="portletClass" required="false"> - <default>com.liferay.portlet.jsf.GenericFaceletsPortlet</default> + <default>org.andromda.presentation.jsf2.GenericFaceletsPortlet</default> <documentation> The value of the portlet class in the portlet.xml </documentation> </property> + <property name="defaultPortletClassName" required="false"> + <default>GenericFaceletsPortlet</default> + <documentation> + The name of the default portlet class to use. + </documentation> + </property> </propertyGroup> <propertyGroup name="Table Paging (DB paging)"> <documentation> 1.1 cartridges/andromda-jsf2/src/main/resources/resources/lib/myfaces/tomahawk-1.1.7-SNAPSHOT.jar <<Binary file>> 1.1 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/utils/portlet/GenericFaceletsPortlet.java.vsl Index: GenericFaceletsPortlet.java.vsl =================================================================== #set ($className = $defaultPortletClassName) #if ($stringUtils.isNotEmpty($managedBeansPackage)) package $managedBeansPackage; #end import java.io.IOException; import javax.faces.FactoryFinder; import javax.faces.application.Application; import javax.faces.application.ApplicationFactory; import javax.faces.application.ViewHandler; import javax.faces.component.UIViewRoot; import javax.faces.context.FacesContext; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.PortletException; import javax.portlet.PortletMode; import javax.portlet.PortletSession; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import javax.portlet.UnavailableException; import org.apache.myfaces.context.servlet.ServletFacesContextImpl; /** * Extends the default {@link org.apache.myfaces.portlet.MyFacesGenericPortlet} instance to * provide the necessary support for Facelets. * * @author Raymond Auge * @author Joel Kozikowski * @author Chad Brandon */ public class $className extends org.apache.myfaces.portlet.MyFacesGenericPortlet { public static final String DEFAULT_VIEW_PARAM = "DEFAULT_VIEW_ID"; public void init() throws UnavailableException, PortletException { _editPage = this.getInitParameter("EditPage"); _helpPage = this.getInitParameter("HelpPage"); _viewPage = this.getInitParameter("ViewPage"); super.init(); } public void render(RenderRequest req, RenderResponse res) throws IOException, PortletException { PortletSession ses = req.getPortletSession(); PortletMode mode = (PortletMode)ses.getAttribute("CurrentPortletMode"); if (mode == null) { mode = req.getPortletMode(); } if (mode != req.getPortletMode()) { req.setAttribute("isPortletModeChanged", Boolean.TRUE); } else { req.setAttribute("isPortletModeChanged", Boolean.FALSE); } ses.setAttribute("CurrentPortletMode", mode); super.render(req, res); // - if we don't do this, the FacesContext.getCurrentInstance() // will return null (at least in myfaces 1.1.5) this.facesContext(req, res); } @Override protected void setDefaultView() throws UnavailableException { defaultView = getPortletConfig().getInitParameter(DEFAULT_VIEW); if (defaultView == null) { defaultView = _viewPage; } if (defaultView == null) { throw new UnavailableException( "Default JSF view is not specified in portlet.xml"); } } protected void doEdit(RenderRequest req, RenderResponse res) throws IOException, PortletException { Boolean isPortletModeChanged = (Boolean)req.getAttribute("isPortletModeChanged"); if (isPortletModeChanged.booleanValue()) { setPortletRequestFlag(req); nonFacesRequest(req, res, _editPage); return; } facesRender(req, res); } protected void doHelp(RenderRequest req, RenderResponse res) throws IOException, PortletException { Boolean isPortletModeChanged = (Boolean)req.getAttribute("isPortletModeChanged"); if (isPortletModeChanged.booleanValue()) { setPortletRequestFlag(req); nonFacesRequest(req, res, _helpPage); return; } facesRender(req, res); } /** * Overriden in order to save the VIEW_ID to the portlet session (the version in MyFacesGenericPortlet saves the * viewId as a render parameter which is lost when executing another portlet). This should be fixed at some point * in the {@link org.apache.myfaces.portlet.MyFacesGenericPortlet} code at which time this method can be removed. */ @Override public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { if (sessionTimedOut(request)) return; setPortletRequestFlag(request); FacesContext facesContext = facesContext(request, response); try { lifecycle.execute(facesContext); if (!facesContext.getResponseComplete()) { request.getPortletSession().setAttribute(VIEW_ID, facesContext.getViewRoot().getViewId()); // This here below is what is in the MyFacesGenericPortlet implementation // response.setRenderParameter(VIEW_ID, facesContext.getViewRoot().getViewId()); } request.getPortletSession().setAttribute(CURRENT_FACES_CONTEXT, facesContext); } catch (Throwable e) { facesContext.release(); handleExceptionFromLifecycle(e); } finally { saveRequestAttributes(request); } } /** * Overridden in order to retrieve the VIEW_ID from the portlet session (instead of request.getParameter(VIEW_ID) * as found in {@link org.apache.myfaces.portlet.MyFacesGenericPortlet}). When stored in the request, the VIEW_ID * is lost when executing anything on another portlet instance. This should be fixed at some point * in the {@link org.apache.myfaces.portlet.MyFacesGenericPortlet} code at which time this method can be removed. */ @Override protected void facesRender(RenderRequest request, RenderResponse response) throws PortletException, java.io.IOException { setContentType(request, response); String viewId = request.getParameter(DEFAULT_VIEW_PARAM); boolean restoreRequired = true; if (viewId == null) { viewId = (String)request.getPortletSession().getAttribute(VIEW_ID); } else { // - since we're using an explicitly defined default view (we don't // need to attempt to restore any previous attributes). restoreRequired = false; } // This here below is what was in the MyFacesGenericPortlet implementation // String viewId = request.getParameter(VIEW_ID); if (viewId == null || sessionInvalidated(request)) { setPortletRequestFlag(request); nonFacesRequest(request, response); return; } setPortletRequestFlag(request); ServletFacesContextImpl facesContext = null; try { facesContext = (ServletFacesContextImpl)request.getPortletSession().getAttribute(CURRENT_FACES_CONTEXT); if (facesContext == null) // processAction was not called { facesContext = (ServletFacesContextImpl)facesContext(request, response); setViewRootOnFacesContext(facesContext, viewId); } // TODO: not sure if this can happen. Also double check this against spec section 2.1.3 if (facesContext.getResponseComplete()) return; facesContext.setExternalContext(makeExternalContext(request, response)); if (restoreRequired) { restoreRequestAttributes(request); } lifecycle.render(facesContext); } catch (Throwable e) { handleExceptionFromLifecycle(e); } } // Set the view root on a FacesContext to prepare for rendering private void setViewRootOnFacesContext(FacesContext facesContext, String view) { ApplicationFactory appFactory = (ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY); Application application = appFactory.getApplication(); ViewHandler viewHandler = application.getViewHandler(); UIViewRoot viewRoot = viewHandler.createView(facesContext, view); viewRoot.setViewId(view); facesContext.setViewRoot(viewRoot); } private String _editPage = null; private String _helpPage = null; private String _viewPage = null; } 1.1 cartridges/andromda-jsf2/src/main/resources/resources/lib/portlet/jsf-facelets-portlet-1.1.14.jar <<Binary file>> |