Announcement Announcement Module
Collapse
No announcement yet.
property-placeholder and validation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • property-placeholder and validation

    Hi,

    I use the <contextroperty-placeholder location=".........." /> XML element to retrieve properties from a file. I would like to know if there is a mechanism provided by Spring to validate the values retrieved from the file?
    If no, what is the best practice to implement this requirement?

    Thanks,
    Mickael

  • #2
    No there isn't.. And also the property-placeholder isn't to be used to retrieve properties and use them later on as a properties object. For that there is the properties element in the util namespace. But that has no validation logic either.

    What is it you want to validate?!

    Comment


    • #3
      Thanks for your answer Marten, I always used property-placeholder to retrieve properties from a file until now and it always worked. It's also what I've always seen on the web. I've never heard about the <utilroperties> element. What is the difference between them?

      I want to validate the properties retrieved from the file. For example, checking that a property that should be an integer is really an integer. Basic validation rules...

      Thanks

      Comment


      • #4
        The property-placeholder is used to read a properties file and then replace the placeholders in the context it is not to be used to read properties and then use the properties object (which is hard to access) as is.

        The logic you want is pretty custom so I guess you would have to write something yourself (probably extending the PropertiesFactoryBean and add the logic in there). Spring will blow up when you try to replace a property which should be an integer and which is a string for instance.

        Comment

        Working...
        X