From: Chad B. <cwb...@us...> - 2008-03-28 22:19:11
|
User: cwbrandon Date: 08/03/28 15:19:16 Modified: andromda-jsf2/src/main/resources/templates/jsf2/views/portlet edit.xhtml.vsl andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: expose some convience methods on the controller for portlets Revision Changes Path 1.2 +7 -9 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/portlet/edit.xhtml.vsl Index: edit.xhtml.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/portlet/edit.xhtml.vsl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- edit.xhtml.vsl 21 Mar 2008 16:07:11 -0000 1.1 +++ edit.xhtml.vsl 28 Mar 2008 22:19:15 -0000 1.2 @@ -1,18 +1,16 @@ <div xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" - xmlns:f="http://java.sun.com/jsf/core" - xmlns:lr="http://www.liferay.com/jsf/facelets"> - + xmlns:f="http://java.sun.com/jsf/core"> <f:view> <h:form> - <!--h:panelGrid columns="2"> - - <h:outputText value="Editor height (in pixels)" style="font-weight: bold; text-align: right; width: 100%"/> - <h:inputText value="#{portletPreferences.editorHeight}"/> - + <h:panelGrid columns="2"> +#foreach ($attribute in $useCase.preferences.getAttributes(true)) + <h:outputText value="#{messages['$attribute.messageKey']}:" style="font-weight: bold; text-align: right; width: 100%"/> + <h:inputText value="#{${useCase.controller.beanName}.preferences.${attribute.name}}"/> +#end </h:panelGrid> - <lr:commandButton value="Save" action="#{editBackingBean.savePreferences}"/--> + <h:commandButton value="#{messages['action.save']}" action="#{${useCase.controller.beanName}.setPortletModeView}"/> </h:form> </f:view> </div> \ No newline at end of file 1.11 +57 -3 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/controllers/Controller.java.vsl Index: Controller.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/controllers/Controller.java.vsl,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -r1.10 -r1.11 --- Controller.java.vsl 28 Mar 2008 20:32:25 -0000 1.10 +++ Controller.java.vsl 28 Mar 2008 22:19:15 -0000 1.11 @@ -163,7 +163,7 @@ * * @return the JSF faces context instance. */ - protected javax.faces.context.FacesContext getContext() + public javax.faces.context.FacesContext getContext() { return javax.faces.context.FacesContext.getCurrentInstance(); } @@ -531,14 +531,68 @@ this.getRequest().setAttribute(ACTION_EVENT_ATTRIBUTES, event.getComponent(). getAttributes()); } -#if ($portlet && $controller.useCase.preferences) +#if ($portlet) +#if ($controller.useCase.preferences) /** * Gets the portlet preferences available to this controller. */ - protected $controller.useCase.preferences.name getPreferences() + public $controller.useCase.preferences.name getPreferences() { return ${controller.useCase.preferences.name}.getInstance(); } #end + + /** + * Gets the current action response. + * + * @return the current action response. + */ + protected javax.portlet.ActionResponse getActionResponse() + { + javax.portlet.ActionResponse actionResponse = null; + if (this.getResponse() instanceof javax.portlet.ActionResponse) + { + actionResponse = (javax.portlet.ActionResponse)this.getResponse(); + } + return actionResponse; + } + + protected void setPortletMode(final javax.portlet.PortletMode mode) + throws javax.portlet.PortletModeException + { + final javax.portlet.ActionResponse actionResponse = this.getActionResponse(); + if (actionResponse != null) + { + actionResponse.setPortletMode(mode); + } + } + + /** + * Sets the portlet to the {@link javax.portlet.PortletMode#VIEW} mode. + */ + public void setPortletModeView() + throws javax.portlet.PortletModeException + { + this.setPortletMode(javax.portlet.PortletMode.VIEW); + } + + /** + * Sets the portlet to the {@link javax.portlet.PortletMode#EDIT} mode. + */ + public void setPortletModeEdit() + throws javax.portlet.PortletModeException + { + this.setPortletMode(javax.portlet.PortletMode.EDIT); + } + + /** + * Sets the portlet to the {@link javax.portlet.PortletMode#HELP} mode. + */ + public void setPortletModeHelp() + throws javax.portlet.PortletModeException + { + this.setPortletMode(javax.portlet.PortletMode.HELP); + } +#end } \ No newline at end of file |