Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
Valang: validating fields where form bean is a Map Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    forgot to say

    spring 2.0.1
    modules 0.7 (d/loaded today)
    Jboss 4.0.5GA

    Cheers,

    Alph

    Comment

    Working...
    X