AnsweredAssumed Answered

Programmatic output of a property's constraints

Question asked by burriad on Apr 16, 2009
Latest reply on Apr 16, 2009 by burriad

I am looking for a way to programmatically retrieve the values of a list constraint. The example below tries to do exactly this, but does not work as expected.

public List<SelectItem> getStatusValues() {
   PropertyDefinition pd = getDictionaryService().getProperty(MyModel.STATUS_PROP);
   List<SelectItem> result = new ArrayList<SelectItem>();
   for (ConstraintDefinition cd : pd.getConstraints()) {
      result.add(new SelectItem(cd.getName().getLocalName()));

   return result;
So the expected output in a listbox would be two entries with values "open" and "closed", given the constraint definition below.

<constraint name="enum-status" type="LIST">
  <parameter name="allowedValues">

<property name="status">
    <constraint ref="enum-status"/>

Unfortunately, all I get is a single entry "status_anon_13". What would be the correct code to produce the desired listbox entries?