Results 1 to 2 of 2

Thread: Valang: should <key> not always have to be a bean property?

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Posts
    119

    Default Valang: should <key> not always have to be a bean property?

    (I guess that this is an enhancement request...)

    The valang syntax is:

    { <key> : <predicate_expression> : <message> [: <error_code> [: <args> ]] }

    The docs say:

    "...binds the rule predicates to a key (usually a bean property)"

    I have make a rule that says "either any one of these (3) fields contains data, or the 'anonymous' property == true". It looks like:

    Code:
    { firstName : ((title HAS TEXT) OR (firstName HAS TEXT) OR (surname HAS TEXT)) OR (anonymous == TRUE) : 'NAME!' : 'contactDetailsCheck.specified.title.field.required' }
    This works fine but is rather inelegant.

    My issue is that the <key> part does NOT refer to a bean property. In this case the rule refers to 4 properties.

    I'd LIKE to say:

    Code:
    { allOrPartNameGiven : ((title HAS TEXT) OR (firstName HAS TEXT) OR (surname HAS TEXT)) OR (anonymous == TRUE) : 'NAME!' : 'contactDetailsCheck.specified.name.fields.required' }
    Where 'allOrPartNameGiven' is NOT a bean property.

    At the moment, I get an exception along the lines of:

    Code:
    org.springframework.webflow.engine.ActionExecutionException: Exception thrown executing [AnnotatedAction@1dc7a0d targetAction = org.springframework.webflow.action.FormAction@19a485f, attributes = map['method' -> 'bindAndValidate']] in state 'contactDetailsCheck' of flow 'tceScriptFlow' -- action execution attributes were 'map['method' -> 'bindAndValidate']'; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'nameStuff' of bean class [au.com.sparq.tce.web.ContactDetailsCheckActionObject]: Bean property 'nameStuff' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    Caused by: 
    org.springframework.beans.NotReadablePropertyException: Invalid property 'nameStuff' of bean class [au.com.sparq.tce.web.ContactDetailsCheckActionObject]: Bean property 'nameStuff' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    	at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:510)
    	at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:502)
    Thoughts?

    Cheers,

    Alph

  2. #2
    Join Date
    Aug 2009
    Posts
    1

    Default

    I have this same problem. According to the documentation, the key field should be allowed to be any value, not just a bean field name, but I get an error saying that the Bean property is not readable or has no getter.

    I need to highlight specific field errors on the field that caused the error, so this is a problem for "generic" errors that don't apply to any one field in particular.

    One workaround is to use any non-displayed field in the bean as the key value, but I'd really like to be able to just use a dummy key name so the error does not bind to any particular field.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •