From: Walter M. <wal...@us...> - 2008-06-10 17:35:44
|
User: walterim Date: 08/06/10 10:35:52 Modified: andromda-jsf2/src/main/resources/templates/jsf2/forms/crud Form.java.vsl Log: Changed the support to jsf messages, following the non-crud forms handling methods. Revision Changes Path 1.6 +58 -14 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/forms/crud/Form.java.vsl Index: Form.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/forms/crud/Form.java.vsl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -r1.5 -r1.6 --- Form.java.vsl 7 Mar 2008 16:48:49 -0000 1.5 +++ Form.java.vsl 10 Jun 2008 17:35:52 -0000 1.6 @@ -199,10 +199,13 @@ return this.dateTimeFormatters; } + /** * The current collection of messages stored within this form. */ - private java.util.Map $formMessagesProperty = new java.util.LinkedHashMap(); + private java.util.Map<java.lang.String, javax.faces.application.FacesMessage> $formMessagesProperty = + new java.util.LinkedHashMap<java.lang.String, javax.faces.application.FacesMessage>(); + /** * Adds a {@link javax.faces.application.FacesMessage} message to the current messages @@ -224,43 +227,83 @@ * * @return the current Faces messages. */ - public java.util.Collection get${stringUtils.capitalize($formMessagesProperty)}() + public java.util.Collection<javax.faces.application.FacesMessage> get${stringUtils.capitalize($formMessagesProperty)}() { return this.${formMessagesProperty}.values(); } /** + * Sets the current {@link javax.faces.application.FacesMessage} message + * instances stored within this form. + * + * @param messages a collection of the current Faces messages. + */ + public void set${stringUtils.capitalize($formMessagesProperty)}(final java.util.Collection<javax.faces.application.FacesMessage> messages) + { + if (messages != null) + { + for (final java.util.Iterator iterator = messages.iterator(); iterator.hasNext();) + { + javax.faces.application.FacesMessage jsfMessage = (javax.faces.application.FacesMessage)iterator.next(); + this.${formMessagesProperty}.put(jsfMessage.getDetail(), jsfMessage); + } + } + } + + /** * Clear the current {@link javax.faces.application.FacesMessage} message * instances stored within this form. * */ - public void clearJsfMessages() + public void clear${stringUtils.capitalize($formMessagesProperty)}() { this.${formMessagesProperty}.clear(); } /** - * Gets the current {@link javax.faces.application.FacesMessage} message - * instances stored within this form, as Map. + * 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. * - * @return the current Faces messages. + * @param jsfMessagesTitle the title to use for the messages on the view. */ - public java.util.Map get${stringUtils.capitalize($formMessagesProperty)}Map() + public void set${stringUtils.capitalize($formMessagesProperty)}Title(final String ${formMessagesProperty}Title) { - return this.${formMessagesProperty}; + this.${formMessagesProperty}Title = ${formMessagesProperty}Title; } /** - * Sets the current {@link javax.faces.application.FacesMessage} message - * instances stored within this form, as Map. + * Gets the faces messages title to use. * - * @return the current Faces messages. + * @return the faces messages title. */ - public void set${stringUtils.capitalize($formMessagesProperty)}Map(java.util.Map ${formMessagesProperty}) + public String get${stringUtils.capitalize($formMessagesProperty)}Title() { - this.${formMessagesProperty} = ${formMessagesProperty}; + 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. + */ + public javax.faces.application.FacesMessage.Severity getMaximumMessageSeverity() + { + javax.faces.application.FacesMessage.Severity maxSeverity = null; + for (final javax.faces.application.FacesMessage message : this.get${stringUtils.capitalize($formMessagesProperty)}()) + { + final javax.faces.application.FacesMessage.Severity severity = message.getSeverity(); + if (maxSeverity == null || (severity != null && severity.getOrdinal() > maxSeverity.getOrdinal())) + { + maxSeverity = severity; + } + } + return maxSeverity; + } public void copyFrom($manageable.formBeanClassName otherForm){ #foreach ($field in $manageable.manageableAttributes) @@ -274,7 +317,8 @@ this.set${backingListMethod}(otherForm.get${backingListMethod}()); #end - this.set${stringUtils.capitalize($formMessagesProperty)}Map(get${stringUtils.capitalize($formMessagesProperty)}Map()); + this.set${stringUtils.capitalize($formMessagesProperty)}(otherForm.get${stringUtils.capitalize($formMessagesProperty)}()); + this.set${stringUtils.capitalize($formMessagesProperty)}Title(otherForm.get${stringUtils.capitalize($formMessagesProperty)}Title()); this.setEditState(otherForm.getEditState()); this.setSearchForm(otherForm.getSearchForm()); |