From: Walter M. <wal...@us...> - 2007-01-11 17:35:55
|
User: walterim Date: 07/01/11 09:35:53 Modified: andromda-jsf2/src/main/resources/templates/jsf2/flow/crud ViewPopulator.java.vsl andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/crud view.xhtml.vsl andromda-jsf2/src/main/resources/templates/jsf2/controllers/crud Controller.java.vsl Log: Bug fixes Revision Changes Path 1.2 +9 -35 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/flow/crud/ViewPopulator.java.vsl Index: ViewPopulator.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/flow/crud/ViewPopulator.java.vsl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- ViewPopulator.java.vsl 11 Dec 2006 13:43:57 -0000 1.1 +++ ViewPopulator.java.vsl 11 Jan 2007 17:35:53 -0000 1.2 @@ -67,47 +67,22 @@ org.apache.myfaces.trinidad.context.RequestContext adfContext = org.apache.myfaces.trinidad.context.RequestContext.getCurrentInstance(); final javax.faces.el.VariableResolver variableResolver = facesContext.getApplication().getVariableResolver(); - final javax.servlet.http.HttpSession session = ((javax.servlet.http.HttpServletRequest)request).getSession(); - if (form == null) - { - // - first try getting the form from the ADF PageFlowScope + form = adfContext.getPageFlowScope().get("$manageable.formKey"); - // - if the form is null, try getting the current adfContext from the session (and then remove it from the session) - if (form == null) - { - final ${managedBeansPackage}.AdfFacesContextWrapper contextWrapper = - (${managedBeansPackage}.AdfFacesContextWrapper)session.getAttribute("$adfContextAttributeName"); - adfContext = contextWrapper != null ? contextWrapper.getCurrentInstance() : null; - form = adfContext != null ? adfContext.getPageFlowScope().get("$manageable.formKey") : null; + #if ($formSerialization) + final javax.servlet.http.HttpSession session = ((javax.servlet.http.HttpServletRequest)request).getSession(); + // - if the form is still null, see if we can get it from a serialized state if (form == null) { form = ${managedBeansPackage}.JsfUtils.getSerializedForm(session); } #end - if (form != null) - { - // - add the form to the current process scope since it wasn't in the current one to begin with - org.apache.myfaces.trinidad.context.RequestContext.getCurrentInstance().getPageFlowScope().put("$manageable.formKey", form); - } - } - else - { - // - remove the ADF context in the event that its present - session.removeAttribute("AndroMDAADFContext"); - } - } - else - { - // - since the form argument is not null, set it as the "$manageable.formKey" in the PageFlowScope - // (to replace the existing "$manageable.formKey" attribute) - adfContext.getPageFlowScope().put("$manageable.formKey", form); - } try { // - populate the forms - if (form != null) + if (form != null && form instanceof $manageable.formBeanType) { $manageable.formBeanType $manageable.formBeanName = (${manageable.formBeanType})variableResolver.resolveVariable( @@ -115,7 +90,6 @@ "$manageable.formBeanName"); // - populate the $manageable.formBeanName with any parameters from the previous form ${managedBeansPackage}.${formPopulatorName}.populateForm(form, $manageable.formBeanName); - request.setAttribute("$manageable.formBeanName", $manageable.formBeanName); } #if ($formSerialization) // - serialize the form 1.3 +10 -16 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/crud/view.xhtml.vsl Index: view.xhtml.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/crud/view.xhtml.vsl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- view.xhtml.vsl 12 Dec 2006 18:46:32 -0000 1.2 +++ view.xhtml.vsl 11 Jan 2007 17:35:53 -0000 1.3 @@ -89,8 +89,7 @@ ## deixei false em função da discrepância com o uso do \ no javascript#set ($clientValidation = $clientValidation && $manageable.validationRequired) #set ($clientValidation = false) #set ($formValidateName = "validate$stringUtils.capitalize($formName)") - <c:if test="#{!${formName}.editState}"> - <tr:subform id="${formName}_search" enctype="multipart/form-data"> + <tr:subform id="${formName}_search" rendered="#{!${formName}.editState}"> <tr:panelFormLayout> #foreach ($field in $manageable.manageableSearchAttributes) #renderSearchInput($field) @@ -113,16 +112,14 @@ #end <f:facet name="footer"> <tr:panelButtonBar> - <tr:commandButton text="#{messages['action.search']}" action="#{${manageable.controllerBeanName}.search}" accessKey="#{messages['action.search.access.key']}"/> + <tr:commandButton id="searchButton" text="#{messages['action.search']}" action="#{${manageable.controllerBeanName}.search}" accessKey="#{messages['action.search.access.key']}"/> #if ($manageable.create) - <tr:commandButton text="#{messages['action.new']}" action="#{${manageable.controllerBeanName}.startNew}" accessKey="#{messages['action.new.access.key']}"/> + <tr:commandButton id="newButton" text="#{messages['action.new']}" action="#{${manageable.controllerBeanName}.startNew}" accessKey="#{messages['action.new.access.key']}"/> #end </tr:panelButtonBar> </f:facet> </tr:panelFormLayout> - </tr:subform> - <tr:subform> - <tr:table allDetailsEnabled="true" var="row" bandingInterval="1" banding="row" value="#{${formName}.${manageable.listName}}" rows="#{${preferencesBeanName}.maxTableRows}" width="90%"> + <tr:table allDetailsEnabled="true" var="row" bandingInterval="1" banding="row" value="#{${formName}.${manageable.listName}}" rows="#{${preferencesBeanName}.maxTableRows}" width="90%" rendered="#{!empty ${formName}.${manageable.listName}}"> <tr:column width="46px"> <f:facet name="header"> <h:panelGroup><t:graphicImage url="/images/space.gif"/></h:panelGroup> @@ -162,14 +159,11 @@ #end </tr:table> </tr:subform> - </c:if> - <c:if test="#{${formName}.editState}"> - <tr:subform> + <tr:group rendered="#{${formName}.editState}"> <tr:commandLink action="#{${manageable.controllerBeanName}.back}" accessKey="#{messages['action.back.access.key']}"> <t:graphicImage url="/skins/#{${preferencesBeanName}.skin}/images/back.gif" title="#{messages['action.back']}" border="0" /> </tr:commandLink> - </tr:subform> - <tr:subform id="$formName"#if($clientValidation) onsubmit="return $formValidateName(this);"#end enctype="multipart/form-data"> + <tr:subform id="${formName}_edit" #if($clientValidation) onsubmit="return $formValidateName(this);"#end> <tr:panelFormLayout> #foreach ($field in $manageable.manageableAttributes) #if($field.hidden) @@ -204,7 +198,7 @@ </tr:panelFormLayout> <a:validator#if(!$clientValidation) client="false"#end/> </tr:subform> - </c:if> + </tr:group> </ui:define> </ui:composition> 1.2 +52 -185 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.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- Controller.java.vsl 11 Dec 2006 13:43:58 -0000 1.1 +++ Controller.java.vsl 11 Jan 2007 17:35:53 -0000 1.2 @@ -12,24 +12,21 @@ public String init(){ final org.andromda.presentation.jsf2.AdfFacesContextWrapper contextWrapper = new org.andromda.presentation.jsf2.AdfFacesContextWrapper(); - final Object currentForm = this.resolveVariable("form"); try { final ${manageable.formBeanType} form = this.getForm(); - // - populate the form with any request parameters that may match - this.populateFormFromRequestParameters(form, form.getDateTimeFormatters()); try { contextWrapper.getCurrentInstance().getPageFlowScope().put("form", form); - // - add this temporary ADF context to the session so that we can retrieve from a view populator if required - this.getSession(false).setAttribute("AndroMDAADFContext", contextWrapper); + + // - populate the form with any request parameters that may match + this.populateFormFromRequestParameters(form, form.getDateTimeFormatters()); this.doInit(form); } catch (final Throwable throwable) { - contextWrapper.getCurrentInstance().getPageFlowScope().put("form", currentForm); final String message = org.andromda.presentation.jsf2.Messages.get( org.andromda.presentation.jsf2.PatternMatchingExceptionHandler.instance().handleException(throwable), null); throwable.printStackTrace(); @@ -38,55 +35,51 @@ } catch (final Throwable throwable) { - contextWrapper.getCurrentInstance().getPageFlowScope().put("form", currentForm); this.addExceptionMessage(throwable); } - return "${manageable.viewFullPath}"; } public void doInit(${manageable.formBeanType} form) throws Exception { -#if ($manageable.preload) - final java.util.List list = ${manageable.manageableServiceAccessorCall}.readAll(); - - form.${manageable.listSetterName}(list); - -#if ($manageable.maximumListSize > 0) - if (list.size() >= $manageable.maximumListSize) - saveMaxResultsWarning(); - -#end -#if (!$manageable.manageableAssociationEnds.empty) - final java.util.Map backingLists = ${manageable.manageableServiceAccessorCall}.readBackingLists(); -#foreach ($member in $manageable.manageableAssociationEnds) - form.${member.setterName}BackingList((java.util.Collection)backingLists.get("${member.name}")); -#end - -#end +## does not preload the data anymore... testing. +###if ($manageable.preload) +## final java.util.List list = ${manageable.manageableServiceAccessorCall}.readAll(); +## +## form.${manageable.listSetterName}(list); +## +###if ($manageable.maximumListSize > 0) +## if (list.size() >= $manageable.maximumListSize) +## saveMaxResultsWarning(); +## +###end +###if (!$manageable.manageableAssociationEnds.empty) +## final java.util.Map backingLists = ${manageable.manageableServiceAccessorCall}.readBackingLists(); +###foreach ($member in $manageable.manageableAssociationEnds) +## form.${member.setterName}BackingList((java.util.Collection)backingLists.get("${member.name}")); +###end +## +###end +###end form.setEditState(false); -#end } public String load(){ final org.andromda.presentation.jsf2.AdfFacesContextWrapper contextWrapper = new org.andromda.presentation.jsf2.AdfFacesContextWrapper(); - final Object currentForm = this.resolveVariable("form"); try { final ${manageable.formBeanType} form = this.getForm(); - // - populate the form with any request parameters that may match - this.populateFormFromRequestParameters(form, form.getDateTimeFormatters()); try { contextWrapper.getCurrentInstance().getPageFlowScope().put("form", form); - // - add this temporary ADF context to the session so that we can retrieve from a view populator if required - this.getSession(false).setAttribute("AndroMDAADFContext", contextWrapper); + + // - populate the form with any request parameters that may match + this.populateFormFromRequestParameters(form, form.getDateTimeFormatters()); this.doLoad(form); } catch (final Throwable throwable) { - contextWrapper.getCurrentInstance().getPageFlowScope().put("form", currentForm); final String message = org.andromda.presentation.jsf2.Messages.get( org.andromda.presentation.jsf2.PatternMatchingExceptionHandler.instance().handleException(throwable), null); this.addErrorMessage(message); @@ -94,15 +87,14 @@ } catch (final Throwable throwable) { - contextWrapper.getCurrentInstance().getPageFlowScope().put("form", currentForm); this.addExceptionMessage(throwable); } - return null; + return "${manageable.viewFullPath}"; } public void doLoad(${manageable.formBeanType} form) throws Exception { final Object vo= - ${manageable.manageableServiceAccessorCall}.load(form.${manageable.manageableIdentifier.getterName}()); + ${manageable.manageableServiceAccessorCall}.readById(form.${manageable.manageableIdentifier.getterName}()); ## fazer via members org.apache.commons.beanutils.BeanUtils.copyProperties(form,vo); @@ -112,24 +104,21 @@ public String back(){ final org.andromda.presentation.jsf2.AdfFacesContextWrapper contextWrapper = new org.andromda.presentation.jsf2.AdfFacesContextWrapper(); - final Object currentForm = this.resolveVariable("form"); try { final ${manageable.formBeanType} form = this.getForm(); - // - populate the form with any request parameters that may match - this.populateFormFromRequestParameters(form, form.getDateTimeFormatters()); try { contextWrapper.getCurrentInstance().getPageFlowScope().put("form", form); - // - add this temporary ADF context to the session so that we can retrieve from a view populator if required - this.getSession(false).setAttribute("AndroMDAADFContext", contextWrapper); + + // - populate the form with any request parameters that may match + this.populateFormFromRequestParameters(form, form.getDateTimeFormatters()); this.doBack(form); } catch (final Throwable throwable) { - contextWrapper.getCurrentInstance().getPageFlowScope().put("form", currentForm); final String message = org.andromda.presentation.jsf2.Messages.get( org.andromda.presentation.jsf2.PatternMatchingExceptionHandler.instance().handleException(throwable), null); this.addErrorMessage(message); @@ -137,10 +126,9 @@ } catch (final Throwable throwable) { - contextWrapper.getCurrentInstance().getPageFlowScope().put("form", currentForm); this.addExceptionMessage(throwable); } - return null; + return "${manageable.viewFullPath}"; } public void doBack(${manageable.formBeanType} form) throws Exception { @@ -150,24 +138,21 @@ #if ($manageable.create) public String startNew(){ final org.andromda.presentation.jsf2.AdfFacesContextWrapper contextWrapper = new org.andromda.presentation.jsf2.AdfFacesContextWrapper(); - final Object currentForm = this.resolveVariable("form"); try { final ${manageable.formBeanType} form = this.getForm(); - // - populate the form with any request parameters that may match - this.populateFormFromRequestParameters(form, form.getDateTimeFormatters()); try { contextWrapper.getCurrentInstance().getPageFlowScope().put("form", form); - // - add this temporary ADF context to the session so that we can retrieve from a view populator if required - this.getSession(false).setAttribute("AndroMDAADFContext", contextWrapper); + + // - populate the form with any request parameters that may match + this.populateFormFromRequestParameters(form, form.getDateTimeFormatters()); this.doStartNew(form); } catch (final Throwable throwable) { - contextWrapper.getCurrentInstance().getPageFlowScope().put("form", currentForm); final String message = org.andromda.presentation.jsf2.Messages.get( org.andromda.presentation.jsf2.PatternMatchingExceptionHandler.instance().handleException(throwable), null); this.addErrorMessage(message); @@ -175,10 +160,9 @@ } catch (final Throwable throwable) { - contextWrapper.getCurrentInstance().getPageFlowScope().put("form", currentForm); this.addExceptionMessage(throwable); } - return null; + return "${manageable.viewFullPath}"; } public void doStartNew(${manageable.formBeanType} form) throws Exception { @@ -233,24 +217,21 @@ #if ($manageable.create || $manageable.update) public String save(){ final org.andromda.presentation.jsf2.AdfFacesContextWrapper contextWrapper = new org.andromda.presentation.jsf2.AdfFacesContextWrapper(); - final Object currentForm = this.resolveVariable("form"); try { final ${manageable.formBeanType} form = this.getForm(); - // - populate the form with any request parameters that may match - this.populateFormFromRequestParameters(form, form.getDateTimeFormatters()); try { contextWrapper.getCurrentInstance().getPageFlowScope().put("form", form); - // - add this temporary ADF context to the session so that we can retrieve from a view populator if required - this.getSession(false).setAttribute("AndroMDAADFContext", contextWrapper); + + // - populate the form with any request parameters that may match + this.populateFormFromRequestParameters(form, form.getDateTimeFormatters()); this.doSave(form); } catch (final Throwable throwable) { - contextWrapper.getCurrentInstance().getPageFlowScope().put("form", currentForm); final String message = org.andromda.presentation.jsf2.Messages.get( org.andromda.presentation.jsf2.PatternMatchingExceptionHandler.instance().handleException(throwable), null); this.addErrorMessage(message); @@ -258,10 +239,9 @@ } catch (final Throwable throwable) { - contextWrapper.getCurrentInstance().getPageFlowScope().put("form", currentForm); this.addExceptionMessage(throwable); } - return null; + return "${manageable.viewFullPath}"; } public void doSave(${manageable.formBeanType} form) throws Exception { @@ -285,29 +265,27 @@ ); } - doSearch(form); + if(form.${manageable.listGetterName}() != null) //only searches again if there was an old search + doSearch(form); //search again to show the updated item (if it fits the search criteria) } #end public String search(){ final org.andromda.presentation.jsf2.AdfFacesContextWrapper contextWrapper = new org.andromda.presentation.jsf2.AdfFacesContextWrapper(); - final Object currentForm = this.resolveVariable("form"); try { final ${manageable.formBeanType} form = this.getForm(); - // - populate the form with any request parameters that may match - this.populateFormFromRequestParameters(form, form.getDateTimeFormatters()); try { contextWrapper.getCurrentInstance().getPageFlowScope().put("form", form); - // - add this temporary ADF context to the session so that we can retrieve from a view populator if required - this.getSession(false).setAttribute("AndroMDAADFContext", contextWrapper); + + // - populate the form with any request parameters that may match + this.populateFormFromRequestParameters(form, form.getDateTimeFormatters()); this.doSearch(form); } catch (final Throwable throwable) { - contextWrapper.getCurrentInstance().getPageFlowScope().put("form", currentForm); final String message = org.andromda.presentation.jsf2.Messages.get( org.andromda.presentation.jsf2.PatternMatchingExceptionHandler.instance().handleException(throwable), null); this.addErrorMessage(message); @@ -315,7 +293,6 @@ } catch (final Throwable throwable) { - contextWrapper.getCurrentInstance().getPageFlowScope().put("form", currentForm); this.addExceptionMessage(throwable); } return null; @@ -336,6 +313,9 @@ form.${manageable.listSetterName}(list); + if(list.size() == 0) + addWarningMessage(org.andromda.presentation.jsf2.Messages.get("no.entity.found", new Object[]{org.andromda.presentation.jsf2.Messages.get("$manageable.messageKey",null)})); + #if ($manageable.maximumListSize > 0) if (list.size() >= $manageable.maximumListSize) saveMaxResultsWarning(); @@ -354,24 +334,21 @@ #if ($manageable.delete) public String delete(){ final org.andromda.presentation.jsf2.AdfFacesContextWrapper contextWrapper = new org.andromda.presentation.jsf2.AdfFacesContextWrapper(); - final Object currentForm = this.resolveVariable("form"); try { final ${manageable.formBeanType} form = this.getForm(); - // - populate the form with any request parameters that may match - this.populateFormFromRequestParameters(form, form.getDateTimeFormatters()); try { contextWrapper.getCurrentInstance().getPageFlowScope().put("form", form); - // - add this temporary ADF context to the session so that we can retrieve from a view populator if required - this.getSession(false).setAttribute("AndroMDAADFContext", contextWrapper); + + // - populate the form with any request parameters that may match + this.populateFormFromRequestParameters(form, form.getDateTimeFormatters()); this.doDelete(form); } catch (final Throwable throwable) { - contextWrapper.getCurrentInstance().getPageFlowScope().put("form", currentForm); final String message = org.andromda.presentation.jsf2.Messages.get( org.andromda.presentation.jsf2.PatternMatchingExceptionHandler.instance().handleException(throwable), null); this.addErrorMessage(message); @@ -379,7 +356,6 @@ } catch (final Throwable throwable) { - contextWrapper.getCurrentInstance().getPageFlowScope().put("form", currentForm); this.addExceptionMessage(throwable); } return null; @@ -402,10 +378,6 @@ protected ${manageable.formBeanType} getForm() { - // - we do this in the case a button that submitted the form was set to immediate (this should be removed - // when we found a better way to handle this). - final javax.faces.component.UIForm uiForm = this.findForm(this.getContext().getViewRoot(), "${manageable.formBeanName}"); - this.populateComponentInputs(uiForm); return (${manageable.formBeanType})this.resolveVariable("${manageable.formBeanName}"); } @@ -465,28 +437,8 @@ */ protected java.lang.Object resolveVariable(final String name) { - org.apache.myfaces.trinidad.context.RequestContext adfContext = org.apache.myfaces.trinidad.context.RequestContext.getCurrentInstance(); - Object variable = adfContext.getPageFlowScope().get(name); - // - if we couldn't get the variable from the regular ADF context, see if - // the session contains an ADF context with the variable - if (variable == null) - { - final javax.servlet.http.HttpSession session = this.getSession(false); - if (session != null) - { - final ${managedBeansPackage}.AdfFacesContextWrapper contextWrapper = - (${managedBeansPackage}.AdfFacesContextWrapper)session.getAttribute("$adfContextAttributeName"); - adfContext = contextWrapper != null ? contextWrapper.getCurrentInstance() : null; - } - variable = adfContext != null ? adfContext.getPageFlowScope().get(name) : null; - } - // - finally try resolving it in the standard JSF manner - if (variable == null) - { final javax.faces.context.FacesContext context = this.getContext(); - variable = context != null ? context.getApplication().getVariableResolver().resolveVariable(context, name) : null; - } - return variable; + return context.getApplication().getVariableResolver().resolveVariable(context, name); } /** @@ -580,15 +532,6 @@ } /** - * Copies all matching properties from the <code>fromForm</code> to the given - * <code>toForm</code> overridding any previously set values. - */ - protected void copyForm(final Object fromForm, final Object toForm) - { - ${managedBeansPackage}.${formPopulatorName}.populateForm(fromForm, toForm, true); - } - - /** * Populates the form from the given parameters. If the request parameter is null or an empty * string, then null is placed on the form. * @@ -645,80 +588,4 @@ } } - /** - * Finds the form (if one is present) on the given <code>component</code> having the given - * <code>id</code>. - * - * @param component the component to search. - * @param id the id of the form. - * @return the form or null if none was found. - */ - private javax.faces.component.UIForm findForm(javax.faces.component.UIComponent component, String id) - { - javax.faces.component.UIForm foundForm = null; - if (component != null) - { - for (final java.util.Iterator iterator = component.getFacetsAndChildren(); iterator.hasNext();) - { - final Object object = iterator.next(); - if (object instanceof javax.faces.component.UIComponent) - { - final javax.faces.component.UIComponent uiComponent = (javax.faces.component.UIComponent)object; - if (uiComponent instanceof javax.faces.component.UIForm) - { - final javax.faces.component.UIForm form = (javax.faces.component.UIForm)uiComponent; - if (form.getId().equals(id)) - { - foundForm = form; - break; - } - } - foundForm = this.findForm(uiComponent, id); - if (foundForm != null) - { - break; - } - } - } - } - return foundForm; - } - - /** - * If the given <code>component</code> has an child input elements, this method findds - * 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. - * - * @param component the component to populate. - */ - private void populateComponentInputs(javax.faces.component.UIComponent component) - { - if (component != null) - { - for (final java.util.Iterator iterator = component.getFacetsAndChildren(); iterator.hasNext();) - { - final javax.faces.component.UIComponent uiComponent = (javax.faces.component.UIComponent)iterator.next(); - if (uiComponent instanceof javax.faces.component.UIInput) - { - try - { - final javax.faces.component.UIInput input = (javax.faces.component.UIInput)uiComponent; - input.validate(this.getContext()); - input.updateModel(this.getContext()); - } - catch (javax.faces.validator.ValidatorException exception) - { - // - ignore, no value is set (validate will be called by the regular - // JSF lifecycle processing anyway, this is just called to populate the - // local value - } - } - else - { - this.populateComponentInputs(uiComponent); - } - } - } - } - } \ No newline at end of file |
From: Walter M. <wal...@us...> - 2007-01-18 10:11:15
|
User: walterim Date: 07/01/18 02:11:10 Modified: andromda-jsf2/src/main/resources/templates/jsf2/views renderActionFormInput.vm andromda-jsf2/src/main/resources/templates/jsf2/flow/crud ViewPopulator.java.vsl andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/layout layout.xhtml.vsl andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/crud view.xhtml.vsl andromda-jsf2/src/main/resources/templates/jsf2/forms/crud SearchForm.java.vsl Form.java.vsl andromda-jsf2/src/main/resources/templates/jsf2/configuration web.xml.vsl andromda-jsf2/src/main/resources/templates/jsf2/controllers/crud Controller.java.vsl Log: Revision Changes Path 1.3 +2 -1 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/renderActionFormInput.vm Index: renderActionFormInput.vm =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/renderActionFormInput.vm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- renderActionFormInput.vm 11 Dec 2006 13:44:00 -0000 1.2 +++ renderActionFormInput.vm 18 Jan 2007 10:11:07 -0000 1.3 @@ -32,7 +32,7 @@ #end #elseif ($parameter.inputCheckbox) <tr:selectBooleanCheckbox id="$propertyId" value="#{${formValuePropertyName}}" label="#{messages['$parameter.messageKey']}:" required="$parameter.required" readOnly="$parameter.readOnly"/> -#elseif ($parameter.inputSelect || $parameter.type.enumeration) +#elseif ($parameter.inputSelect) #set ($multiSelect = $parameter.type.collectionType || $parameter.type.arrayType) #set ($selectBoxType = "selectOneChoice") #if ($multiSelect) @@ -74,6 +74,7 @@ #set ($selectBoxType = "selectManyListbox") #end <tr:$selectBoxType id="$propertyId" value="#{${formValuePropertyName}}" label="#{messages['$parameter.messageKey']}:" required="$parameter.required" readOnly="$parameter.readOnly"#if ($multiSelect) size="$defaultMultiSelectSize"#else unselectedLabel=""#end> + <f:converter converterId="${parameter.type.fullyQualifiedName}"/> #foreach ($literal in $field.type.literals) #if ($literal.type.stringType)#set ($quote = '')#else#set ($quote = '"')#end #set($literalKey = $literal.name) 1.3 +1 -1 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/flow/crud/ViewPopulator.java.vsl Index: ViewPopulator.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/flow/crud/ViewPopulator.java.vsl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- ViewPopulator.java.vsl 11 Jan 2007 17:35:53 -0000 1.2 +++ ViewPopulator.java.vsl 18 Jan 2007 10:11:07 -0000 1.3 @@ -89,7 +89,7 @@ facesContext, "$manageable.formBeanName"); // - populate the $manageable.formBeanName with any parameters from the previous form - ${managedBeansPackage}.${formPopulatorName}.populateForm(form, $manageable.formBeanName); + ${manageable.formBeanName}.copyFrom((${manageable.formBeanType})form); } #if ($formSerialization) // - serialize the form 1.4 +5 -5 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/layout/layout.xhtml.vsl Index: layout.xhtml.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/layout/layout.xhtml.vsl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -r1.3 -r1.4 --- layout.xhtml.vsl 30 Dec 2006 20:10:22 -0000 1.3 +++ layout.xhtml.vsl 18 Jan 2007 10:11:07 -0000 1.4 @@ -36,21 +36,21 @@ <f:facet name="navigation1"> <tr:navigationPane hint="tabs" level="0" var="item" value="#{menuModel.model}"> <f:facet name="nodeStamp"> - <tr:commandNavigationItem text="#{item.label}" action="#{item.getAction}"/> + <tr:commandNavigationItem text="#{messages[item.label]}" action="#{item.getAction}"/> </f:facet> </tr:navigationPane> </f:facet> <f:facet name="navigation2"> <tr:navigationPane hint="bar" level="1" var="item" value="#{menuModel.model}"> <f:facet name="nodeStamp"> - <tr:commandNavigationItem text="#{item.label}" action="#{item.getAction}"/> + <tr:commandNavigationItem text="#{messages[item.label]}" action="#{item.getAction}"/> </f:facet> </tr:navigationPane> </f:facet> <f:facet name="navigation3"> <tr:navigationPane hint="list" level="2" var="item" value="#{menuModel.model}"> <f:facet name="nodeStamp"> - <tr:commandNavigationItem text="#{item.label}" action="#{item.getAction}"/> + <tr:commandNavigationItem text="#{messages[item.label]}" action="#{item.getAction}"/> </f:facet> </tr:navigationPane> </f:facet> @@ -59,7 +59,7 @@ <f:facet name="navigation3"> <tr:navigationTree var="item" value="#{menuModel.model}"> <f:facet name="nodeStamp"> - <tr:commandNavigationItem text="#{item.label}" action="#{item.getAction}"/> + <tr:commandNavigationItem text="#{messages[item.label]}" action="#{item.getAction}"/> </f:facet> </tr:navigationTree> </f:facet> @@ -77,7 +77,7 @@ <f:facet name="location"> <tr:breadCrumbs var="item" value="#{menuModel.model}"> <f:facet name="nodeStamp"> - <tr:commandNavigationItem text="#{item.label}" action="#{item.getAction}"/> + <tr:commandNavigationItem text="#{messages[item.label]}" action="#{item.getAction}"/> </f:facet> </tr:breadCrumbs> </f:facet> 1.4 +1 -0 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/crud/view.xhtml.vsl Index: view.xhtml.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/crud/view.xhtml.vsl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -r1.3 -r1.4 --- view.xhtml.vsl 11 Jan 2007 17:35:53 -0000 1.3 +++ view.xhtml.vsl 18 Jan 2007 10:11:08 -0000 1.4 @@ -52,6 +52,7 @@ #set ($selectBoxType = "selectManyListbox") #end <tr:$selectBoxType id="$propertyId" value="#{${formValuePropertyName}}" label="#{messages['$parameter.messageKey']}:" required="false" readOnly="false"#if ($multiSelect) size="$defaultMultiSelectSize"#else unselectedLabel=""#end> + <f:converter converterId="${field.type.fullyQualifiedName}"/> #foreach ($literal in $field.type.literals) #if ($literal.type.stringType)#set ($quote = '')#else#set ($quote = '"')#end #set($literalKey = $literal.name) 1.2 +22 -26 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/forms/crud/SearchForm.java.vsl Index: SearchForm.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/forms/crud/SearchForm.java.vsl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- SearchForm.java.vsl 11 Dec 2006 13:44:00 -0000 1.1 +++ SearchForm.java.vsl 18 Jan 2007 10:11:08 -0000 1.2 @@ -23,19 +23,6 @@ implements java.io.Serializable { - public ${manageable.searchFormBeanClassName}(${manageable.formBeanClassName} parent){ -#foreach ($field in $manageable.manageableSearchAttributes) -#if ($field.type.dateType) - java.text.DateFormat ${field.dateFormatter} = new java.text.SimpleDateFormat("$field.format"); -#set ($lenient = !$field.strictDateFormat) - ${field.dateFormatter}.setLenient($lenient); - parent.getDateTimeFormatters().put("search.${field.name}", ${field.dateFormatter}); -#elseif ($field.type.timeType) - parent.getDateTimeFormatters().put("search.${field.name}", new java.text.SimpleDateFormat("$field.format")); -#end -#end - } - #foreach ($field in $manageable.manageableSearchAttributes) #if ($field.type.collectionType) #set ($fieldTypeName = "java.util.List") @@ -92,23 +79,32 @@ this.$member.name = $member.name; } -#end - /** - * Stores any date or time formatters for this form. - */ - private final java.util.Map dateTimeFormatters = new java.util.HashMap(); + private java.util.Collection $member.backingListName; - /** - * Gets any date and time formatters (keyed by property name) - * for this form. - * - * @return the Map containing any date and time formatters. - */ - public java.util.Map getDateTimeFormatters() +#set ($backingListMethod = $stringUtils.capitalize($member.backingListName)) + public java.util.Collection get${backingListMethod}(){ + return ${member.backingListName}; + } + + public void set${backingListMethod}(java.util.Collection ${member.backingListName}){ + this.${member.backingListName} = ${member.backingListName}; + } + + private ${member.type.searchFormBeanType} ${member.name}SearchForm = null;##não pode inicializar direto senão dá loop + + $member.visibility ${member.type.searchFormBeanType} ${member.getterName}SearchForm() { - return this.dateTimeFormatters; + if(this.${member.name}SearchForm == null) + this.${member.name}SearchForm = new ${member.type.searchFormBeanType}(); + return this.${member.name}SearchForm; } + $member.visibility void ${member.setterName}SearchForm(${member.type.searchFormBeanType} ${member.name}SearchForm) + { + this.${member.name}SearchForm = ${member.name}SearchForm; + } +#end + /** * The serial version UID of this class. Needed for serialization. */ 1.2 +60 -3 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.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- Form.java.vsl 11 Dec 2006 13:44:00 -0000 1.1 +++ Form.java.vsl 18 Jan 2007 10:11:08 -0000 1.2 @@ -30,16 +30,18 @@ #set ($lenient = !$field.strictDateFormat) ${field.dateFormatter}.setLenient($lenient); this.dateTimeFormatters.put("${field.name}", ${field.dateFormatter}); + this.dateTimeFormatters.put("searchForm.${field.name}", ${field.dateFormatter}); #elseif ($field.type.timeType) this.dateTimeFormatters.put("${field.name}", new java.text.SimpleDateFormat("$field.format")); + this.dateTimeFormatters.put("searchForm.${field.name}", new java.text.SimpleDateFormat("$field.format")); #end #end // - setup the default java.util.Date.toString() formatter - java.text.DateFormat dateFormatter = new java.text.SimpleDateFormat("EEE MMM dd hh:mm:ss zzz yyyy"); + java.text.DateFormat dateFormatter = new java.text.SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); dateFormatter.setLenient(true); this.dateTimeFormatters.put(null, dateFormatter); - searchForm = new ${manageable.searchFormBeanClassName}(this); + searchForm = new ${manageable.searchFormBeanClassName}(); editState=false; } @@ -60,7 +62,7 @@ return searchForm; } - public void setSearch(${manageable.searchFormBeanClassName} searchForm){ + public void setSearchForm(${manageable.searchFormBeanClassName} searchForm){ this.searchForm = searchForm; } @@ -196,7 +198,19 @@ this.${member.backingListName} = ${member.backingListName}; } + private ${member.type.searchFormBeanType} ${member.name}SearchForm = null;##não pode inicializar direto senão dá loop + $member.visibility ${member.type.searchFormBeanType} ${member.getterName}SearchForm() + { + if(this.${member.name}SearchForm == null) + this.${member.name}SearchForm = new ${member.type.searchFormBeanType}(); + return this.${member.name}SearchForm; + } + + $member.visibility void ${member.setterName}SearchForm(${member.type.searchFormBeanType} ${member.name}SearchForm) + { + this.${member.name}SearchForm = ${member.name}SearchForm; + } #end /** * Stores any date or time formatters for this form. @@ -255,6 +269,49 @@ } /** + * Gets the current {@link javax.faces.application.FacesMessage} message + * instances stored within this form, as Map. + * + * @return the current Faces messages. + */ + public java.util.Map get${stringUtils.capitalize($formMessagesProperty)}Map() + { + return this.${formMessagesProperty}; + } + + /** + * Sets the current {@link javax.faces.application.FacesMessage} message + * instances stored within this form, as Map. + * + * @return the current Faces messages. + */ + public void set${stringUtils.capitalize($formMessagesProperty)}Map(java.util.Map ${formMessagesProperty}) + { + this.${formMessagesProperty} = ${formMessagesProperty}; + } + + + public void copyFrom($manageable.formBeanClassName otherForm){ +#foreach ($field in $manageable.manageableAttributes) + this.${field.setterName}(otherForm.${field.getterName}()); +#set ($backingListMethod = $stringUtils.capitalize($field.backingListName)) + this.set${backingListMethod}(otherForm.get${backingListMethod}()); +#end +#foreach ($member in $manageable.manageableAssociationEnds) + this.${member.setterName}(otherForm.${member.getterName}()); +#set ($backingListMethod = $stringUtils.capitalize($member.backingListName)) + this.set${backingListMethod}(otherForm.get${backingListMethod}()); +#end + + this.set${stringUtils.capitalize($formMessagesProperty)}Map(get${stringUtils.capitalize($formMessagesProperty)}Map()); + + this.setEditState(otherForm.getEditState()); + this.setSearchForm(otherForm.getSearchForm()); + this.${manageable.listSetterName}(otherForm.${manageable.listGetterName}()); + this.setSelectedRows(otherForm.getSelectedRows()); + } + + /** * The serial version UID of this class. Needed for serialization. */ private static final long serialVersionUID = ${manageable.formSerialVersionUID}L; 1.5 +4 -0 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/configuration/web.xml.vsl Index: web.xml.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/configuration/web.xml.vsl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -r1.4 -r1.5 --- web.xml.vsl 11 Jan 2007 17:35:19 -0000 1.4 +++ web.xml.vsl 18 Jan 2007 10:11:09 -0000 1.5 @@ -28,6 +28,10 @@ <param-name>facelets.VIEW_MAPPINGS</param-name> <param-value>*.xhtml</param-value> </context-param> + <context-param> + <param-name>facelets.DEVELOPMENT</param-name> + <param-value>true</param-value> + </context-param> <context-param> <param-name>facelets.LIBRARIES</param-name> 1.3 +9 -7 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.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- Controller.java.vsl 11 Jan 2007 17:35:53 -0000 1.2 +++ Controller.java.vsl 18 Jan 2007 10:11:10 -0000 1.3 @@ -52,14 +52,14 @@ ## saveMaxResultsWarning(); ## ###end -###if (!$manageable.manageableAssociationEnds.empty) -## final java.util.Map backingLists = ${manageable.manageableServiceAccessorCall}.readBackingLists(); -###foreach ($member in $manageable.manageableAssociationEnds) -## form.${member.setterName}BackingList((java.util.Collection)backingLists.get("${member.name}")); -###end -## -###end ###end +#if (!$manageable.manageableAssociationEnds.empty) + final java.util.Map backingLists = ${manageable.manageableServiceAccessorCall}.readBackingLists(); +#foreach ($member in $manageable.manageableAssociationEnds) + form.${member.setterName}BackingList((java.util.Collection)backingLists.get("${member.name}")); +#end + +#end form.setEditState(false); } @@ -267,6 +267,8 @@ if(form.${manageable.listGetterName}() != null) //only searches again if there was an old search doSearch(form); //search again to show the updated item (if it fits the search criteria) + + form.setEditState(false); } #end public String search(){ |
From: Leif J. <le...@it...> - 2007-01-18 10:29:36
|
On Thursday 18 January 2007 11:11, Walter Mourao wrote: > User: walterim > Date: 07/01/18 02:11:10 > > Modified: andromda-jsf2/src/main/resources/templates/jsf2/views > renderActionFormInput.vm > andromda-jsf2/src/main/resources/templates/jsf2/flow/crud > ViewPopulator.java.vsl > > andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/layout > layout.xhtml.vsl > > andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/crud > view.xhtml.vsl > andromda-jsf2/src/main/resources/templates/jsf2/forms/crud > SearchForm.java.vsl Form.java.vsl > > andromda-jsf2/src/main/resources/templates/jsf2/configuration web.xml.vsl > > andromda-jsf2/src/main/resources/templates/jsf2/controllers/crud > Controller.java.vsl > Log: > > > Revision Changes Path > 1.3 +2 -1 > cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/renderActi >onFormInput.vm > > Index: renderActionFormInput.vm > =================================================================== > RCS file: > /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templa >tes/jsf2/views/renderActionFormInput.vm,v retrieving revision 1.2 > retrieving revision 1.3 > diff -u -w -r1.2 -r1.3 > --- renderActionFormInput.vm 11 Dec 2006 13:44:00 -0000 1.2 > +++ renderActionFormInput.vm 18 Jan 2007 10:11:07 -0000 1.3 > @@ -32,7 +32,7 @@ > #end > #elseif ($parameter.inputCheckbox) > <tr:selectBooleanCheckbox id="$propertyId" > value="#{${formValuePropertyName}}" > label="#{messages['$parameter.messageKey']}:" > required="$parameter.required" readOnly="$parameter.readOnly"/> -#elseif > ($parameter.inputSelect || $parameter.type.enumeration) +#elseif > ($parameter.inputSelect) I don't think that was a good idea... I think it will break support for Enumerations Cheers Leif |
From: Chad B. <cha...@gm...> - 2007-01-18 14:47:26
|
Walter, Please add comments for any commits you do, otherwise its hard to figure out what you're doing without looking at the entire commit. Walter Mourao wrote: > User: walterim > Date: 07/01/18 02:11:10 > > Modified: andromda-jsf2/src/main/resources/templates/jsf2/views > renderActionFormInput.vm > andromda-jsf2/src/main/resources/templates/jsf2/flow/crud > ViewPopulator.java.vsl > andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/layout > layout.xhtml.vsl > andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/crud > view.xhtml.vsl > andromda-jsf2/src/main/resources/templates/jsf2/forms/crud > SearchForm.java.vsl Form.java.vsl > andromda-jsf2/src/main/resources/templates/jsf2/configuration > web.xml.vsl > andromda-jsf2/src/main/resources/templates/jsf2/controllers/crud > Controller.java.vsl > Log: > > > Revision Changes Path > 1.3 +2 -1 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/renderActionFormInput.vm > > Index: renderActionFormInput.vm > =================================================================== > RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/renderActionFormInput.vm,v > retrieving revision 1.2 > retrieving revision 1.3 > diff -u -w -r1.2 -r1.3 > --- renderActionFormInput.vm 11 Dec 2006 13:44:00 -0000 1.2 > +++ renderActionFormInput.vm 18 Jan 2007 10:11:07 -0000 1.3 > @@ -32,7 +32,7 @@ > #end > #elseif ($parameter.inputCheckbox) > <tr:selectBooleanCheckbox id="$propertyId" value="#{${formValuePropertyName}}" label="#{messages['$parameter.messageKey']}:" required="$parameter.required" readOnly="$parameter.readOnly"/> > -#elseif ($parameter.inputSelect || $parameter.type.enumeration) > +#elseif ($parameter.inputSelect) > #set ($multiSelect = $parameter.type.collectionType || $parameter.type.arrayType) > #set ($selectBoxType = "selectOneChoice") > #if ($multiSelect) > @@ -74,6 +74,7 @@ > #set ($selectBoxType = "selectManyListbox") > #end > <tr:$selectBoxType id="$propertyId" value="#{${formValuePropertyName}}" label="#{messages['$parameter.messageKey']}:" required="$parameter.required" readOnly="$parameter.readOnly"#if ($multiSelect) size="$defaultMultiSelectSize"#else unselectedLabel=""#end> > + <f:converter converterId="${parameter.type.fullyQualifiedName}"/> > #foreach ($literal in $field.type.literals) > #if ($literal.type.stringType)#set ($quote = '')#else#set ($quote = '"')#end > #set($literalKey = $literal.name) > > > > 1.3 +1 -1 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/flow/crud/ViewPopulator.java.vsl > > Index: ViewPopulator.java.vsl > =================================================================== > RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/flow/crud/ViewPopulator.java.vsl,v > retrieving revision 1.2 > retrieving revision 1.3 > diff -u -w -r1.2 -r1.3 > --- ViewPopulator.java.vsl 11 Jan 2007 17:35:53 -0000 1.2 > +++ ViewPopulator.java.vsl 18 Jan 2007 10:11:07 -0000 1.3 > @@ -89,7 +89,7 @@ > facesContext, > "$manageable.formBeanName"); > // - populate the $manageable.formBeanName with any parameters from the previous form > - ${managedBeansPackage}.${formPopulatorName}.populateForm(form, $manageable.formBeanName); > + ${manageable.formBeanName}.copyFrom((${manageable.formBeanType})form); > } > #if ($formSerialization) > // - serialize the form > > > > 1.4 +5 -5 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/layout/layout.xhtml.vsl > > Index: layout.xhtml.vsl > =================================================================== > RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/layout/layout.xhtml.vsl,v > retrieving revision 1.3 > retrieving revision 1.4 > diff -u -w -r1.3 -r1.4 > --- layout.xhtml.vsl 30 Dec 2006 20:10:22 -0000 1.3 > +++ layout.xhtml.vsl 18 Jan 2007 10:11:07 -0000 1.4 > @@ -36,21 +36,21 @@ > <f:facet name="navigation1"> > <tr:navigationPane hint="tabs" level="0" var="item" value="#{menuModel.model}"> > <f:facet name="nodeStamp"> > - <tr:commandNavigationItem text="#{item.label}" action="#{item.getAction}"/> > + <tr:commandNavigationItem text="#{messages[item.label]}" action="#{item.getAction}"/> > </f:facet> > </tr:navigationPane> > </f:facet> > <f:facet name="navigation2"> > <tr:navigationPane hint="bar" level="1" var="item" value="#{menuModel.model}"> > <f:facet name="nodeStamp"> > - <tr:commandNavigationItem text="#{item.label}" action="#{item.getAction}"/> > + <tr:commandNavigationItem text="#{messages[item.label]}" action="#{item.getAction}"/> > </f:facet> > </tr:navigationPane> > </f:facet> > <f:facet name="navigation3"> > <tr:navigationPane hint="list" level="2" var="item" value="#{menuModel.model}"> > <f:facet name="nodeStamp"> > - <tr:commandNavigationItem text="#{item.label}" action="#{item.getAction}"/> > + <tr:commandNavigationItem text="#{messages[item.label]}" action="#{item.getAction}"/> > </f:facet> > </tr:navigationPane> > </f:facet> > @@ -59,7 +59,7 @@ > <f:facet name="navigation3"> > <tr:navigationTree var="item" value="#{menuModel.model}"> > <f:facet name="nodeStamp"> > - <tr:commandNavigationItem text="#{item.label}" action="#{item.getAction}"/> > + <tr:commandNavigationItem text="#{messages[item.label]}" action="#{item.getAction}"/> > </f:facet> > </tr:navigationTree> > </f:facet> > @@ -77,7 +77,7 @@ > <f:facet name="location"> > <tr:breadCrumbs var="item" value="#{menuModel.model}"> > <f:facet name="nodeStamp"> > - <tr:commandNavigationItem text="#{item.label}" action="#{item.getAction}"/> > + <tr:commandNavigationItem text="#{messages[item.label]}" action="#{item.getAction}"/> > </f:facet> > </tr:breadCrumbs> > </f:facet> > > > > 1.4 +1 -0 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/crud/view.xhtml.vsl > > Index: view.xhtml.vsl > =================================================================== > RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/crud/view.xhtml.vsl,v > retrieving revision 1.3 > retrieving revision 1.4 > diff -u -w -r1.3 -r1.4 > --- view.xhtml.vsl 11 Jan 2007 17:35:53 -0000 1.3 > +++ view.xhtml.vsl 18 Jan 2007 10:11:08 -0000 1.4 > @@ -52,6 +52,7 @@ > #set ($selectBoxType = "selectManyListbox") > #end > <tr:$selectBoxType id="$propertyId" value="#{${formValuePropertyName}}" label="#{messages['$parameter.messageKey']}:" required="false" readOnly="false"#if ($multiSelect) size="$defaultMultiSelectSize"#else unselectedLabel=""#end> > + <f:converter converterId="${field.type.fullyQualifiedName}"/> > #foreach ($literal in $field.type.literals) > #if ($literal.type.stringType)#set ($quote = '')#else#set ($quote = '"')#end > #set($literalKey = $literal.name) > > > > 1.2 +22 -26 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/forms/crud/SearchForm.java.vsl > > Index: SearchForm.java.vsl > =================================================================== > RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/forms/crud/SearchForm.java.vsl,v > retrieving revision 1.1 > retrieving revision 1.2 > diff -u -w -r1.1 -r1.2 > --- SearchForm.java.vsl 11 Dec 2006 13:44:00 -0000 1.1 > +++ SearchForm.java.vsl 18 Jan 2007 10:11:08 -0000 1.2 > @@ -23,19 +23,6 @@ > implements java.io.Serializable > { > > - public ${manageable.searchFormBeanClassName}(${manageable.formBeanClassName} parent){ > -#foreach ($field in $manageable.manageableSearchAttributes) > -#if ($field.type.dateType) > - java.text.DateFormat ${field.dateFormatter} = new java.text.SimpleDateFormat("$field.format"); > -#set ($lenient = !$field.strictDateFormat) > - ${field.dateFormatter}.setLenient($lenient); > - parent.getDateTimeFormatters().put("search.${field.name}", ${field.dateFormatter}); > -#elseif ($field.type.timeType) > - parent.getDateTimeFormatters().put("search.${field.name}", new java.text.SimpleDateFormat("$field.format")); > -#end > -#end > - } > - > #foreach ($field in $manageable.manageableSearchAttributes) > #if ($field.type.collectionType) > #set ($fieldTypeName = "java.util.List") > @@ -92,23 +79,32 @@ > this.$member.name = $member.name; > } > > -#end > - /** > - * Stores any date or time formatters for this form. > - */ > - private final java.util.Map dateTimeFormatters = new java.util.HashMap(); > + private java.util.Collection $member.backingListName; > > - /** > - * Gets any date and time formatters (keyed by property name) > - * for this form. > - * > - * @return the Map containing any date and time formatters. > - */ > - public java.util.Map getDateTimeFormatters() > +#set ($backingListMethod = $stringUtils.capitalize($member.backingListName)) > + public java.util.Collection get${backingListMethod}(){ > + return ${member.backingListName}; > + } > + > + public void set${backingListMethod}(java.util.Collection ${member.backingListName}){ > + this.${member.backingListName} = ${member.backingListName}; > + } > + > + private ${member.type.searchFormBeanType} ${member.name}SearchForm = null;##não pode inicializar direto senão dá loop > + > + $member.visibility ${member.type.searchFormBeanType} ${member.getterName}SearchForm() > { > - return this.dateTimeFormatters; > + if(this.${member.name}SearchForm == null) > + this.${member.name}SearchForm = new ${member.type.searchFormBeanType}(); > + return this.${member.name}SearchForm; > } > > + $member.visibility void ${member.setterName}SearchForm(${member.type.searchFormBeanType} ${member.name}SearchForm) > + { > + this.${member.name}SearchForm = ${member.name}SearchForm; > + } > +#end > + > /** > * The serial version UID of this class. Needed for serialization. > */ > > > > 1.2 +60 -3 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.1 > retrieving revision 1.2 > diff -u -w -r1.1 -r1.2 > --- Form.java.vsl 11 Dec 2006 13:44:00 -0000 1.1 > +++ Form.java.vsl 18 Jan 2007 10:11:08 -0000 1.2 > @@ -30,16 +30,18 @@ > #set ($lenient = !$field.strictDateFormat) > ${field.dateFormatter}.setLenient($lenient); > this.dateTimeFormatters.put("${field.name}", ${field.dateFormatter}); > + this.dateTimeFormatters.put("searchForm.${field.name}", ${field.dateFormatter}); > #elseif ($field.type.timeType) > this.dateTimeFormatters.put("${field.name}", new java.text.SimpleDateFormat("$field.format")); > + this.dateTimeFormatters.put("searchForm.${field.name}", new java.text.SimpleDateFormat("$field.format")); > #end > #end > // - setup the default java.util.Date.toString() formatter > - java.text.DateFormat dateFormatter = new java.text.SimpleDateFormat("EEE MMM dd hh:mm:ss zzz yyyy"); > + java.text.DateFormat dateFormatter = new java.text.SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); > dateFormatter.setLenient(true); > this.dateTimeFormatters.put(null, dateFormatter); > > - searchForm = new ${manageable.searchFormBeanClassName}(this); > + searchForm = new ${manageable.searchFormBeanClassName}(); > > editState=false; > } > @@ -60,7 +62,7 @@ > return searchForm; > } > > - public void setSearch(${manageable.searchFormBeanClassName} searchForm){ > + public void setSearchForm(${manageable.searchFormBeanClassName} searchForm){ > this.searchForm = searchForm; > } > > @@ -196,7 +198,19 @@ > this.${member.backingListName} = ${member.backingListName}; > } > > + private ${member.type.searchFormBeanType} ${member.name}SearchForm = null;##não pode inicializar direto senão dá loop > > + $member.visibility ${member.type.searchFormBeanType} ${member.getterName}SearchForm() > + { > + if(this.${member.name}SearchForm == null) > + this.${member.name}SearchForm = new ${member.type.searchFormBeanType}(); > + return this.${member.name}SearchForm; > + } > + > + $member.visibility void ${member.setterName}SearchForm(${member.type.searchFormBeanType} ${member.name}SearchForm) > + { > + this.${member.name}SearchForm = ${member.name}SearchForm; > + } > #end > /** > * Stores any date or time formatters for this form. > @@ -255,6 +269,49 @@ > } > > /** > + * Gets the current {@link javax.faces.application.FacesMessage} message > + * instances stored within this form, as Map. > + * > + * @return the current Faces messages. > + */ > + public java.util.Map get${stringUtils.capitalize($formMessagesProperty)}Map() > + { > + return this.${formMessagesProperty}; > + } > + > + /** > + * Sets the current {@link javax.faces.application.FacesMessage} message > + * instances stored within this form, as Map. > + * > + * @return the current Faces messages. > + */ > + public void set${stringUtils.capitalize($formMessagesProperty)}Map(java.util.Map ${formMessagesProperty}) > + { > + this.${formMessagesProperty} = ${formMessagesProperty}; > + } > + > + > + public void copyFrom($manageable.formBeanClassName otherForm){ > +#foreach ($field in $manageable.manageableAttributes) > + this.${field.setterName}(otherForm.${field.getterName}()); > +#set ($backingListMethod = $stringUtils.capitalize($field.backingListName)) > + this.set${backingListMethod}(otherForm.get${backingListMethod}()); > +#end > +#foreach ($member in $manageable.manageableAssociationEnds) > + this.${member.setterName}(otherForm.${member.getterName}()); > +#set ($backingListMethod = $stringUtils.capitalize($member.backingListName)) > + this.set${backingListMethod}(otherForm.get${backingListMethod}()); > +#end > + > + this.set${stringUtils.capitalize($formMessagesProperty)}Map(get${stringUtils.capitalize($formMessagesProperty)}Map()); > + > + this.setEditState(otherForm.getEditState()); > + this.setSearchForm(otherForm.getSearchForm()); > + this.${manageable.listSetterName}(otherForm.${manageable.listGetterName}()); > + this.setSelectedRows(otherForm.getSelectedRows()); > + } > + > + /** > * The serial version UID of this class. Needed for serialization. > */ > private static final long serialVersionUID = ${manageable.formSerialVersionUID}L; > > > > 1.5 +4 -0 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/configuration/web.xml.vsl > > Index: web.xml.vsl > =================================================================== > RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/configuration/web.xml.vsl,v > retrieving revision 1.4 > retrieving revision 1.5 > diff -u -w -r1.4 -r1.5 > --- web.xml.vsl 11 Jan 2007 17:35:19 -0000 1.4 > +++ web.xml.vsl 18 Jan 2007 10:11:09 -0000 1.5 > @@ -28,6 +28,10 @@ > <param-name>facelets.VIEW_MAPPINGS</param-name> > <param-value>*.xhtml</param-value> > </context-param> > + <context-param> > + <param-name>facelets.DEVELOPMENT</param-name> > + <param-value>true</param-value> > + </context-param> > > <context-param> > <param-name>facelets.LIBRARIES</param-name> > > > > 1.3 +9 -7 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.2 > retrieving revision 1.3 > diff -u -w -r1.2 -r1.3 > --- Controller.java.vsl 11 Jan 2007 17:35:53 -0000 1.2 > +++ Controller.java.vsl 18 Jan 2007 10:11:10 -0000 1.3 > @@ -52,14 +52,14 @@ > ## saveMaxResultsWarning(); > ## > ###end > -###if (!$manageable.manageableAssociationEnds.empty) > -## final java.util.Map backingLists = ${manageable.manageableServiceAccessorCall}.readBackingLists(); > -###foreach ($member in $manageable.manageableAssociationEnds) > -## form.${member.setterName}BackingList((java.util.Collection)backingLists.get("${member.name}")); > -###end > -## > -###end > ###end > +#if (!$manageable.manageableAssociationEnds.empty) > + final java.util.Map backingLists = ${manageable.manageableServiceAccessorCall}.readBackingLists(); > +#foreach ($member in $manageable.manageableAssociationEnds) > + form.${member.setterName}BackingList((java.util.Collection)backingLists.get("${member.name}")); > +#end > + > +#end > form.setEditState(false); > } > > @@ -267,6 +267,8 @@ > > if(form.${manageable.listGetterName}() != null) //only searches again if there was an old search > doSearch(form); //search again to show the updated item (if it fits the search criteria) > + > + form.setEditState(false); > } > #end > public String search(){ > > > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > ------------------------------------------------------------------------ > > _______________________________________________ > Andromdaplugins-cvs mailing list > And...@li... > https://lists.sourceforge.net/lists/listinfo/andromdaplugins-cvs > |
From: Walter M. <wal...@us...> - 2007-03-04 16:06:54
|
User: walterim Date: 07/03/04 08:06:54 Modified: andromda-jsf2/src/main/resources/templates/jsf2/views renderActionFormInput.vm andromda-jsf2/src/main/resources/templates/jsf2/forms/crud Form.java.vsl andromda-jsf2/src/main/resources/templates/jsf2/controllers/crud Controller.java.vsl Log: File upload support Revision Changes Path 1.5 +3 -1 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/renderActionFormInput.vm Index: renderActionFormInput.vm =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/renderActionFormInput.vm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -r1.4 -r1.5 --- renderActionFormInput.vm 18 Jan 2007 12:37:13 -0000 1.4 +++ renderActionFormInput.vm 4 Mar 2007 16:06:54 -0000 1.5 @@ -67,7 +67,9 @@ </tr:panelLabelAndMessage> #else ##if the widget type is not defined explicit ... -#if($parameter.type.enumeration) +#if($parameter.inputFile) + <tr:inputFile id="$propertyId" value="#{${formValuePropertyName}}" label="#{messages['$parameter.messageKey']}:" required="$parameter.required" columns="50"/> +#elseif($parameter.type.enumeration) #set ($multiSelect = $parameter.type.collectionType || $parameter.type.arrayType) #set ($selectBoxType = "selectOneChoice") #if ($multiSelect) 1.3 +1 -1 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.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- Form.java.vsl 18 Jan 2007 10:11:08 -0000 1.2 +++ Form.java.vsl 4 Mar 2007 16:06:54 -0000 1.3 @@ -94,7 +94,7 @@ #foreach ($field in $manageable.manageableAttributes) #if ($field.type.collectionType) #set ($fieldTypeName = "java.util.List") -#elseif ($field.type.fileType) +#elseif ($field.inputFile) #set ($fieldTypeName = "$fileTypeName") #else #set ($fieldTypeName = $field.type.fullyQualifiedName) 1.5 +8 -0 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.4 retrieving revision 1.5 diff -u -w -r1.4 -r1.5 --- Controller.java.vsl 20 Feb 2007 10:14:55 -0000 1.4 +++ Controller.java.vsl 4 Mar 2007 16:06:54 -0000 1.5 @@ -250,7 +250,11 @@ ${manageable.manageableServiceAccessorCall}.create( #set ($comma = '') #foreach ($member in $manageable.manageableMembers) +#if ($member.inputFile) + ${comma}org.apache.commons.io.IOUtils.toByteArray(form.${member.getterName}().getInputStream()) +#else ${comma}form.${member.getterName}() +#end #set ($comma = ', ') #end ); @@ -259,7 +263,11 @@ ${manageable.manageableServiceAccessorCall}.update( #set ($comma = '') #foreach ($member in $manageable.manageableMembers) +#if ($member.inputFile) + ${comma}org.apache.commons.io.IOUtils.toByteArray(form.${member.getterName}().getInputStream()) +#else ${comma}form.${member.getterName}() +#end #set ($comma = ', ') #end ); |
From: Walter M. <wal...@us...> - 2007-07-01 19:22:40
|
User: walterim Date: 07/07/01 12:22:42 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers/crud Controller.java.vsl Log: Using only not hidden parameters in the search Revision Changes Path 1.7 +15 -1 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.6 retrieving revision 1.7 diff -u -w -r1.6 -r1.7 --- Controller.java.vsl 4 Mar 2007 19:08:34 -0000 1.6 +++ Controller.java.vsl 1 Jul 2007 19:22:42 -0000 1.7 @@ -309,7 +309,21 @@ } public void doSearch(${manageable.formBeanType} form) throws Exception { - final java.util.List list = ${manageable.manageableServiceAccessorCall}.read( + + final java.util.List list; + //if all search fields are null, call readAll() + if( +#set ($and = '') +#foreach ($member in $manageable.manageableMembers) +#if(!$member.hidden)##não está funcionando($manageable.searchable($member)) + ${and} form.getSearchForm().${member.getterName}() == null +#set ($and = '&&') +#end +#end + ) + list=${manageable.manageableServiceAccessorCall}.readAll(); + else + list = ${manageable.manageableServiceAccessorCall}.read( #set ($comma = '') #foreach ($member in $manageable.manageableMembers) #if(!$member.hidden)##não está funcionando($manageable.searchable($member)) |
From: Chad B. <cwb...@us...> - 2007-07-02 17:10:14
|
User: cwbrandon Date: 07/07/02 10:10:15 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers/crud Controller.java.vsl Log: untabify Revision Changes Path 1.8 +108 -108 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.7 retrieving revision 1.8 diff -u -w -r1.7 -r1.8 |
From: Walter M. <wal...@us...> - 2007-10-21 20:06:56
|
User: walterim Date: 07/10/21 13:06:59 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers/crud Controller.java.vsl Log: Avoid compilation error when using fileUpload Revision Changes Path 1.10 +2 -0 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.9 retrieving revision 1.10 diff -u -w -r1.9 -r1.10 --- Controller.java.vsl 9 Sep 2007 11:01:06 -0000 1.9 +++ Controller.java.vsl 21 Oct 2007 20:06:59 -0000 1.10 @@ -98,8 +98,10 @@ ${manageable.manageableServiceAccessorCall}.readById(${manageable.manageableIdentifier.name}); #foreach ($member in $manageable.attributes) +#if(!${member.inputFile}) form.${member.setterName}(vo.${member.getterName}()); #end +#end #foreach ($member in $manageable.manageableAssociationEnds) form.${member.setterName}(vo.${member.getterName}()); #end |
From: Walter M. <wal...@us...> - 2008-07-29 20:27:47
|
User: walterim Date: 08/07/29 13:27:57 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers/crud Controller.java.vsl Log: Corrected a fixed class reference Revision Changes Path 1.19 +2 -2 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.18 retrieving revision 1.19 diff -u -w -r1.18 -r1.19 --- Controller.java.vsl 26 Jul 2008 12:10:48 -0000 1.18 +++ Controller.java.vsl 29 Jul 2008 20:27:56 -0000 1.19 @@ -609,8 +609,8 @@ final javax.servlet.http.HttpSession session = this.getSession(false); if (session != null) { - final org.trinityssm.webapp.AdfFacesContextWrapper contextWrapper = - (org.trinityssm.webapp.AdfFacesContextWrapper)session.getAttribute("AndroMDAADFContext"); + final ${managedBeansPackage}.AdfFacesContextWrapper contextWrapper = + (${managedBeansPackage}.AdfFacesContextWrapper)session.getAttribute("AndroMDAADFContext"); adfContext = contextWrapper != null ? contextWrapper.getCurrentInstance() : null; } variable = adfContext != null ? adfContext.getPageFlowScope().get(name) : null; |
From: Walter M. <wal...@us...> - 2008-08-11 18:59:06
|
User: walterim Date: 08/08/11 11:59:17 Modified: andromda-jsf2/src/main/resources/templates/jsf2/controllers/crud Controller.java.vsl Log: Logging only unhandled exceptions. Revision Changes Path 1.20 +24 -40 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.19 retrieving revision 1.20 diff -u -w -r1.19 -r1.20 --- Controller.java.vsl 29 Jul 2008 20:27:56 -0000 1.19 +++ Controller.java.vsl 11 Aug 2008 18:59:17 -0000 1.20 @@ -21,13 +21,11 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ - throw throwable; - } else { + // - 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) { logger.error(throwable); @@ -84,13 +82,11 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ - throw throwable; - } else { + // - 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) { logger.error(throwable); @@ -129,13 +125,11 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ - throw throwable; - } else { + // - 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) { logger.error(throwable); @@ -164,13 +158,11 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ - throw throwable; - } else { + // - 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) { logger.error(throwable); @@ -252,13 +244,11 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ - throw throwable; - } else { + // - 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) { logger.error(throwable); @@ -327,13 +317,11 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ - throw throwable; - } else { + // - 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) { logger.error(throwable); @@ -358,13 +346,11 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ - throw throwable; - } else { + // - 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) { logger.error(throwable); @@ -447,13 +433,11 @@ catch (final Throwable throwable) { final String messageKey = ${managedBeansPackage}.${patternMatchingExceptionHandler}.instance().handleException(throwable); - if(org.apache.commons.lang.StringUtils.isEmpty(messageKey)){ - throw throwable; - } else { + // - 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) { logger.error(throwable); |
From: Walter M. <wal...@us...> - 2008-09-29 11:25:30
|
User: walterim Date: 08/09/29 04:25:13 Modified: andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/crud view.xhtml.vsl andromda-jsf2/src/main/resources/templates/jsf2/controllers/crud Controller.java.vsl Log: Better control over the ppr behavior in crud. Revision Changes Path 1.16 +3 -3 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/crud/view.xhtml.vsl Index: view.xhtml.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/facelets/crud/view.xhtml.vsl,v retrieving revision 1.15 retrieving revision 1.16 diff -u -w -r1.15 -r1.16 --- view.xhtml.vsl 13 Mar 2008 13:14:13 -0000 1.15 +++ view.xhtml.vsl 29 Sep 2008 11:25:13 -0000 1.16 @@ -151,7 +151,7 @@ <h:panelGroup><tr:image source="/images/space.gif"/></h:panelGroup> </f:facet> <h:panelGroup> - <tr:commandLink id="loadAction" actionListener="#{${manageable.controllerBeanName}.load}" action="${manageable.viewFullPath}" partialSubmit="true" immediate="true"> + <tr:commandLink id="loadAction" actionListener="#{${manageable.controllerBeanName}.load}" partialSubmit="true" immediate="true"> <tr:image source="/skins/#{${preferencesBeanName}.skin}/images/tableLoad.gif" shortDesc="#{messages['action.load']}" inlineStyle="border-style:none" /> <f:param name="${manageable.manageableIdentifier.name}" id="${manageable.manageableIdentifier.name}" value="#{row.${manageable.manageableIdentifier.name}}" /> </tr:commandLink> @@ -262,9 +262,9 @@ <f:facet name="footer"> <tr:panelButtonBar> #if ($manageable.create || !$manageable.update) - <tr:commandButton id="saveAction" text="#{messages['action.save']}" action="#{${manageable.controllerBeanName}.save}" accessKey="#{messages['action.save.access.key']}" /> + <tr:commandButton id="saveAction" text="#{messages['action.save']}" action="#{${manageable.controllerBeanName}.save}" accessKey="#{messages['action.save.access.key']}" partialSubmit="true"/> #if ($manageable.create) - <tr:commandButton id="saveAndNewAction" text="#{messages['action.saveAndNew']}" action="#{${manageable.controllerBeanName}.saveAndNew}" accessKey="#{messages['action.saveAndNew.access.key']}" rendered="#{empty ${formName}.${manageable.manageableIdentifier.name}}"/> + <tr:commandButton id="saveAndNewAction" text="#{messages['action.saveAndNew']}" action="#{${manageable.controllerBeanName}.saveAndNew}" accessKey="#{messages['action.saveAndNew.access.key']}" rendered="#{empty ${formName}.${manageable.manageableIdentifier.name}}" partialSubmit="true"/> #end <tr:commandButton id="cancelAction" text="#{messages['action.cancel']}" action="#{${manageable.controllerBeanName}.cancel}" accessKey="#{messages['action.cancel.access.key']}" immediate="true" partialSubmit="true" /> #end 1.21 +87 -20 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.20 retrieving revision 1.21 diff -u -w -r1.20 -r1.21 --- Controller.java.vsl 11 Aug 2008 18:59:17 -0000 1.20 +++ Controller.java.vsl 29 Sep 2008 11:25:13 -0000 1.21 @@ -6,7 +6,8 @@ { private static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(${manageable.controllerName}.class); - public String init(){ + public String init() + { final ${managedBeansPackage}.AdfFacesContextWrapper contextWrapper = new ${managedBeansPackage}.AdfFacesContextWrapper(); try { @@ -34,7 +35,9 @@ return "${manageable.viewFullPath}"; } - public void doInit(${manageable.formBeanType} form) throws Exception { + public void doInit(${manageable.formBeanType} form) + throws Exception + { #if ($manageable.preload) final java.util.List list = ${manageable.manageableServiceAccessorCall}.readAll(); @@ -67,7 +70,8 @@ #else #set($idParamClass = $manageable.manageableIdentifier.type.name) #end - public void load(javax.faces.event.ActionEvent event){ + public void load(javax.faces.event.ActionEvent event) + { final ${managedBeansPackage}.AdfFacesContextWrapper contextWrapper = new ${managedBeansPackage}.AdfFacesContextWrapper(); try { @@ -86,6 +90,7 @@ // (no reason to check for presence of messageKey) this.addErrorMessage(${managedBeansPackage}.Messages.get(messageKey, null)); } + resetAllEditableComponentsValues(); } catch (final Throwable throwable) { @@ -94,7 +99,9 @@ } } - public void doLoad(${idParamClass} ${manageable.manageableIdentifier.name}, ${manageable.formBeanType} form) throws Exception { + public void doLoad(${idParamClass} ${manageable.manageableIdentifier.name}, ${manageable.formBeanType} form) + throws Exception + { final ${manageable.valueObjectClassName} vo= ${manageable.manageableServiceAccessorCall}.readById(${manageable.manageableIdentifier.name}); @@ -110,7 +117,8 @@ form.setEditState(true); } - public String cancel(){ + public String cancel() + { final ${managedBeansPackage}.AdfFacesContextWrapper contextWrapper = new ${managedBeansPackage}.AdfFacesContextWrapper(); try { @@ -135,15 +143,20 @@ logger.error(throwable); this.addExceptionMessage(throwable); } + + resetAllEditableComponentsValues(); return null; } - public void doCancel(${manageable.formBeanType} form) throws Exception { + public void doCancel(${manageable.formBeanType} form) + throws Exception + { form.setEditState(false); } #if ($manageable.create) - public String startNew(){ + public String startNew() + { final ${managedBeansPackage}.AdfFacesContextWrapper contextWrapper = new ${managedBeansPackage}.AdfFacesContextWrapper(); try { @@ -169,10 +182,13 @@ this.addExceptionMessage(throwable); } - return "${manageable.viewFullPath}"; + resetAllEditableComponentsValues(); + return null; } - public void doStartNew(${manageable.formBeanType} form) throws Exception { + public void doStartNew(${manageable.formBeanType} form) + throws Exception + { ## set all default attribute values #foreach ($member in $manageable.manageableAttributes) @@ -229,7 +245,8 @@ } #end #if ($manageable.create || $manageable.update) - public String save(){ + public String save() + { final ${managedBeansPackage}.AdfFacesContextWrapper contextWrapper = new ${managedBeansPackage}.AdfFacesContextWrapper(); try { @@ -254,10 +271,14 @@ logger.error(throwable); this.addExceptionMessage(throwable); } + + resetAllEditableComponentsValues(); return null; } - public void doSave(${manageable.formBeanType} form) throws Exception { + public void doSave(${manageable.formBeanType} form) + throws Exception + { #if ($manageable.create) if(form.${manageable.manageableIdentifier.getterName}() == null){ @@ -301,7 +322,8 @@ #end #if ($manageable.create) - public String saveAndNew(){ + public String saveAndNew() + { final ${managedBeansPackage}.AdfFacesContextWrapper contextWrapper = new ${managedBeansPackage}.AdfFacesContextWrapper(); try { @@ -327,11 +349,14 @@ logger.error(throwable); this.addExceptionMessage(throwable); } + + resetAllEditableComponentsValues(); return null; } #end - public String search(){ + public String search() + { final ${managedBeansPackage}.AdfFacesContextWrapper contextWrapper = new ${managedBeansPackage}.AdfFacesContextWrapper(); try { @@ -356,10 +381,14 @@ logger.error(throwable); this.addExceptionMessage(throwable); } + + resetAllEditableComponentsValues(); return null; } - public void doSearch(${manageable.formBeanType} form) throws Exception { + public void doSearch(${manageable.formBeanType} form) + throws Exception + { final java.util.List list; //if all search fields are null, call readAll() @@ -418,7 +447,8 @@ #else #set($idParamClass = $manageable.manageableIdentifier.type.name) #end - public void delete(javax.faces.event.ActionEvent event){ + public void delete(javax.faces.event.ActionEvent event) + { final ${managedBeansPackage}.AdfFacesContextWrapper contextWrapper = new ${managedBeansPackage}.AdfFacesContextWrapper(); try { @@ -437,6 +467,7 @@ // (no reason to check for presence of messageKey) this.addErrorMessage(${managedBeansPackage}.Messages.get(messageKey, null)); } + resetAllEditableComponentsValues(); } catch (final Throwable throwable) { @@ -445,7 +476,9 @@ } } - public void doDelete(${idParamClass} ${manageable.manageableIdentifier.name}, ${manageable.formBeanType} form) throws Exception { + public void doDelete(${idParamClass} ${manageable.manageableIdentifier.name}, ${manageable.formBeanType} form) + throws Exception + { ${manageable.manageableServiceAccessorCall}.delete(new ${idParamClass}[]{${manageable.manageableIdentifier.name}}); doSearch(form); @@ -453,12 +486,14 @@ #end #if ($manageable.maximumListSize > 0) - private void saveMaxResultsWarning() { + private void saveMaxResultsWarning() + { addWarningMessage(${managedBeansPackage}.Messages.get("maximum.results.fetched.warning", new Object[]{String.valueOf("${manageable.maximumListSize}")})); } #end - public void fillAutocomplete(javax.faces.event.ActionEvent event){ + public void fillAutocomplete(javax.faces.event.ActionEvent event) + { final javax.faces.context.FacesContext facesContext = this.getContext(); final java.util.Map parameters = facesContext.getExternalContext().getRequestParameterMap(); final Object fieldValue = parameters.get(this.getParameterValue("searchFieldRequestParamName",event)); @@ -492,7 +527,8 @@ } } - public java.util.Collection<javax.faces.model.SelectItem> getAsSelectItems(){ + public java.util.Collection<javax.faces.model.SelectItem> getAsSelectItems() + { final java.util.Collection<${manageable.valueObjectClassName}> vos; try { vos = (java.util.Collection<${manageable.valueObjectClassName}>)${manageable.manageableServiceAccessorCall}.readAll(); @@ -508,15 +544,46 @@ return result; } + /** + * Returns the manageable form + */ protected ${manageable.formBeanType} getForm() { return (${manageable.formBeanType})this.resolveVariable("${manageable.formBeanName}"); } /** + * Force the component to get its value from the backing bean before rendering + */ + private void resetEditableComponentsValues(javax.faces.component.UIComponent uic) + { + if(uic instanceof javax.faces.component.EditableValueHolder) + { + final javax.faces.component.EditableValueHolder evh=(javax.faces.component.EditableValueHolder)uic; + evh.setValue(null); + evh.setSubmittedValue(null); + evh.setLocalValueSet(false); + evh.setValid(true); + } + for(Object component: uic.getChildren()) + { + resetEditableComponentsValues((javax.faces.component.UIComponent)component); + } + } + + /** + * Force all the editable components to get its values from the backing bean before rendering + */ + private void resetAllEditableComponentsValues() + { + resetEditableComponentsValues(this.getContext().getViewRoot()); + } + + /** * Returns an javax.faces.event.FacesEvent parameter value, from its name */ - protected Object getParameterValue(String parameterName, javax.faces.event.FacesEvent event){ + protected Object getParameterValue(String parameterName, javax.faces.event.FacesEvent 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; |