From: Leif J. <le...@us...> - 2007-06-10 20:27:14
|
User: leifj Date: 07/06/10 13:27:17 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: fall back to using session if storing in the pageFlowScope doesn\t work Revision Changes Path 1.2 +1 -0 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.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- Controller.java.vsl 5 Dec 2006 19:39:27 -0000 1.1 +++ Controller.java.vsl 10 Jun 2007 20:27:17 -0000 1.2 @@ -61,6 +61,7 @@ { #if (!$action.formFields.empty) contextWrapper.getCurrentInstance().getPageFlowScope().put("$action.formKey", form); + this.getSession(false).setAttribute("$action.formKey",form); // - add this temporary ADF context to the session so that we can retrieve from a view populator if required this.getSession(false).setAttribute("$adfContextAttributeName", contextWrapper); #end |
From: Chad B. <cwb...@us...> - 2007-09-26 15:46:03
|
User: cwbrandon Date: 07/09/26 08:46:03 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: switch ordering of parameter/attribute population Revision Changes Path 1.5 +3 -2 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.4 retrieving revision 1.5 diff -u -w -r1.4 -r1.5 --- Controller.java.vsl 19 Sep 2007 16:50:53 -0000 1.4 +++ Controller.java.vsl 26 Sep 2007 15:46:03 -0000 1.5 @@ -54,11 +54,12 @@ // - pass any properties from the previous form along ${managedBeansPackage}.${formPopulatorName}.populateForm(currentForm, form); + // - populate the form with any event attributes that may match + ${managedBeansPackage}.${formPopulatorName}.populateFormFromPropertyMap( + form, form.getDateTimeFormatters(), (java.util.Map)this.getRequest().getAttribute(ACTION_EVENT_ATTRIBUTES)); // - populate the form with any request parameters that may match ${managedBeansPackage}.${formPopulatorName}.populateFormFromPropertyMap( form, form.getDateTimeFormatters(), this.getContext().getExternalContext().getRequestParameterMap()); - ${managedBeansPackage}.${formPopulatorName}.populateFormFromPropertyMap( - form, form.getDateTimeFormatters(), (java.util.Map)this.getRequest().getAttribute(ACTION_EVENT_ATTRIBUTES)); #end try { |
From: Walter M. <wal...@us...> - 2008-02-25 14:19:40
|
User: walterim Date: 08/02/25 06:19:46 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: Added support to 'silent' exceptions so the programmer can keep the current page without showing a global message. Useful when showing only field messages. Revision Changes Path 1.7 +3 -4 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.6 retrieving revision 1.7 diff -u -w -r1.6 -r1.7 --- Controller.java.vsl 26 Sep 2007 17:59:27 -0000 1.6 +++ Controller.java.vsl 25 Feb 2008 14:19:46 -0000 1.7 @@ -80,10 +80,9 @@ catch (final Throwable throwable) { contextWrapper.getCurrentInstance().getPageFlowScope().put("$action.formKey", currentForm); - final String message = ${managedBeansPackage}.Messages.get( - ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable), null); - throwable.printStackTrace(); - this.addErrorMessage(message); + final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); + if(!org.apache.commons.lang.StringUtils.isEmpty(messageKey)) + this.addErrorMessage(${managedBeansPackage}.Messages.get(messageKey, null)); } } catch (final Throwable throwable) |
From: Chad B. <cwb...@us...> - 2008-03-28 20:30:54
|
User: cwbrandon Date: 08/03/28 13:31:00 Modified: andromda-jsf2/src/main/resources/templates/jsf2/preferences/portlet Preferences.java.vsl andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: finish implementing facade portlet prefs class Revision Changes Path 1.2 +58 -120 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/preferences/portlet/Preferences.java.vsl Index: Preferences.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/preferences/portlet/Preferences.java.vsl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- Preferences.java.vsl 28 Mar 2008 18:37:03 -0000 1.1 +++ Preferences.java.vsl 28 Mar 2008 20:30:59 -0000 1.2 @@ -8,164 +8,102 @@ #end /** + * Provides access to portlet preferences for: $class.useCase.name. $class.getDocumentation(" * ") */ -public#if($class.abstract) abstract#end class $class.name -#if($class.generalization) - extends $class.generalization.fullyQualifiedName -#end -#if ($serializable) - implements java.io.Serializable -#end +public class $class.name { -#if ($serializable) /** - * The serial version UID of this class. Needed for serialization. + * The shared instance of this class. */ - private static final long serialVersionUID = ${class.serialVersionUID}L; + private static $class.name instance; -#end -## -## default constructor -## -#if ($class.requiredConstructorParameters.size() > 0 || $class.allRequiredConstructorParameters.size() > $class.requiredConstructorParameters.size()) - public ${class.name}() + /** + * Gets the shared instance of this class. + */ + public static $class.name getInstance() { -#if($class.generalization) - super(); -#end + if (instance == null) + { + instance = new ${class.name}(); + } + return instance; } -#end -## -## constructor taking only required properties -## -#if ($class.allProperties.size() > $class.allRequiredConstructorParameters.size() && ($class.allRequiredConstructorParameters.size() != 1 || !$class.allRequiredConstructorParameters.get(0).getterSetterTypeName.equals($class.fullyQualifiedName))) - public ${class.name}(## no newline -#set ($comma = "") -#foreach ($property in $class.allRequiredConstructorParameters) -${comma}${property.getterSetterTypeName} ${property.name}## no newline -#set ($comma = ", ") -#end -) + private ${class.name}() { -#if($class.generalization) - super(## no newline -#set ($comma = "") -#foreach ($property in $class.generalization.allRequiredConstructorParameters) -${comma}${property.name}## no newline -#set ($comma = ", ") -#end -); -#end -#foreach ($property in $class.requiredConstructorParameters) - this.${property.name} = ${property.name}; -#end } -#end -## -## constructor taking all properties -## -#if ($class.allProperties.size() != 1 || !$class.allProperties.get(0).getterSetterTypeName.equals($class.fullyQualifiedName)) - public ${class.name}(## no newline -#set ($comma = "") -#foreach ($property in $class.allProperties) -${comma}${property.getterSetterTypeName} ${property.name}## no newline -#set ($comma = ", ") -#end -) + protected javax.portlet.PortletPreferences getPreferences() { -#if($class.generalization) - super(## no newline -#set ($comma = "") -#foreach ($property in $class.generalization.allProperties) -${comma}${property.name}## no newline -#set ($comma = ", ") -#end -); -#end -#foreach ($property in $class.properties) - this.${property.name} = ${property.name}; -#end + return ((javax.portlet.PortletRequest)javax.faces.context.FacesContext.getCurrentInstance().getExternalContext().getRequest()).getPreferences(); } +#foreach ($attribute in $class.attributes) -#end /** - * Copies constructor from other ${class.name} - * - * @param otherBean, cannot be <code>null</code> - * @throws java.lang.NullPointerException if the argument is <code>null</code> +$attribute.getDocumentation(" * ") */ - public ${class.name}(${class.name} otherBean) + public $attribute.getterSetterTypeName ${attribute.getterName}() { - this(## no newline -#set ($comma = "") -#foreach ($property in $class.allProperties) -${comma}otherBean.${property.getterName}()## no newline -#set ($comma = ", ") + final java.lang.String value = this.getPreferences().getValue("$attribute.name", null); +#if (!$attribute.type.stringType) + final $attribute.type.wrapperName wrappedValue = ${attribute.type.wrapperName}.valueOf(value); +#* *##if ($attribute.type.primitive) + return wrappedValue.${attribute.getterSetterTypeName}Value(); +#* *##else + return wrappedValue; +#* *##end +#else + return value; #end -); } /** - * Copies all properties from the argument value object into this value object. + * Associates the value of the specified <code>${attribute.name}</code> + * with the '${attribute.name}' preference and persists the change if <code>store</code> + * is specified as <code>true</code>. + * + * @param $attribute.name the value to give the $attribute.name preference. */ - public void copy(${class.name} otherBean) + public void ${attribute.setterName}(final $attribute.getterSetterTypeName $attribute.name, final boolean store) + throws Exception { - if (otherBean != null) +#if ($attribute.type.primitive) + final java.lang.String value = java.lang.String.valueOf($attribute.name); +#else + java.lang.String value = null; + if ($attribute.name != null) { -#foreach ($property in $class.allProperties) - this.${property.setterName}(otherBean.${property.getterName}()); -#end - } + value = java.lang.String.valueOf($attribute.name); } - -#foreach ($attribute in $class.attributes) - private $attribute.getterSetterTypeName $attribute.name#if ($attribute.defaultValuePresent) = $attribute.defaultValue#end; - - /** -$attribute.getDocumentation(" * ") - */ - public $attribute.getterSetterTypeName ${attribute.getterName}() +#end + this.getPreferences().setValue("$attribute.name", value); + if (store) { - return this.${attribute.name}; + this.store(); } - -## - always have as public, having read-only causes too many issues when attempting to -## use in other cartridges - public void ${attribute.setterName}($attribute.getterSetterTypeName $attribute.name) - { - this.${attribute.name} = $attribute.name; } -#end -## Generate the relation methods. -#foreach ($associationEnd in $class.associationEnds) -#set ($target = $associationEnd.otherEnd) -#if ($target.navigable) - private $target.getterSetterTypeName $target.name; - /** - * Get the $target.name -$target.getDocumentation(" * ") + * Associates the value of the specified <code>${attribute.name}</code> + * with the '${attribute.name}' preference and persists the change. + * + * @param $attribute.name the value to give the $attribute.name preference. */ - public $target.getterSetterTypeName ${target.getterName}() + public void ${attribute.setterName}(final $attribute.getterSetterTypeName $attribute.name) + throws Exception { - return this.${target.name}; + this.${attribute.setterName}($attribute.name, true); } -## - always have as public, having read-only causes too many issues when attempting to -## use in other cartridges +#end /** - * Sets the $target.name + * Commits any pending portlet preference changes. */ - public void ${target.setterName}($target.getterSetterTypeName $target.name) + public void store() throws Exception { - this.${target.name} = ${target.name}; + this.getPreferences().store(); } -#end -#end - // ${class.fullyQualifiedName} value-object java merge-point + // ${class.fullyQualifiedName} portlet-preferences merge-point } \ No newline at end of file 1.9 +10 -0 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.8 retrieving revision 1.9 diff -u -w -r1.8 -r1.9 --- Controller.java.vsl 21 Mar 2008 16:07:13 -0000 1.8 +++ Controller.java.vsl 28 Mar 2008 20:31:00 -0000 1.9 @@ -531,4 +531,14 @@ this.getRequest().setAttribute(ACTION_EVENT_ATTRIBUTES, event.getComponent(). getAttributes()); } +#if ($portlet && $controller.useCase.preferences) + + /** + * Gets the portlet preferences available to this controller. + */ + protected $controller.useCase.preferences.name getPreferences() + { + return ${controller.useCase.preferences.name}.getInstance(); + } +#end } \ No newline at end of file |
From: Chad B. <cwb...@us...> - 2008-03-28 20:32:21
|
User: cwbrandon Date: 08/03/28 13:32:25 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: typo Revision Changes Path 1.10 +1 -1 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.9 retrieving revision 1.10 diff -u -w -r1.9 -r1.10 --- Controller.java.vsl 28 Mar 2008 20:31:00 -0000 1.9 +++ Controller.java.vsl 28 Mar 2008 20:32:25 -0000 1.10 @@ -401,7 +401,7 @@ } /** - * If the given <code>component</code> has an child input elements, this method findds + * If the given <code>component</code> has an child input elements, this method finds * them all and populates them. This is to get around the fact that when immediate is set to true * on a button that submits the form that the form isn't populated. * |
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 |
From: Chad B. <cwb...@us...> - 2008-05-15 19:30:24
|
User: cwbrandon Date: 08/05/15 12:30:28 Modified: andromda-jsf2/src/main/resources/templates/jsf2/flow ViewPopulator.java.vsl andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: improve exception handling a bit (make sure the form that was set before an exception occured is set back) Revision Changes Path 1.8 +2 -1 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/flow/ViewPopulator.java.vsl Index: ViewPopulator.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/flow/ViewPopulator.java.vsl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -r1.7 -r1.8 --- ViewPopulator.java.vsl 8 Apr 2008 16:29:06 -0000 1.7 +++ ViewPopulator.java.vsl 15 May 2008 19:30:24 -0000 1.8 @@ -156,6 +156,7 @@ try { #if (!$view.formActions.empty) + final boolean override = (($jsfUtils.requestClassName)facesContext.getExternalContext().getRequest()).getAttribute(${view.useCase.controller.name}.CONTROLLER_EXCEPTION) != null; // - populate the forms if (form != null) { @@ -165,7 +166,7 @@ facesContext, "$action.formBeanName"); // - populate the $action.formBeanName with any parameters from the previous form - ${managedBeansPackage}.${formPopulatorName}.populateForm(form, $action.formBeanName); + ${managedBeansPackage}.${formPopulatorName}.populateForm(form, $action.formBeanName, override); request.setAttribute("$action.formBeanName", $action.formBeanName); #end } 1.13 +4 -0 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.12 retrieving revision 1.13 diff -u -w -r1.12 -r1.13 --- Controller.java.vsl 29 Mar 2008 00:05:32 -0000 1.12 +++ Controller.java.vsl 15 May 2008 19:30:28 -0000 1.13 @@ -8,6 +8,8 @@ public abstract class $controller.name implements java.io.Serializable { + static final String CONTROLLER_EXCEPTION = ${controller.name}.class.getName() + ".exception"; + #foreach ($operation in $controller.operations) /** $operation.getDocumentation(" * ") @@ -75,6 +77,7 @@ } catch (final Throwable throwable) { + this.getRequest().setAttribute(CONTROLLER_EXCEPTION, throwable); this.setForm("$action.formKey", currentForm, false); final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); if(!org.apache.commons.lang.StringUtils.isEmpty(messageKey)) @@ -83,6 +86,7 @@ } catch (final Throwable throwable) { + this.getRequest().setAttribute(CONTROLLER_EXCEPTION, throwable); this.setForm("$action.formKey", currentForm, false); this.addExceptionMessage(throwable); // - set the forward to null so that we stay on the current view |
From: Chad B. <cwb...@us...> - 2008-05-16 22:18:46
|
User: cwbrandon Date: 08/05/16 13:27:18 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: add some convience methods to getting and setting request/session attributes (to insulate us from portlet vs http requests and sessions). Revision Changes Path 1.14 +42 -7 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.13 retrieving revision 1.14 diff -u -w -r1.13 -r1.14 --- Controller.java.vsl 15 May 2008 19:30:28 -0000 1.13 +++ Controller.java.vsl 16 May 2008 20:27:18 -0000 1.14 @@ -59,7 +59,7 @@ // IMPORTANT: it isn't possible to automatically populate any property named "id" since that // is a reserved name in JSF (the id of a component), therefore we have to unfortunately ignore any availble "id" attribute ${managedBeansPackage}.${formPopulatorName}.populateFormFromPropertyMap( - form, form.getDateTimeFormatters(), (java.util.Map)this.getRequest().getAttribute(ACTION_EVENT_ATTRIBUTES), new String[] {"id"}); + form, form.getDateTimeFormatters(), (java.util.Map)this.getRequestAttribute(ACTION_EVENT_ATTRIBUTES), new String[] {"id"}); // - populate the form with any request parameters that may match ${managedBeansPackage}.${formPopulatorName}.populateFormFromPropertyMap( form, form.getDateTimeFormatters(), this.getContext().getExternalContext().getRequestParameterMap()); @@ -77,7 +77,7 @@ } catch (final Throwable throwable) { - this.getRequest().setAttribute(CONTROLLER_EXCEPTION, throwable); + this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); this.setForm("$action.formKey", currentForm, false); final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); if(!org.apache.commons.lang.StringUtils.isEmpty(messageKey)) @@ -86,7 +86,7 @@ } catch (final Throwable throwable) { - this.getRequest().setAttribute(CONTROLLER_EXCEPTION, throwable); + this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); this.setForm("$action.formKey", currentForm, false); this.addExceptionMessage(throwable); // - set the forward to null so that we stay on the current view @@ -253,15 +253,15 @@ contextWrapper.getCurrentInstance().getPageFlowScope().put(formKey, form); if (includeInSession) { - this.getSession(false).setAttribute(formKey, form); + this.setSessionAttribute(formKey, form); // - add this temporary ADF context to the session so that we can retrieve from a view populator if required this.getSession(false).setAttribute("$adfContextAttributeName", contextWrapper); } #else - this.getRequest().setAttribute(formKey, form); + this.setRequestAttribute(formKey, form); if (includeInSession) { - this.getSession(false).setAttribute(formKey, form); + this.setSessionAttribute(formKey, form); } #end } @@ -532,9 +532,30 @@ */ public void action(javax.faces.event.ActionEvent event) { - this.getRequest().setAttribute(ACTION_EVENT_ATTRIBUTES, event.getComponent(). + this.setRequestAttribute(ACTION_EVENT_ATTRIBUTES, event.getComponent(). getAttributes()); } + + protected void setRequestAttribute(final String name, final Object object) + { + ${managedBeansPackage}.JsfUtils.setAttribute(this.getContext().getExternalContext().getRequest(), name, object); + } + + protected Object getRequestAttribute(final String name) + { + return ${managedBeansPackage}.JsfUtils.getAttribute(this.getContext().getExternalContext().getRequest(), name); + } + + protected void setSessionAttribute(final String name, final Object object) + { + ${managedBeansPackage}.JsfUtils.setAttribute(this.getContext().getExternalContext().getSession(false), name, object); + } + + protected Object getSessionAttribute(final String name) + { + return ${managedBeansPackage}.JsfUtils.getAttribute(this.getContext().getExternalContext().getSession(false), name); + } + #if ($portlet) #if ($controller.useCase.preferences) @@ -548,6 +569,20 @@ #end /** + * Sets the given form into the {@link javax.portlet.PortletSession#APPLICATION_SCOPE}. + * + * @param form the form to set into the application scope (useful when you need to pass + * the form to another portlet or to the webapp outside of the portlet. + */ + protected void setFormInSessionApplicationScope(final Object form) + { + if (this.getContext().getExternalContext().getSession(false) instanceof javax.portlet.PortletSession) + { + this.getSession(false).setAttribute("$actionFormKey", form, javax.portlet.PortletSession.APPLICATION_SCOPE); + } + } + + /** * Gets the current action response. * * @return the current action response. |
From: Chad B. <cwb...@us...> - 2008-05-28 15:10:18
|
User: cwbrandon Date: 08/05/28 08:10:25 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: Make controller operations throw Throwable (so we don't have to worry about rethrowing exceptions and having them handled in the controller impl code) Revision Changes Path 1.15 +7 -2 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.14 retrieving revision 1.15 diff -u -w -r1.14 -r1.15 --- Controller.java.vsl 16 May 2008 20:27:18 -0000 1.14 +++ Controller.java.vsl 28 May 2008 15:10:25 -0000 1.15 @@ -8,13 +8,16 @@ public abstract class $controller.name implements java.io.Serializable { + private static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(${controller.name}.class); + static final String CONTROLLER_EXCEPTION = ${controller.name}.class.getName() + ".exception"; #foreach ($operation in $controller.operations) /** $operation.getDocumentation(" * ") */ - $operation.formSignature; + $operation.formSignature + throws java.lang.Throwable; #end @@ -90,8 +93,8 @@ this.setForm("$action.formKey", currentForm, false); this.addExceptionMessage(throwable); // - set the forward to null so that we stay on the current view - throwable.printStackTrace(); forward = null; + logger.error(throwable); } return forward; #end @@ -102,6 +105,7 @@ $actionState.getDocumentation(" * ") */ private java.lang.String ${actionState.actionMethodName}(#if (!$action.formFields.empty)final $action.fullyQualifiedFormImplementationName form#end) + throws java.lang.Throwable { java.lang.String forward = null; #if ($actionState.controllerCalls.empty) @@ -127,6 +131,7 @@ $decisionTransition.getDocumentation(" * ") */ private java.lang.String __${decisionTransition.operationCall.name}(#if (!$action.formFields.empty)final $action.fullyQualifiedFormImplementationName form#end) + throws java.lang.Throwable { final String value = java.lang.String.valueOf($decisionTransition.operationCall.formCall); #foreach ($outcome in $decisionTransition.target.outgoing) |
From: Chad B. <cwb...@us...> - 2008-05-28 19:04:27
|
User: cwbrandon Date: 08/05/28 12:04:34 Modified: andromda-jsf2/src/main/resources/templates/jsf2/utils Messages.java.vsl MessagePhaseListener.java.vsl andromda-jsf2/src/main/resources/templates/jsf2/views/portlet messages.xhtml.vsl andromda-jsf2/src/main/resources/templates/jsf2/messages messages.properties.vsl andromda-jsf2/src/main/resources/templates/jsf2/forms FormImpl.java.vsl andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: Add default messages title (and ability to set in in a controller operation) Revision Changes Path 1.3 +11 -0 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/utils/Messages.java.vsl Index: Messages.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/utils/Messages.java.vsl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- Messages.java.vsl 3 Apr 2008 22:21:20 -0000 1.2 +++ Messages.java.vsl 28 May 2008 19:04:29 -0000 1.3 @@ -58,4 +58,15 @@ } return resourceString; } + + /** + * Gets the message given the <code>key</code>. + * + * @param key the message key. + * @return the message (or key if the message isn't found). + */ + public static String get(String key) + { + return get(key, (Object[])null); + } } \ No newline at end of file 1.7 +23 -1 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/utils/MessagePhaseListener.java.vsl Index: MessagePhaseListener.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/utils/MessagePhaseListener.java.vsl,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -r1.6 -r1.7 --- MessagePhaseListener.java.vsl 28 May 2008 17:23:26 -0000 1.6 +++ MessagePhaseListener.java.vsl 28 May 2008 19:04:29 -0000 1.7 @@ -69,7 +69,24 @@ { javax.faces.context.FacesContext.getCurrentInstance().addMessage(null, (javax.faces.application.FacesMessage)iterator.next()); } - form.getClass().getMethod("clearJsfMessages", (Class[])null).invoke(form, (Object[])null); + // - set the messages title to use (if we have a severity of error or higher) + final javax.faces.application.FacesMessage.Severity severity = context.getMaximumSeverity(); + if (severity != null && severity.getOrdinal() >= javax.faces.application.FacesMessage.SEVERITY_ERROR.getOrdinal()) + { + final java.lang.Object request = context.getExternalContext().getRequest(); + if (request instanceof $jsfUtils.requestClassName) + { + String messagesTitle = (String)form.getClass().getMethod("get${stringUtils.capitalize($formMessagesProperty)}Title", (Class[])null).invoke(form, (Object[])null); + if (messagesTitle == null || messagesTitle.trim().length() == 0) + { + messagesTitle = Messages.get("errors.header", null); + } + (($jsfUtils.requestClassName)request).setAttribute(MESSAGES_TITLE, messagesTitle); + } + } + form.getClass().getMethod("clear${stringUtils.capitalize($formMessagesProperty)}", (Class[])null).invoke(form, (Object[])null); + form.getClass().getMethod("set${stringUtils.capitalize($formMessagesProperty)}Title", + new Class[]{java.lang.String.class}).invoke(form, new Object[]{null}); } } catch (final Exception exception) @@ -79,6 +96,11 @@ } } + /** + * The name of the property storing the title to use for faces messages in the request scope + */ + protected static final String MESSAGES_TITLE = "${formMessagesProperty}Title"; + @Override protected void handleAfterPhase(javax.faces.event.PhaseEvent event) { 1.3 +4 -1 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/portlet/messages.xhtml.vsl Index: messages.xhtml.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/portlet/messages.xhtml.vsl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- messages.xhtml.vsl 27 May 2008 16:14:19 -0000 1.2 +++ messages.xhtml.vsl 28 May 2008 19:04:31 -0000 1.3 @@ -2,6 +2,9 @@ xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"> <ui:composition> - <h:messages globalOnly="true" title="#{messages['errors.header']}" rendered="#{!hideGlobalMessages}"/> + <h:panelGrid columns="1" cellpadding="2" cellspacing="2" rendered="#{!hideGlobalMessages and !empty facesContext.maximumSeverity}"> + <h:outputText value="#{${formMessagesProperty}Title}" escape="false" rendered="#{!empty ${formMessagesProperty}Title}"/> + <h:messages globalOnly="true" showDetail="false"/> + </h:panelGrid> </ui:composition> </div> 1.12 +2 -2 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/messages/messages.properties.vsl Index: messages.properties.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/messages/messages.properties.vsl,v retrieving revision 1.11 retrieving revision 1.12 diff -u -w -r1.11 -r1.12 --- messages.properties.vsl 23 May 2008 20:59:54 -0000 1.11 +++ messages.properties.vsl 28 May 2008 19:04:32 -0000 1.12 @@ -103,9 +103,9 @@ login.na=This feature is not available yet # -# Messages for the validator plugin +# Messages for validation # -errors.header=Errors +errors.header=You have one or more error(s) present: errors.required={0} is required. errors.minlength={0} can not be less than {1} characters. 1.7 +26 -0 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/forms/FormImpl.java.vsl Index: FormImpl.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/forms/FormImpl.java.vsl,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -r1.6 -r1.7 --- FormImpl.java.vsl 28 May 2008 16:40:45 -0000 1.6 +++ FormImpl.java.vsl 28 May 2008 19:04:33 -0000 1.7 @@ -185,6 +185,32 @@ } /** + * The faces message title (used on a view). + */ + private String ${formMessagesProperty}Title; + + /** + * The optional faces message title to set (used on a view). If not set, the default title + * will be used. + * + * @param jsfMessagesTitle the title to use for the messages on the view. + */ + public void set${stringUtils.capitalize($formMessagesProperty)}Title(final String ${formMessagesProperty}Title) + { + this.${formMessagesProperty}Title = ${formMessagesProperty}Title; + } + + /** + * Gets the faces messages title to use. + * + * @return the faces messages title. + */ + public String get${stringUtils.capitalize($formMessagesProperty)}Title() + { + return this.${formMessagesProperty}Title; + } + + /** * Gets the maximum severity of the messages stored in this form. * * @return the maximum severity or null if no messages are present and/or severity isn't set. 1.17 +24 -0 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.16 retrieving revision 1.17 diff -u -w -r1.16 -r1.17 --- Controller.java.vsl 28 May 2008 16:40:46 -0000 1.16 +++ Controller.java.vsl 28 May 2008 19:04:33 -0000 1.17 @@ -361,6 +361,30 @@ } /** + * Sets the messages title to use on the next view. + * + * @param messagesTitle the title to use. + */ + protected void setMessagesTitle(final String messagesTitle) + { + final Object form = this.resolveVariable("form"); + if (form != null) + { + try + { + final java.lang.reflect.Method method = form.getClass().getMethod( + "set${stringUtils.capitalize($formMessagesProperty)}Title", + new Class[]{java.lang.String.class}); + method.invoke(form, new Object[]{messagesTitle}); + } + catch (final Exception exception) + { + throw new RuntimeException(exception); + } + } + } + + /** * Gets the maximum severity of the messages stored in the current form. * * @return the maximum message severity. |
From: Chad B. <cwb...@us...> - 2008-06-03 21:26:15
|
User: cwbrandon Date: 08/06/03 14:26:23 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: log the controller error Revision Changes Path 1.18 +1 -0 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.17 retrieving revision 1.18 diff -u -w -r1.17 -r1.18 --- Controller.java.vsl 28 May 2008 19:04:33 -0000 1.17 +++ Controller.java.vsl 3 Jun 2008 21:26:23 -0000 1.18 @@ -80,6 +80,7 @@ } catch (final Throwable throwable) { + logger.error(throwable); this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); this.setForm("$action.formKey", currentForm, false); final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); |
From: Chad B. <cwb...@us...> - 2008-07-01 15:42:35
|
User: cwbrandon Date: 08/07/01 08:42:43 Modified: andromda-jsf2/src/main/resources/templates/jsf2/flow/portlet PortletPhaseListener.java.vsl andromda-jsf2/src/main/resources/templates/jsf2/utils JsfUtils.java.vsl FormPopulator.java.vsl andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: Add ability to pass parameters from URL to portlets. Also add population of form from request attributes with matching names. Revision Changes Path 1.14 +18 -0 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/flow/portlet/PortletPhaseListener.java.vsl Index: PortletPhaseListener.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/flow/portlet/PortletPhaseListener.java.vsl,v retrieving revision 1.13 retrieving revision 1.14 diff -u -w -r1.13 -r1.14 --- PortletPhaseListener.java.vsl 30 Jun 2008 15:15:22 -0000 1.13 +++ PortletPhaseListener.java.vsl 1 Jul 2008 15:42:41 -0000 1.14 @@ -16,12 +16,30 @@ private static final String FACES_CONTEXT = "facesContext"; +#if ($liferayPortlet) + /** + * Liferay specific attribute available in the request that gives the current URL in the browser. + */ + private static final String CURRENT_URL = "CURRENT_URL"; + +#end @Override protected void handleBeforePhase(javax.faces.event.PhaseEvent event) { String viewId = this.getViewId(event); if (viewId != null && event.getFacesContext() != null) { +#if ($liferayPortlet) + // - get the parameters from the current URL and set them as request attributes to make them available to the current portlets + // (otherwise we'd need to namespace prefix the parameter names in order to pass them to the portlet - at least in Liferay) + final javax.portlet.PortletRequest request = (javax.portlet.PortletRequest)event.getFacesContext().getExternalContext().getRequest(); + final String currentUrl = (String)request.getAttribute(CURRENT_URL); + final java.util.Map<String, Object> parameters = ${managedBeansPackage}.JsfUtils.extractParameters(currentUrl); + for (final String parameter : parameters.keySet()) + { + request.setAttribute(parameter, parameters.get(parameter)); + } +#end // - make the faces context available to all views ((javax.portlet.PortletRequest)event.getFacesContext().getExternalContext().getRequest()).setAttribute(FACES_CONTEXT, event.getFacesContext()); 1.7 +99 -6 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/utils/JsfUtils.java.vsl Index: JsfUtils.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/utils/JsfUtils.java.vsl,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -r1.6 -r1.7 --- JsfUtils.java.vsl 20 May 2008 16:21:46 -0000 1.6 +++ JsfUtils.java.vsl 1 Jul 2008 15:42:41 -0000 1.7 @@ -255,6 +255,93 @@ } /** + * Gets the names of all attributes on the given object. + * + * @param object the object on which to get all attribute names. + * @return an array of all attribute names. + */ + public static String[] getAttributeNames(final Object object) + { + final java.util.Collection<java.lang.String> names = new java.util.ArrayList<String>(); + try + { + if (object != null) + { + try + { + final java.lang.reflect.Method method = object.getClass().getMethod("getAttributeNames", new Class[]{}); + final java.util.Enumeration enumeration = (java.util.Enumeration)method.invoke(object, (Object[])null); + if (enumeration != null) + { + while (enumeration.hasMoreElements()) + { + names.add(java.lang.String.valueOf(enumeration.nextElement())); + } + } + } + catch (NoSuchMethodException exception) + { + } + } + } + catch (Exception exception) + { + throw new RuntimeException(exception); + } + return names.toArray(new java.lang.String[0]); + } + + /** + * Extracts and returns the parameters from the given URL string. + * + * @param url the URL from which to extract parameters. + * @return the Map of parameters. + */ + @SuppressWarnings("unchecked") + public static java.util.Map<String, Object> extractParameters(final String url) + { + final java.util.Map<String, Object> parameterMap = new java.util.LinkedHashMap<String, Object>(); + if (url.contains("?")) + { + final String parameterString = url.replaceAll(".*\\?", ""); + if (parameterString.trim().length() > 0) + { + final String[] parametersAndValues = parameterString.split("\\s*&\\s*"); + for (final String parameterAndValue : parametersAndValues) + { + final String[] parameters = parameterAndValue.split("\\s*=\\s*"); + final String parameter = parameters[0]; + Object existingValue = parameterMap.get(parameter); + String value = null; + if (parameters.length > 1) + { + value = parameters[1]; + } + if (existingValue != null) + { + if (existingValue instanceof java.util.Collection) + { + ((java.util.Collection)existingValue).add(value); + } + else + { + final java.util.Collection<Object> values = new java.util.ArrayList<Object>(); + values.add(existingValue); + values.add(value); + parameterMap.put(parameter, values); + } + } + else + { + parameterMap.put(parameter, value); + } + } + } + } + return parameterMap; + } + + /** * Uses the converter identified by converterId to convert the value to a String. * @value the value to be converted * @converterId the id of the converter to be used @@ -264,7 +351,8 @@ public static String valueFromConverter( final Object value, final String converterId, - final String componentId){ + final String componentId) + { final javax.faces.context.FacesContext facesContext=javax.faces.context.FacesContext.getCurrentInstance(); final javax.faces.convert.Converter converter = facesContext.getApplication().createConverter(converterId); return converter.getAsString(facesContext, @@ -280,7 +368,8 @@ */ public static String valueFromConverter( final Object value, - final String converterId){ + final String converterId) + { final javax.faces.context.FacesContext facesContext=javax.faces.context.FacesContext.getCurrentInstance(); final javax.faces.convert.Converter converter = facesContext.getApplication().createConverter(converterId); return converter.getAsString(facesContext,null,value); @@ -292,11 +381,15 @@ * @event ActionEvent containing the parameter * @return the parameter value. */ - public static Object getParameterValue(String parameterName, javax.faces.event.ActionEvent event){ - for(Object uiObject : event.getComponent().getChildren()){ - if(uiObject instanceof javax.faces.component.UIParameter){ + public static Object getParameterValue(String parameterName, javax.faces.event.ActionEvent event) + { + for(Object uiObject : event.getComponent().getChildren()) + { + if(uiObject instanceof javax.faces.component.UIParameter) + { final javax.faces.component.UIParameter param = (javax.faces.component.UIParameter)uiObject; - if(param.getName().equals(parameterName)) { + if(param.getName().equals(parameterName)) + { return param.getValue(); } } 1.9 +22 -0 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/utils/FormPopulator.java.vsl Index: FormPopulator.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/utils/FormPopulator.java.vsl,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -r1.8 -r1.9 --- FormPopulator.java.vsl 3 Jun 2008 21:22:02 -0000 1.8 +++ FormPopulator.java.vsl 1 Jul 2008 15:42:42 -0000 1.9 @@ -97,6 +97,28 @@ } /** + * Populates the form from the attributes contained in the request object. + * + * @param form the form to populate. + * @param formatters any date or time formatters. + * @param request the request object from which to populate attributes. + */ + public static final void populateFormFromRequestAttributes(final Object form, final java.util.Map formatters) + { + final javax.faces.context.FacesContext context = javax.faces.context.FacesContext.getCurrentInstance(); + final String[] names = org.andromda.presentation.jsf2.JsfUtils.getAttributeNames(context.getExternalContext().getRequest()); + final java.util.Map<String, Object> attributes = new java.util.LinkedHashMap<String, Object>(); + if (names != null) + { + for (final String name : names) + { + attributes.put(name, org.andromda.presentation.jsf2.JsfUtils.getAttribute(context.getExternalContext().getRequest(), name)); + } + } + populateFormFromPropertyMap(form, formatters, attributes); + } + + /** * Populates the form from the given map of properties. If a matching property is null or an empty * string, then null is placed on the form. * 1.19 +2 -0 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.18 retrieving revision 1.19 diff -u -w -r1.18 -r1.19 --- Controller.java.vsl 3 Jun 2008 21:26:23 -0000 1.18 +++ Controller.java.vsl 1 Jul 2008 15:42:42 -0000 1.19 @@ -63,6 +63,8 @@ // is a reserved name in JSF (the id of a component), therefore we have to unfortunately ignore any availble "id" attribute ${managedBeansPackage}.${formPopulatorName}.populateFormFromPropertyMap( form, form.getDateTimeFormatters(), (java.util.Map)this.getRequestAttribute(ACTION_EVENT_ATTRIBUTES), new String[] {"id"}); + // - populate the form with any request attributes that may match + ${managedBeansPackage}.${formPopulatorName}.populateFormFromRequestAttributes(form, form.getDateTimeFormatters()); // - populate the form with any request parameters that may match ${managedBeansPackage}.${formPopulatorName}.populateFormFromPropertyMap( form, form.getDateTimeFormatters(), this.getContext().getExternalContext().getRequestParameterMap()); |
From: Walter M. <wal...@us...> - 2008-07-15 11:43:32
|
User: walterim Date: 08/07/15 04:42:45 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers/crud Controller.java.vsl andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: re-throw the exceptions, case there isn't a message to be shown Revision Changes Path 1.16 +63 -21 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/controllers/crud/Controller.java.vsl Index: Controller.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/controllers/crud/Controller.java.vsl,v retrieving revision 1.15 retrieving revision 1.16 diff -u -w -r1.15 -r1.16 --- Controller.java.vsl 10 Jul 2008 14:59:52 -0000 1.15 +++ Controller.java.vsl 15 Jul 2008 11:42:44 -0000 1.16 @@ -4,6 +4,9 @@ public abstract class ${manageable.controllerName} { + private static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(${manageable.controllerName}.class); + + static final String CONTROLLER_EXCEPTION = ${manageable.controllerName}.class.getName() + ".exception"; public String init(){ final ${managedBeansPackage}.AdfFacesContextWrapper contextWrapper = new ${managedBeansPackage}.AdfFacesContextWrapper(); @@ -20,13 +23,17 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(!org.apache.commons.lang.StringUtils.isEmpty(messageKey)) + if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ + throw throwable; + } else { this.addErrorMessage(${managedBeansPackage}.Messages.get(messageKey, null)); } } + } catch (final Throwable throwable) { - throwable.printStackTrace(); + this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); + logger.error(throwable); this.addExceptionMessage(throwable); } return "${manageable.viewFullPath}"; @@ -80,13 +87,17 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(!org.apache.commons.lang.StringUtils.isEmpty(messageKey)) + if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ + throw throwable; + } else { this.addErrorMessage(${managedBeansPackage}.Messages.get(messageKey, null)); } } + } catch (final Throwable throwable) { - throwable.printStackTrace(); + this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); + logger.error(throwable); this.addExceptionMessage(throwable); } } @@ -122,13 +133,17 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(!org.apache.commons.lang.StringUtils.isEmpty(messageKey)) + if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ + throw throwable; + } else { this.addErrorMessage(${managedBeansPackage}.Messages.get(messageKey, null)); } } + } catch (final Throwable throwable) { - throwable.printStackTrace(); + this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); + logger.error(throwable); this.addExceptionMessage(throwable); } return null; @@ -154,13 +169,17 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(!org.apache.commons.lang.StringUtils.isEmpty(messageKey)) + if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ + throw throwable; + } else { this.addErrorMessage(${managedBeansPackage}.Messages.get(messageKey, null)); } } + } catch (final Throwable throwable) { - throwable.printStackTrace(); + this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); + logger.error(throwable); this.addExceptionMessage(throwable); } @@ -239,13 +258,17 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(!org.apache.commons.lang.StringUtils.isEmpty(messageKey)) + if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ + throw throwable; + } else { this.addErrorMessage(${managedBeansPackage}.Messages.get(messageKey, null)); } } + } catch (final Throwable throwable) { - throwable.printStackTrace(); + this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); + logger.error(throwable); this.addExceptionMessage(throwable); } return null; @@ -311,13 +334,17 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(!org.apache.commons.lang.StringUtils.isEmpty(messageKey)) + if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ + throw throwable; + } else { this.addErrorMessage(${managedBeansPackage}.Messages.get(messageKey, null)); } } + } catch (final Throwable throwable) { - throwable.printStackTrace(); + this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); + logger.error(throwable); this.addExceptionMessage(throwable); } return null; @@ -339,13 +366,17 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(!org.apache.commons.lang.StringUtils.isEmpty(messageKey)) + if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ + throw throwable; + } else { this.addErrorMessage(${managedBeansPackage}.Messages.get(messageKey, null)); } } + } catch (final Throwable throwable) { - throwable.printStackTrace(); + this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); + logger.error(throwable); this.addExceptionMessage(throwable); } return null; @@ -425,19 +456,23 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(!org.apache.commons.lang.StringUtils.isEmpty(messageKey)) + if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ + throw throwable; + } else { this.addErrorMessage(${managedBeansPackage}.Messages.get(messageKey, null)); } } + } catch (final Throwable throwable) { - throwable.printStackTrace(); + this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); + logger.error(throwable); this.addExceptionMessage(throwable); } } public void doDelete(${idParamClass} ${manageable.manageableIdentifier.name}, ${manageable.formBeanType} form) throws Exception { - ${manageable.manageableServiceAccessorCall}.delete(new Long[]{${manageable.manageableIdentifier.name}}); + ${manageable.manageableServiceAccessorCall}.delete(new ${idParamClass}[]{${manageable.manageableIdentifier.name}}); doSearch(form); } @@ -478,7 +513,8 @@ } catch (final Throwable throwable) { - throwable.printStackTrace(); + this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); + logger.error(throwable); this.addExceptionMessage(throwable); } } @@ -487,9 +523,10 @@ final java.util.Collection<${manageable.valueObjectClassName}> vos; try { vos = (java.util.Collection<${manageable.valueObjectClassName}>)${manageable.manageableServiceAccessorCall}.readAll(); - } catch (Exception e) { - e.printStackTrace(); - this.addExceptionMessage(e); + } catch (final Throwable throwable) { + this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); + logger.error(throwable); + this.addExceptionMessage(throwable); return null; } final java.util.Collection<javax.faces.model.SelectItem> result=new java.util.ArrayList<javax.faces.model.SelectItem>(vos.size()); @@ -669,6 +706,11 @@ } } + protected void setRequestAttribute(final String name, final Object object) + { + ${managedBeansPackage}.JsfUtils.setAttribute(this.getContext().getExternalContext().getRequest(), name, object); + } + // crud-controller merge-point } \ No newline at end of file 1.21 +4 -1 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.20 retrieving revision 1.21 diff -u -w -r1.20 -r1.21 --- Controller.java.vsl 3 Jul 2008 18:27:18 -0000 1.20 +++ Controller.java.vsl 15 Jul 2008 11:42:44 -0000 1.21 @@ -86,10 +86,13 @@ this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); this.setForm("$action.formKey", currentForm, false); final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(!org.apache.commons.lang.StringUtils.isEmpty(messageKey)) + if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ + throw throwable; + } else { this.addErrorMessage(${managedBeansPackage}.Messages.get(messageKey, null)); } } + } catch (final Throwable throwable) { this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); |
From: Chad B. <cwb...@us...> - 2008-07-17 18:43:29
|
User: cwbrandon Date: 08/07/17 11:43:39 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: Add a couple convience methods for getting the current action form instance within the controller Revision Changes Path 1.22 +33 -2 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.21 retrieving revision 1.22 diff -u -w -r1.21 -r1.22 --- Controller.java.vsl 15 Jul 2008 11:42:44 -0000 1.21 +++ Controller.java.vsl 17 Jul 2008 18:43:39 -0000 1.22 @@ -86,9 +86,12 @@ this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); this.setForm("$action.formKey", currentForm, false); final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ + if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)) + { throw throwable; - } else { + } + else + { this.addErrorMessage(${managedBeansPackage}.Messages.get(messageKey, null)); } } @@ -581,6 +584,34 @@ #end /** + * Retrieves the current action form while making sure the form is of the given + * <code>type</code>. If the action form is found, but not of the given type, null will + * be returned. + * + * @param type the type of form to retrieve. + * @return the found form. + */ + protected Object getCurrentActionForm(final Class type) + { + Object form = this.getCurrentActionForm(); + if (!type.isInstance(form)) + { + form = null; + } + return form; + } + + /** + * Retrieves the current action form instance. + * + * @return the current action form instance. + */ + protected Object getCurrentActionForm() + { + return this.resolveVariable("$actionFormKey"); + } + + /** * The name of the request attribute that stores the attributes from the current action event. */ private static final String ACTION_EVENT_ATTRIBUTES = "actionEventAttributes"; |
From: Walter M. <wal...@us...> - 2008-07-22 16:08:19
|
User: walterim Date: 08/07/22 09:08:27 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: Avoids a compile error when the form does not need the population. Revision Changes Path 1.24 +2 -0 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.23 retrieving revision 1.24 diff -u -w -r1.23 -r1.24 --- Controller.java.vsl 21 Jul 2008 22:35:58 -0000 1.23 +++ Controller.java.vsl 22 Jul 2008 16:08:17 -0000 1.24 @@ -76,9 +76,11 @@ final javax.faces.application.FacesMessage.Severity messageSeverity = this.getMaximumMessageSeverity(); if (messageSeverity != null && javax.faces.application.FacesMessage.SEVERITY_ERROR.getOrdinal() <= messageSeverity.getOrdinal()) { +#if ($formPopulationOperationRequired) // - copy any messages to the 'currentForm' org.apache.commons.beanutils.PropertyUtils.setProperty(currentForm, "$formMessagesProperty", org.apache.commons.beanutils.PropertyUtils.getProperty(form, "$formMessagesProperty")); +#end this.setForm("$action.formKey", currentForm, $portlet); } #saveMessages($action " ") |
From: Chad B. <cwb...@us...> - 2008-07-24 21:03:34
|
User: cwbrandon Date: 08/07/24 14:03:44 Modified: andromda-jsf2/src/main/resources/templates/jsf2/utils JsfUtils.java.vsl andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: Add ability to prevent more than one execution of an action upon either refreshs or multiple clicks (only enabled for portlets at this point). Revision Changes Path 1.8 +37 -0 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/utils/JsfUtils.java.vsl Index: JsfUtils.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/utils/JsfUtils.java.vsl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -r1.7 -r1.8 --- JsfUtils.java.vsl 1 Jul 2008 15:42:41 -0000 1.7 +++ JsfUtils.java.vsl 24 Jul 2008 21:03:44 -0000 1.8 @@ -342,6 +342,43 @@ } /** + * Finds the command that uses the action method on the given component. + * + * @param component the component from which to start the search. + * @param actionMethod the action method (i.e. controller.myMethod) + * @return the component or null of not found. + */ + public static javax.faces.component.UICommand findCommand(final javax.faces.component.UIComponent component, final String actionMethod) + { + javax.faces.component.UICommand found = null; + if (component instanceof javax.faces.component.UICommand) + { + final javax.faces.el.MethodBinding action = ((javax.faces.component.UICommand)component).getAction(); + if (action != null) + { + final String methodName = action.getExpressionString() != null ? action.getExpressionString().replaceAll(".\\{|\\}", "") : null; + if (actionMethod.equals(methodName)) + { + found = (javax.faces.component.UICommand)component; + } + } + } + if (found == null && component != null) + { + for (final java.util.Iterator iterator = component.getFacetsAndChildren(); iterator.hasNext();) + { + final javax.faces.component.UIComponent childComponent = (javax.faces.component.UIComponent)iterator.next(); + found = findCommand(childComponent, actionMethod); + if (found != null) + { + break; + } + } + } + return found; + } + + /** * Uses the converter identified by converterId to convert the value to a String. * @value the value to be converted * @converterId the id of the converter to be used 1.25 +136 -44 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.24 retrieving revision 1.25 diff -u -w -r1.24 -r1.25 --- Controller.java.vsl 22 Jul 2008 16:08:17 -0000 1.24 +++ Controller.java.vsl 24 Jul 2008 21:03:44 -0000 1.25 @@ -53,37 +53,51 @@ #if ($formPopulationOperationRequired) final $action.fullyQualifiedFormImplementationName form = this.$action.formImplementationGetter; - - // - pass any properties from the previous form along - ${managedBeansPackage}.${formPopulatorName}.populateForm(currentForm, form); - // - populate the form with any event attributes that may match - // IMPORTANT: it isn't possible to automatically populate any property named "id" since that - // is a reserved name in JSF (the id of a component), therefore we have to unfortunately ignore any availble "id" attribute - ${managedBeansPackage}.${formPopulatorName}.populateFormFromPropertyMap( - form, form.getDateTimeFormatters(), (java.util.Map)this.getRequestAttribute(ACTION_EVENT_ATTRIBUTES), new String[] {"id"}); - // - populate the form with any request attributes that may match - ${managedBeansPackage}.${formPopulatorName}.populateFormFromRequestAttributes(form, form.getDateTimeFormatters(), false); - // - populate the form with any request parameters that may match - ${managedBeansPackage}.${formPopulatorName}.populateFormFromPropertyMap( - form, form.getDateTimeFormatters(), this.getContext().getExternalContext().getRequestParameterMap()); -#end - try - { -#if (!$action.formFields.empty) this.setForm("$action.formKey", form, true); #end - forward = #processTransition($action) - final javax.faces.application.FacesMessage.Severity messageSeverity = this.getMaximumMessageSeverity(); - if (messageSeverity != null && javax.faces.application.FacesMessage.SEVERITY_ERROR.getOrdinal() <= messageSeverity.getOrdinal()) +## - For now we'll just have the transaction checking in portlets (might be worth while to add to standalone at some point) +#set($indent = "") +#if ($portlet) +#set($indent = " ") + if (this.isTransactionValid("${controller.beanName}.${action.triggerName}")) { +#end +#if ($formPopulationOperationRequired) + ${indent}// - pass any properties from the previous form along + ${indent}${managedBeansPackage}.${formPopulatorName}.populateForm(currentForm, form); + ${indent}// - populate the form with any event attributes that may match + ${indent}// IMPORTANT: it isn't possible to automatically populate any property named "id" since that + ${indent}// is a reserved name in JSF (the id of a component), therefore we have to unfortunately ignore any availble "id" attribute + ${indent}${managedBeansPackage}.${formPopulatorName}.populateFormFromPropertyMap( + ${indent}form, form.getDateTimeFormatters(), (java.util.Map)this.getRequestAttribute(ACTION_EVENT_ATTRIBUTES), new String[] {"id"}); + ${indent}// - populate the form with any request attributes that may match + ${indent}${managedBeansPackage}.${formPopulatorName}.populateFormFromRequestAttributes(form, form.getDateTimeFormatters(), false); + ${indent}// - populate the form with any request parameters that may match + ${indent}${managedBeansPackage}.${formPopulatorName}.populateFormFromPropertyMap( + ${indent}form, form.getDateTimeFormatters(), this.getContext().getExternalContext().getRequestParameterMap()); +#end + ${indent}forward = #processTransition($action) +#if ($portlet) + ${indent}this.setLastForward(forward); +#end + ${indent}final javax.faces.application.FacesMessage.Severity messageSeverity = this.getMaximumMessageSeverity(); + ${indent}if (messageSeverity != null && javax.faces.application.FacesMessage.SEVERITY_ERROR.getOrdinal() <= messageSeverity.getOrdinal()) + ${indent}{ #if ($formPopulationOperationRequired) // - copy any messages to the 'currentForm' - org.apache.commons.beanutils.PropertyUtils.setProperty(currentForm, - "$formMessagesProperty", org.apache.commons.beanutils.PropertyUtils.getProperty(form, "$formMessagesProperty")); + ${indent}org.apache.commons.beanutils.PropertyUtils.setProperty(currentForm, + ${indent}"$formMessagesProperty", org.apache.commons.beanutils.PropertyUtils.getProperty(form, "$formMessagesProperty")); #end - this.setForm("$action.formKey", currentForm, $portlet); - } + ${indent}this.setForm("$action.formKey", currentForm, $portlet); + ${indent}} #saveMessages($action " ") +#if ($portlet) + } + else + { + forward = this.getLastForward(); + } +#end #if (!$action.formFields.empty && $action.formResetRequired) form.reset(); #end @@ -92,24 +106,19 @@ { logger.error(throwable); this.setForm("$action.formKey", currentForm, $portlet); - final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)) - { - throw throwable; - } - else + try { + final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); + // - the exception is re-thrown by the exception handler and handled by the catch below if it can't get a messageKey + // (no reason to check for presence of messageKey) this.addErrorMessage(${managedBeansPackage}.Messages.get(messageKey, null)); } - } - } - catch (final Throwable throwable) + catch (Throwable exception) { - this.setForm("$action.formKey", currentForm, $portlet); - this.addExceptionMessage(throwable); // - set the forward to null so that we stay on the current view forward = null; - logger.error(throwable); + this.addExceptionMessage(exception); + } } return forward; #end @@ -734,5 +743,88 @@ this.setPortletMode(javax.portlet.PortletMode.HELP); return "${controller.useCase.portletHelpForwardName}"; } + + /** + * Indicates whether or not the current transaction is valid (i.e. checks + * that the transaction token - if available - is different than what is stored + * for the last transaction token). + * @param actionName the action name. + * @return whether or not transaction is valid + */ + protected boolean isTransactionValid(final String actionName) + { + boolean valid = true; + final String transactionTokeName = this.getTransactionTokenName(); + if (transactionTokeName != null) + { + final javax.faces.component.UIComponent command = ${managedBeansPackage}.JsfUtils.findCommand( + javax.faces.context.FacesContext.getCurrentInstance().getViewRoot(), actionName); + final String currentToken = command != null ? (String)command.getAttributes().get(transactionTokeName) : null; + if (currentToken != null) + { + final String lastToken = (String)this.getSessionAttribute( + transactionTokeName); + valid = !currentToken.equals(lastToken); + if (valid) + { + this.setSessionAttribute( + transactionTokeName, currentToken); + } + } + } + return valid; + } + + /** + * Gets the name of the attribute that stores the transaction token. + * + * @return the name of the transaction token or null if not available. + */ + protected String getTransactionTokenName() + { + String transactionTokenName = null; + try + { + final Class transactionTokenClass = Thread.currentThread().getContextClassLoader().loadClass( + "org.andromda.cartridges.jsf2.component.TransactionToken"); + transactionTokenName = (String)transactionTokenClass.getField("TRANSACTION_TOKEN").get(null); + } + catch (Exception exception) + { + if (logger.isDebugEnabled()) + { + logger.debug(exception); + } + } + return transactionTokenName; + } + + /** + * The variable that stores the last forward. + */ + private static final String LAST_FORWARD = "AndroMDA_LastForward"; + + /** + * Gets the current value of the last forward. + * + * @return the last forward. + */ + private String getLastForward() + { + return (String)this.getSessionAttribute(LAST_FORWARD); + } + + /** + * Sets the current value of the last forward. + * + * @param forward the last forward + */ + private void setLastForward(String forward) + { + if (forward != null) + { + this.setSessionAttribute(LAST_FORWARD, forward); + } + } #end } \ No newline at end of file |
From: Chad B. <cwb...@us...> - 2008-07-24 21:05:38
|
User: cwbrandon Date: 08/07/24 14:05:48 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: add missing indent Revision Changes Path 1.26 +1 -1 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.25 retrieving revision 1.26 diff -u -w -r1.25 -r1.26 --- Controller.java.vsl 24 Jul 2008 21:03:44 -0000 1.25 +++ Controller.java.vsl 24 Jul 2008 21:05:48 -0000 1.26 @@ -84,7 +84,7 @@ ${indent}if (messageSeverity != null && javax.faces.application.FacesMessage.SEVERITY_ERROR.getOrdinal() <= messageSeverity.getOrdinal()) ${indent}{ #if ($formPopulationOperationRequired) - // - copy any messages to the 'currentForm' + ${indent}// - copy any messages to the 'currentForm' ${indent}org.apache.commons.beanutils.PropertyUtils.setProperty(currentForm, ${indent}"$formMessagesProperty", org.apache.commons.beanutils.PropertyUtils.getProperty(form, "$formMessagesProperty")); #end |
From: Walter M. <wal...@us...> - 2008-08-11 18:58:48
|
User: walterim Date: 08/08/11 11:58:58 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vsl Log: Logging only unhandled exceptions. Revision Changes Path 1.27 +3 -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.26 retrieving revision 1.27 diff -u -w -r1.26 -r1.27 --- Controller.java.vsl 24 Jul 2008 21:05:48 -0000 1.26 +++ Controller.java.vsl 11 Aug 2008 18:58:58 -0000 1.27 @@ -104,8 +104,9 @@ } catch (final Throwable throwable) { - logger.error(throwable); this.setForm("$action.formKey", currentForm, $portlet); + // - set the forward to null so that we stay on the current view + forward = null; try { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); @@ -115,8 +116,7 @@ } catch (Throwable exception) { - // - set the forward to null so that we stay on the current view - forward = null; + logger.error(exception); this.addExceptionMessage(exception); } } |