|
From: Chad B. <cwb...@us...> - 2007-09-07 16:51:20
|
User: cwbrandon
Date: 07/09/07 09:42:48
Modified: andromda-jsf2/src/main/resources/templates/jsf2/configuration
validation.xml.vm
andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/metafacades
JSFManageableEntityAttributeLogicImpl.java
JSFAttributeLogicImpl.java
JSFParameterLogicImpl.java
andromda-jsf2/src/main/uml JSFMetafacadeModel.xml.zip
andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2
JSFUtils.java
Log:
Fix generation of validation.xml for complex objects (wasn't using the nested name for the field name)
Revision Changes Path
1.3 +6 -1 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/configuration/validation.xml.vm
Index: validation.xml.vm
===================================================================
RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/configuration/validation.xml.vm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- validation.xml.vm 11 Dec 2006 13:43:57 -0000 1.2
+++ validation.xml.vm 7 Sep 2007 16:42:48 -0000 1.3
@@ -22,7 +22,12 @@
#end
#end
#end
-#foreach ($validatorVar in $field.validatorVars)
+#if ($ownerParameter.complex)
+#set ($validatorVars = $field.getValidatorVars($ownerParameter))
+#else
+#set ($validatorVars = $field.validatorVars)
+#end
+#foreach ($validatorVar in $validatorVars)
#set ($varValue = $validatorVar.get(1))
#if ($field.equalValidator)
#set ($varValue = "${action.formBeanName}:${varValue}")
1.3 +2 -5 cartridges/andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/metafacades/JSFManageableEntityAttributeLogicImpl.java
Index: JSFManageableEntityAttributeLogicImpl.java
===================================================================
RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/metafacades/JSFManageableEntityAttributeLogicImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- JSFManageableEntityAttributeLogicImpl.java 20 Feb 2007 10:12:05 -0000 1.2
+++ JSFManageableEntityAttributeLogicImpl.java 7 Sep 2007 16:42:48 -0000 1.3
@@ -226,7 +226,8 @@
{
return JSFUtils.getValidatorVars(
((ModelElementFacade)this.THIS()),
- this.getType());
+ this.getType(),
+ null);
}
/**
@@ -561,8 +562,4 @@
return dateFormat;
}
-
-
-
-
}
\ No newline at end of file
1.2 +6 -5 cartridges/andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/metafacades/JSFAttributeLogicImpl.java
Index: JSFAttributeLogicImpl.java
===================================================================
RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/metafacades/JSFAttributeLogicImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- JSFAttributeLogicImpl.java 5 Dec 2006 19:39:09 -0000 1.1
+++ JSFAttributeLogicImpl.java 7 Sep 2007 16:42:48 -0000 1.2
@@ -393,13 +393,14 @@
}
/**
- * @see org.andromda.cartridges.jsf2.metafacades.JSFParameter#getValidatorVars()
+ * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#getValidatorVars(JSFParameter)
*/
- protected java.util.Collection handleGetValidatorVars()
+ protected Collection handleGetValidatorVars(JSFParameter ownerParameter)
{
return JSFUtils.getValidatorVars(
((ModelElementFacade)this.THIS()),
- this.getType());
+ this.getType(),
+ ownerParameter);
}
/**
1.2 +6 -5 cartridges/andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/metafacades/JSFParameterLogicImpl.java
Index: JSFParameterLogicImpl.java
===================================================================
RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/metafacades/JSFParameterLogicImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- JSFParameterLogicImpl.java 5 Dec 2006 19:39:09 -0000 1.1
+++ JSFParameterLogicImpl.java 7 Sep 2007 16:42:48 -0000 1.2
@@ -842,7 +842,8 @@
{
return JSFUtils.getValidatorVars(
((ModelElementFacade)this.THIS()),
- this.getType());
+ this.getType(),
+ null);
}
/**
1.8 +193 -178 cartridges/andromda-jsf2/src/main/uml/JSFMetafacadeModel.xml.zip
<<Binary file>>
1.4 +46 -26 cartridges/andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/JSFUtils.java
Index: JSFUtils.java
===================================================================
RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/JSFUtils.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- JSFUtils.java 3 Sep 2007 00:24:31 -0000 1.3
+++ JSFUtils.java 7 Sep 2007 16:42:48 -0000 1.4
@@ -478,6 +478,28 @@
}
/**
+ * Retrieves the "equal" value from the given element (if one is present).
+ *
+ * @param element the element from which to retrieve the equal value.
+ * @param ownerParameter the optional owner parameter (specified if the element is an attribute).
+ * @return the "equal" value.
+ */
+ public static java.lang.String getEqual(final ModelElementFacade element, final ParameterFacade ownerParameter)
+ {
+ String equal = null;
+ if (element != null)
+ {
+ final Object value = element.findTaggedValue(JSFProfile.TAGGEDVALUE_INPUT_EQUAL);
+ equal = value == null ? null : value.toString();
+ if (StringUtils.isNotBlank(equal) && ownerParameter != null)
+ {
+ equal = ownerParameter.getName() + StringUtilsHelper.upperCamelCaseName(equal);
+ }
+ }
+ return equal;
+ }
+
+ /**
* Retrieves the "validwhen" value from the given element (if one is present).
*
* @param element the element from which to retrieve the validwhen value.
@@ -691,11 +713,13 @@
*
* @param element the element from which to retrieve the variables
* @param type the type of the element.
+ * @param ownerParameter the optional owner parameter (if the element is an attribute for example).
* @return the collection of validator variables.
*/
public static java.util.Collection getValidatorVars(
final ModelElementFacade element,
- final ClassifierFacade type)
+ final ClassifierFacade type,
+ final ParameterFacade ownerParameter)
{
final Map vars = new LinkedHashMap();
if (element != null && type != null)
@@ -755,14 +779,10 @@
{
inputFormat = ((JSFParameter)element).getFormat();
}
- else if (element instanceof JSFManageableEntityAttribute)
- {
- inputFormat = ((JSFManageableEntityAttribute)element).getFormat();
- }
else
{
throw new RuntimeException("'element' is an invalid type, it must be either an instance of '" +
- JSFAttribute.class.getName() + "' or '" +JSFManageableEntityAttribute.class.getName() + "' or '" + JSFParameter.class.getName() + "'");
+ JSFAttribute.class.getName() + "' or '" + JSFParameter.class.getName() + "'");
}
if (JSFUtils.isDate(type))
{
@@ -798,7 +818,7 @@
Arrays.asList(new Object[] {test, validWhen}));
}
- final String equal = JSFUtils.getEqual(element);
+ final String equal = JSFUtils.getEqual(element, ownerParameter);
if (equal != null)
{
final String fieldName = "fieldName";
|