From: Chad B. <cwb...@us...> - 2008-07-21 22:35:50
|
User: cwbrandon Date: 08/07/21 15:35:58 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers/crud Controller.java.vsl andromda-jsf2/src/main/resources/templates/jsf2/flow ViewPopulator.java.vsl andromda-jsf2/src/main/resources/templates/jsf2/controllers Controller.java.vm Controller.java.vsl Log: Get rid of exception checking in populator (was causing problems and wasn't needed anyway). Set currentForm as actionForm when message severity is equal to or greater than ERROR. Revision Changes Path 1.17 +19 -31 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.16 retrieving revision 1.17 diff -u -w -r1.16 -r1.17 --- Controller.java.vsl 15 Jul 2008 11:42:44 -0000 1.16 +++ Controller.java.vsl 21 Jul 2008 22:35:56 -0000 1.17 @@ -6,8 +6,6 @@ { 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(); try @@ -32,7 +30,6 @@ } catch (final Throwable throwable) { - this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); logger.error(throwable); this.addExceptionMessage(throwable); } @@ -96,7 +93,6 @@ } catch (final Throwable throwable) { - this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); logger.error(throwable); this.addExceptionMessage(throwable); } @@ -142,7 +138,6 @@ } catch (final Throwable throwable) { - this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); logger.error(throwable); this.addExceptionMessage(throwable); } @@ -178,7 +173,6 @@ } catch (final Throwable throwable) { - this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); logger.error(throwable); this.addExceptionMessage(throwable); } @@ -267,7 +261,6 @@ } catch (final Throwable throwable) { - this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); logger.error(throwable); this.addExceptionMessage(throwable); } @@ -343,7 +336,6 @@ } catch (final Throwable throwable) { - this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); logger.error(throwable); this.addExceptionMessage(throwable); } @@ -375,7 +367,6 @@ } catch (final Throwable throwable) { - this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); logger.error(throwable); this.addExceptionMessage(throwable); } @@ -465,7 +456,6 @@ } catch (final Throwable throwable) { - this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); logger.error(throwable); this.addExceptionMessage(throwable); } @@ -513,7 +503,6 @@ } catch (final Throwable throwable) { - this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); logger.error(throwable); this.addExceptionMessage(throwable); } @@ -524,7 +513,6 @@ try { vos = (java.util.Collection<${manageable.valueObjectClassName}>)${manageable.manageableServiceAccessorCall}.readAll(); } catch (final Throwable throwable) { - this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); logger.error(throwable); this.addExceptionMessage(throwable); return null; 1.12 +1 -2 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.11 retrieving revision 1.12 diff -u -w -r1.11 -r1.12 --- ViewPopulator.java.vsl 3 Jul 2008 18:27:17 -0000 1.11 +++ ViewPopulator.java.vsl 21 Jul 2008 22:35:58 -0000 1.12 @@ -156,7 +156,6 @@ 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) { @@ -166,7 +165,7 @@ facesContext, "$action.formBeanName"); // - populate the $action.formBeanName with any parameters from the previous form - ${managedBeansPackage}.${formPopulatorName}.populateForm(form, $action.formBeanName, override); + ${managedBeansPackage}.${formPopulatorName}.populateForm(form, $action.formBeanName, false); request.setAttribute("$action.formBeanName", $action.formBeanName); #end } 1.3 +1 -2 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/controllers/Controller.java.vm Index: Controller.java.vm =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/controllers/Controller.java.vm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- Controller.java.vm 28 May 2008 16:40:45 -0000 1.2 +++ Controller.java.vm 21 Jul 2008 22:35:58 -0000 1.3 @@ -24,9 +24,8 @@ #set($messagesFullyQualifiedName = "${managedBeansPackage}.${messagesFullyQualifiedName}") #end #if ($transition.successMessagesPresent) -${indent}final javax.faces.application.FacesMessage.Severity messageSeverity = this.getMaximumMessageSeverity(); ${indent}// - only add info messages if we don't have any messages or warnings are the maximum severity -${indent}if (messageSeverity == null || messageSeverity.equals(javax.faces.application.FacesMessage.SEVERITY_WARN)) +${indent}else if (messageSeverity == null || messageSeverity.equals(javax.faces.application.FacesMessage.SEVERITY_WARN)) ${indent}{ #foreach ($message in $transition.successMessages.entrySet()) ${indent} this.addInfoMessage(${messagesFullyQualifiedName}.get("$message.key", (Object[])null)); 1.23 +12 -8 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.22 retrieving revision 1.23 diff -u -w -r1.22 -r1.23 --- Controller.java.vsl 17 Jul 2008 18:43:39 -0000 1.22 +++ Controller.java.vsl 21 Jul 2008 22:35:58 -0000 1.23 @@ -10,8 +10,6 @@ { 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(" * ") @@ -75,6 +73,14 @@ 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()) + { + // - copy any messages to the 'currentForm' + org.apache.commons.beanutils.PropertyUtils.setProperty(currentForm, + "$formMessagesProperty", org.apache.commons.beanutils.PropertyUtils.getProperty(form, "$formMessagesProperty")); + this.setForm("$action.formKey", currentForm, $portlet); + } #saveMessages($action " ") #if (!$action.formFields.empty && $action.formResetRequired) form.reset(); @@ -83,8 +89,7 @@ catch (final Throwable throwable) { logger.error(throwable); - this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); - this.setForm("$action.formKey", currentForm, false); + this.setForm("$action.formKey", currentForm, $portlet); final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)) { @@ -98,8 +103,7 @@ } catch (final Throwable throwable) { - this.setRequestAttribute(CONTROLLER_EXCEPTION, throwable); - this.setForm("$action.formKey", currentForm, false); + this.setForm("$action.formKey", currentForm, $portlet); this.addExceptionMessage(throwable); // - set the forward to null so that we stay on the current view forward = null; @@ -376,7 +380,7 @@ */ protected void setMessagesTitle(final String messagesTitle) { - final Object form = this.resolveVariable("form"); + final Object form = this.resolveVariable("$actionFormKey"); if (form != null) { try @@ -401,7 +405,7 @@ protected javax.faces.application.FacesMessage.Severity getMaximumMessageSeverity() { javax.faces.application.FacesMessage.Severity maximumSeverity = null; - final Object form = this.resolveVariable("form"); + final Object form = this.resolveVariable("$actionFormKey"); if (form != null) { try |