|
|
Problem outputting arguments from messageSource
Hi i am new to the spring MVC and have a question i made a validation class that does the following if a error occurs: PHP Code:
errors.rejectValue("selectionA",nbsp;"error.proto.wrong-select",nbsp;newnbsp;Object#91;#93;{"Sentinel"},nbsp;null);
In my messages.properties i added the following line
error.proto.wrong-select=Please select a {0}
If i display the error in two ways, first a global sumup on top of the page of al the errors, and i display the error above the formfield
The error above the error field is as follows: PHP Code:
lt;spring:bindnbsp;path="${path}"gt;lt;c:ifnbsp;test="${status.error}"gt;lt;spannbsp;class="error"gt;lt;c:forEachnbsp;items="${status.errorMessages}"nbsp;var="error"gt;lt;c utnbsp;value="${error}"/gt;lt;/c:forEachgt;lt;/spangt;lt;brnbsp;/gt;lt;/c:ifgt;lt;labelnbsp;for="lt;c utnbsp;value="${status.expression}"/gt;"gt;${name}:nbsp;lt;/labelgt;lt;form:selectnbsp;onchange="${onchange}"nbsp;path="${path}"gt;lt;c:choosegt;lt;c:whennbsp;test="${emptynbsp;list}"gt;lt;form ptionnbsp;value="-1"nbsp;label="--Firstnbsp;selectnbsp;anbsp;${depended}--"nbsp;/gt;lt;/c:whengt;lt;c therwisegt;lt;form ptionnbsp;value="-1"nbsp;label="--Pleasenbsp;Select--"nbsp;/gt;lt;form ptionsnbsp;items="${list}"nbsp;/gt;lt;/c therwisegt;lt;/c:choosegt;lt;/form:selectgt;lt;brnbsp;/gt;lt;/spring:bindgt;
And the global errors: PHP Code:
lt;spring:hasBindErrorsnbsp;name="${name}"gt;lt;pgt;Therenbsp;werenbsp;lt;c utnbsp;value="${errors.errorCount}"/gt;error(s)nbsp;found:lt;/pgt;lt;ulgt;lt;c:forEachnbsp;var="errMsgObj"nbsp;items="${errors.allErrors}"nbsp;gt;lt;ligt;lt;spring:messagenbsp;code="${errMsgObj.code}"nbsp;text="${errMsgObj.defaultMessage}"nbsp;/gt;lt;/ligt;lt;/c:forEachgt;lt;/ulgt;lt;/spring:hasBindErrorsgt;The problem is that the error in global errors doesn't show the object set with the reject.
so it displays :
Please select a {0}
and the error above the field shows:
Please select a Sentinel
what am i doing wrong? Hope somebody can help me.
Regards,
Olaf
*bump*
Anyone an idea how to fix this?
for future references, maybe somebody with the same problems, i fixed the problem, it was the following HP Code:
lt;spring:hasBindErrorsnbsp;name="${name}"gt;lt;fieldsetnbsp;id="errorBox"gt;lt;legendgt;lt;ingnbsp;src="images/caution-e.gif"gt;Errorslt;/legendgt;lt;spangt;Therenbsp;werenbsp;lt;c utnbsp;value="${errors.errorCount}"/gt;error(s)nbsp;found:lt;/spangt;lt;ulgt;lt;c:forEachnbsp;var="errMsgObj"nbsp;items="${errors.allErrors}"nbsp;gt;lt;ligt;lt;spring:messagenbsp;arguments="${errMsgObj.arguments}"nbsp;code="${errMsgObj.code}"nbsp;text="${errMsgObj.defaultMessage}"nbsp;/gt;lt;/ligt;lt;/c:forEachgt;lt;/ulgt;lt;/fieldsetgt;lt;/spring:hasBindErrorsgt;
I needed to pass the arguments to the spring:message tag, otherwise they where not recognized. |
|