Consistent iteration over actualValue in Velocity and FreeMarker macros
This requires consistent exposure of an actualValue in BindStatus, even if no BindingResult available. Issue: SPR-10837
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -90,7 +90,7 @@ public class BindStatus {
|
||||
this.htmlEscape = htmlEscape;
|
||||
|
||||
// determine name of the object and property
|
||||
String beanName = null;
|
||||
String beanName;
|
||||
int dotPos = path.indexOf('.');
|
||||
if (dotPos == -1) {
|
||||
// property not set, only the object itself
|
||||
@@ -124,6 +124,9 @@ public class BindStatus {
|
||||
this.actualValue = this.bindingResult.getRawFieldValue(this.expression);
|
||||
this.editor = this.bindingResult.findEditor(this.expression, null);
|
||||
}
|
||||
else {
|
||||
this.actualValue = this.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -143,8 +146,9 @@ public class BindStatus {
|
||||
}
|
||||
if (this.expression != null && !"*".equals(this.expression) && !this.expression.endsWith("*")) {
|
||||
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(target);
|
||||
this.valueType = bw.getPropertyType(this.expression);
|
||||
this.value = bw.getPropertyValue(this.expression);
|
||||
this.valueType = bw.getPropertyType(this.expression);
|
||||
this.actualValue = this.value;
|
||||
}
|
||||
this.errorCodes = new String[0];
|
||||
this.errorMessages = new String[0];
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
*
|
||||
* @param path the name of the field to bind to
|
||||
* @param attributes any additional attributes for the element (such as class
|
||||
* or CSS styles or size
|
||||
* or CSS styles or size)
|
||||
*
|
||||
*#
|
||||
#macro( springFormInput $path $attributes )
|
||||
@@ -124,7 +124,7 @@
|
||||
*
|
||||
* @param path the name of the field to bind to
|
||||
* @param attributes any additional attributes for the element (such as class
|
||||
* or CSS styles or size
|
||||
* or CSS styles or size)
|
||||
*
|
||||
*#
|
||||
#macro( springFormPasswordInput $path $attributes )
|
||||
@@ -140,7 +140,7 @@
|
||||
*
|
||||
* @param path the name of the field to bind to
|
||||
* @param attributes any additional attributes for the element (such as class
|
||||
* or CSS styles or size
|
||||
* or CSS styles or size)
|
||||
*
|
||||
*#
|
||||
#macro( springFormHiddenInput $path $attributes )
|
||||
@@ -156,7 +156,7 @@
|
||||
*
|
||||
* @param path the name of the field to bind to
|
||||
* @param attributes any additional attributes for the element (such as class
|
||||
* or CSS styles or size
|
||||
* or CSS styles or size)
|
||||
*
|
||||
*#
|
||||
#macro( springFormTextarea $path $attributes )
|
||||
@@ -178,16 +178,14 @@
|
||||
* @param path the name of the field to bind to
|
||||
* @param options a map (value=label) of all the available options
|
||||
* @param attributes any additional attributes for the element (such as class
|
||||
* or CSS styles or size
|
||||
* or CSS styles or size)
|
||||
*#
|
||||
#macro( springFormSingleSelect $path $options $attributes )
|
||||
#springBind($path)
|
||||
<select id="${status.expression}" name="${status.expression}" ${attributes}>
|
||||
#foreach($option in $options.keySet())
|
||||
<option value="${option}"
|
||||
#if("$!status.value" == "$option")
|
||||
selected="selected"
|
||||
#end>
|
||||
#if("$!status.value" == "$option") selected="selected" #end>
|
||||
${options.get($option)}</option>
|
||||
#end
|
||||
</select>
|
||||
@@ -202,17 +200,15 @@
|
||||
* @param path the name of the field to bind to
|
||||
* @param options a map (value=label) of all the available options
|
||||
* @param attributes any additional attributes for the element (such as class
|
||||
* or CSS styles or size
|
||||
* or CSS styles or size)
|
||||
*#
|
||||
#macro( springFormMultiSelect $path $options $attributes )
|
||||
#springBind($path)
|
||||
<select multiple="multiple" id="${status.expression}" name="${status.expression}" ${attributes}>
|
||||
#foreach($option in $options.keySet())
|
||||
<option value="${option}"
|
||||
#foreach($item in $status.value)
|
||||
#if($item == $option)
|
||||
selected="selected"
|
||||
#end
|
||||
#foreach($item in $status.actualValue)
|
||||
#if($item == $option) selected="selected" #end
|
||||
#end
|
||||
>${options.get($option)}</option>
|
||||
#end
|
||||
@@ -229,15 +225,13 @@
|
||||
* @param separator the html tag or other character list that should be used to
|
||||
* separate each option. Typically ' ' or '<br>'
|
||||
* @param attributes any additional attributes for the element (such as class
|
||||
* or CSS styles or size
|
||||
* or CSS styles or size)
|
||||
*#
|
||||
#macro( springFormRadioButtons $path $options $separator $attributes )
|
||||
#springBind($path)
|
||||
#foreach($option in $options.keySet())
|
||||
<input type="radio" name="${status.expression}" value="${option}"
|
||||
#if("$!status.value" == "$option")
|
||||
checked="checked"
|
||||
#end
|
||||
#if("$!status.value" == "$option") checked="checked" #end
|
||||
${attributes}
|
||||
#springCloseTag()
|
||||
${options.get($option)} ${separator}
|
||||
@@ -252,15 +246,15 @@
|
||||
* @param path the name of the field to bind to
|
||||
* @param options a map (value=label) of all the available options
|
||||
* @param separator the html tag or other character list that should be used to
|
||||
* separate each option. Typically ' ' or '<br>'
|
||||
* separate each option. Typically ' ' or '<br>'.
|
||||
* @param attributes any additional attributes for the element (such as class
|
||||
* or CSS styles or size
|
||||
* or CSS styles or size)
|
||||
*#
|
||||
#macro( springFormCheckboxes $path $options $separator $attributes )
|
||||
#springBind($path)
|
||||
#foreach($option in $options.keySet())
|
||||
<input type="checkbox" name="${status.expression}" value="${option}"
|
||||
#foreach($item in $status.value)
|
||||
#foreach($item in $status.actualValue)
|
||||
#if($item == $option) checked="checked" #end
|
||||
#end
|
||||
${attributes} #springCloseTag()
|
||||
@@ -276,7 +270,7 @@
|
||||
*
|
||||
* @param path the name of the field to bind to
|
||||
* @param attributes any additional attributes for the element (such as class
|
||||
* or CSS styles or size
|
||||
* or CSS styles or size)
|
||||
*#
|
||||
#macro( springFormCheckbox $path $attributes )
|
||||
#springBind($path)
|
||||
|
||||
Reference in New Issue
Block a user