1 Attachment(s)
Valang: validating fields where form bean is a Map
Hi.
I suspect that I have stumbled across a limitation of valang...and perhaps a bug.
Background:
I am using an extended AbstractWizardFormBean. Instead of using a single large object as form bean, I use a Map and each individual view uses an object keyed against the view name (ie home' -> HomeFormbean).
This is all working well.
I have been trying to use valang. Server-side validation works great (by the way: good work, guys!). My trouble is with the client side stuff.
Specifically the valang:validate tag.
To see this, look at my (Spring MVC/JSP) form:
Code:
...
<form:form method="post" id="homeForm" commandName="command.map['home']>
<valang:validate commandName="command.map['home']" />
<form:input path="address" />
</form>
...
With rules:
Code:
<bean id="valangAddressCheckValidator"
class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<![CDATA[
{ address ? is not blank : '...' : '...' }
]]>
</value>
</property>
</bean>
When the form is invoked, this gives
Code:
IllegalArgumentException: No valang rules for command 'command.map['home']' were found in the page context.
So I try:
Code:
...
<form:form method="post" id="homeForm" commandName="command.map['home']>
<valang:validate commandName="command" />
</form>
...
With rules:
Code:
<bean id="valangAddressCheckValidator"
class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<![CDATA[
{ map['home'].address : ? is not blank : '...' : '...' }
]]>
</value>
</property>
</bean>
The form is now invoked OK and displayed in the browser.
On submit, however, I get an exception:
Code:
org.springframework.beans.NotReadablePropertyException: Invalid property 'map[home]' of bean class [...HomeFormBean]: Bean property 'map[home]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
I THEN try:
Code:
...
<form:form method="post" id="homeForm" commandName="command.map['home']>
<valang:validate commandName="command" />
<form:input path="address" />
</form>
...
With rules:
Code:
<bean id="valangAddressCheckValidator"
class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<![CDATA[
{ address ? is not blank : '...' : '...' }
]]>
</value>
</property>
</bean>
and this gives:
Code:
NotReadablePropertyException: Invalid property 'map[home].map[home]' of bean class [...ScriptFormController$ScriptFormBean]: Bean property 'map[home].map[home]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
This last attempt seems to have thrown up a bug?
Can anyone give guidance as to whether/how valang can be used in this situation?
Am I going to have this same issue with commons validation?
Attached are a few stack traces.
Thannks in advance for any help/comments!
Cheers,
Alph