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 and arrays Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Valang and arrays

    Can you please tell me if it is possible, and if so, how to do validation of an array with Valang?

    from the bean:
    {setOfXTableArray[0].fullAmount : ? < 5 : 'fullAmount too big' }

    This works fine for the first element but I want to test all the elements and the number of elements is not fixed.

    ps: to edit the table I am using the spring bind for a collection http://opensource2.atlassian.com/pro.../browse/SPR-52

    thanks,
    Bert.

  • #2
    i need to do the same thing (only against a collection and not an array).

    i was thinking about wrapping the valang validator instance in another validator instance that knows how to loop over the the collection, but i still need to figure out how to correctly reflect which input row is incorrect.

    if i get it working, i'll post back my solution.

    Comment


    • #3
      validation rules at collection level

      I too need this feature. We have several editable tables where we need to enforce field validation across all rows. The lack of support for field validation operations at the collection level is the only thing that's keeping me from using Valang. I hope this feature is added soon as I cant wait to switch to using Valang.

      In addition to single field level validation rules across a collection, it would be very useful if one could specify uniqueness constraints on one or more bean properties. For example in an editable table displaying items, the item name can be edited by the user however no two items in the table should be the same.

      Thanks,
      Sanjiv

      Comment


      • #4
        Guys, why don't you ask your questions on the Spring Modules user mailing list?

        Comment


        • #5
          validate custom list

          I'm also interested in this, I have for example a valiable list of Contacts
          the validation works well for 1 contacts, but I must apply the same validation for the others.

          valang:

          Code:
          { contact[0].name : ? is not blank : 'es required' : 'contactNameEmpty' }
          form:
          Code:
          <@spring.bind "contacts.contact[0].name" />
          name: <input type="text" name="${spring.status.expression}" value="${spring.status.value?default("")}"><@spring.showErrors ", " "error" /><br>
          
          ...
          <@spring.bind "contacts.contact[1].name" />
          name: <input type="text" name="${spring.status.expression}" value="${spring.status.value?default("")}"><@spring.showErrors ", " "error" /><br>
          databinder:
          Code:
          public class ContactsInputBinder {
          
          	private List contacts= LazyList.decorate(new ArrayList(), FactoryUtils.instantiateFactory(Contact.class));
          	
          	public IngresoClienteBinder()
          	{
          	}
          	
          	public List getContacts() {
          		return contacts;
          	}
          
          	public void setContacts(List contacts) {
          		this.contacts= contacts;
          	}
          	
          	
          }

          I don't know beforehand how many contacs there are, so how can I write the validator?

          Comment


          • #6
            Resurrecting this question - is there a way to apply a validation rule to all items in a collection and/or map?

            Comment


            • #7
              i am facing the same problem

              after 4 years of the start of this thread, it seems this is mission impossible.

              Comment


              • #8
                gaga

                I found it's possible, I rewrite the ValangValidator class, and it works perfectly for first level,which means xxx[0].property, but not implement the xxx[i].yy[j].property

                Comment

                Working...
                X