Thursday, June 18, 2015

How to configure a property to use a range of values on xml repository definition (ATG Oracle Commerce)

There are some things that you can do with xml definition file to define a range of values for a property into a repository.

Let's talk about the following scenario, we need a property that will hold the hour of the day which will be used to determine the released hour for a new product.

So we define this as a number property on our ATG xml repository as follows:



Since this is a property to hold the hour of the day, we need to restrict the field to be just from 0 to 23 if we use 24 hours format.

having said this we have some options that ATG does provide OOTB

One is an enumerated the code is as follows:

The other option is a java Class to create a Property Descriptor class that extends GSAPropertyDescriptor in order to restrict the data entered by the user, an example of how to do this can be found here.

Both options are ATG solutions, however there is an easier way to configure this and is not on ATG side, but on the Database as a constraint level that ATG will be forced to use, and that is a simple DB constraint as follows:

And that's it.
We used the Constraint on our last project, since is easier and less invaise in terms of code, feel free to use the option that fit better for your client needs.
Post a Comment