2006/unicorn/WebContent/WEB-INF/resources/templates/includes macros_index.vm,1.5,1.6

Update of /sources/public/2006/unicorn/WebContent/WEB-INF/resources/templates/includes
In directory hutz:/tmp/cvs-serv2618/WebContent/WEB-INF/resources/templates/includes

Modified Files:
	macros_index.vm 
Log Message:
option input values are kept if an error is thrown, only for dropdown and checkboxlist

Index: macros_index.vm
===================================================================
RCS file: /sources/public/2006/unicorn/WebContent/WEB-INF/resources/templates/includes/macros_index.vm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- macros_index.vm	9 Sep 2009 14:32:01 -0000	1.5
+++ macros_index.vm	10 Sep 2009 15:38:41 -0000	1.6
@@ -71,11 +71,17 @@
 
 #macro(createCheckboxList $param)
 #set($defaults = $param.getMapOfDefaultValue())
+#set( $D = '$' )
+#set ($a = "${D}!{param_${param.Name}}")
+#set ($paramMap = "#evaluate ($a)")
 <label><span>$param.getLongName($lang):</span></label> 
 <span class="checkboxlist">
 #foreach ($value in $param.getMapOfValue())
-	<label>$value.getLongName($lang)
-		<input type="checkbox" name="$param.getName()" value="$value.getName()"#if($defaults.containsKey($value.getName())) checked="checked" #end class="option_input" />
+#set ($s = '')
+#if (($paramMap != "" && $paramMap.contains($value.Name)) || ($paramMap == "" && $defaults.containsKey($value.getName()))) #set ($s = 'checked="checked"') #end
+	<label>
+		<input type="checkbox" name="$param.getName()" value="$value.getName()" $s class="option_input" />
+		$value.getLongName($lang)
 	</label>
 #end
 </span>
@@ -83,10 +89,15 @@
 
 #macro(createDropdown $param $multiple)
 #set($defaults = $param.getMapOfDefaultValue())
+#set( $D = '$' )
+#set ($a = "${D}!{param_${param.Name}}")
+#set ($paramValue = "#evaluate ($a)")
 <label><span>$param.getLongName($lang):</span> 
 	<select name="$param.Name" #if($multiple) multiple="multiple" size="3" #end class="option_input">
 #foreach ($value in $param.getMapOfValue())
-		<option value="$value.Name"#if($defaults.containsKey($value.getName())) selected="selected" #end>$value.getLongName($lang)</option>
+#set ($s = '')
+#if (($paramValue != "" && $paramValue.contains($value.Name)) || ($paramValue == "" && $defaults.containsKey($value.getName()))) #set ($s = 'selected="selected"') #end
+		<option value="$value.Name" $s>$value.getLongName($lang)</option>
 #end
 	</select>
 </label> 

Received on Thursday, 10 September 2009 15:38:53 UTC