From: Chad B. <cwb...@us...> - 2006-06-20 05:17:41
|
User: cwbrandon Date: 06/06/19 22:17:40 Modified: andromda-jsf/src/templates/jsf/forms Tag: V3_x_HEAD FormImpl.java.vsl andromda-jsf/src/test/expected Tag: V3_x_HEAD cartridge-output.zip andromda-jsf/src/templates/jsf/controllers Tag: V3_x_HEAD Controller.java.vsl Log: prevent loss of form information when exceptions occur. Revision Changes Path No revision No revision 1.14.4.5 +6 -3 cartridges/andromda-jsf/src/templates/jsf/forms/FormImpl.java.vsl Index: FormImpl.java.vsl =================================================================== RCS file: /cvsroot/andromda/cartridges/andromda-jsf/src/templates/jsf/forms/FormImpl.java.vsl,v retrieving revision 1.14.4.4 retrieving revision 1.14.4.5 diff -u -w -r1.14.4.4 -r1.14.4.5 --- FormImpl.java.vsl 29 May 2006 22:51:05 -0000 1.14.4.4 +++ FormImpl.java.vsl 20 Jun 2006 05:17:35 -0000 1.14.4.5 @@ -190,7 +190,7 @@ /** * The current collection of messages stored within this form. */ - private java.util.Collection $formMessagesProperty = new java.util.ArrayList();; + private java.util.Map $formMessagesProperty = new java.util.LinkedHashMap(); /** * Adds a {@link javax.faces.application.FacesMessage} message to the current messages @@ -200,7 +200,10 @@ */ public void add${stringUtils.capitalize($formMessagesProperty)}(javax.faces.application.FacesMessage jsfMessage) { - this.${formMessagesProperty}.add(jsfMessage); + if (jsfMessage != null) + { + this.${formMessagesProperty}.put(jsfMessage.getDetail(), jsfMessage); + } } /** @@ -211,7 +214,7 @@ */ public java.util.Collection get${stringUtils.capitalize($formMessagesProperty)}() { - return this.${formMessagesProperty}; + return this.${formMessagesProperty}.values(); } /** No revision No revision 1.2.2.71 +1200 -1099cartridges/andromda-jsf/src/test/expected/cartridge-output.zip <<Binary file>> No revision No revision 1.11.4.12 +6 -3 cartridges/andromda-jsf/src/templates/jsf/controllers/Controller.java.vsl Index: Controller.java.vsl =================================================================== RCS file: /cvsroot/andromda/cartridges/andromda-jsf/src/templates/jsf/controllers/Controller.java.vsl,v retrieving revision 1.11.4.11 retrieving revision 1.11.4.12 diff -u -w -r1.11.4.11 -r1.11.4.12 --- Controller.java.vsl 31 May 2006 19:08:37 -0000 1.11.4.11 +++ Controller.java.vsl 20 Jun 2006 05:17:39 -0000 1.11.4.12 @@ -44,6 +44,8 @@ return controller.${targetUseCase.controllerAction}(); #else String forward = null; + final ${managedBeansPackage}.AdfFacesContextWrapper contextWrapper = new ${managedBeansPackage}.AdfFacesContextWrapper(); + final Object currentForm = this.resolveVariable("$action.formKey"); try { #if ($formPopulationOperationRequired) @@ -51,7 +53,7 @@ this.$action.formImplementationGetter; // - pass any parameters from the previous form along - ${managedBeansPackage}.${formPopulatorName}.populateForm(this.resolveVariable("$action.formKey"), form); + ${managedBeansPackage}.${formPopulatorName}.populateForm(currentForm, form); // - populate the form with any request parameters that may match this.populateFormFromRequestParameters(form, form.getDateTimeFormatters()); #end @@ -60,7 +62,6 @@ { #end #if (!$action.formFields.empty) - final ${managedBeansPackage}.AdfFacesContextWrapper contextWrapper = new ${managedBeansPackage}.AdfFacesContextWrapper(); contextWrapper.getCurrentInstance().getProcessScope().put("$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); @@ -73,6 +74,7 @@ } catch (final Throwable throwable) { + contextWrapper.getCurrentInstance().getProcessScope().put("$action.formKey", currentForm); final String message = ${managedBeansPackage}.Messages.get( ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable), null); this.addErrorMessage(message); @@ -81,6 +83,7 @@ } catch (final Throwable throwable) { + contextWrapper.getCurrentInstance().getProcessScope().put("$action.formKey", currentForm); this.addExceptionMessage(throwable); // - set the forward to null so that we stay on the current view forward = null; |