cancel
Showing results for 
Search instead for 
Did you mean: 

Multi-valued default

lercherl
Champ on-the-rise
Champ on-the-rise
In my model (generated by Model Manager), I have a multi-valued custom property with a "list of values" constraint. This works as expected:


<property name="mymodel:color">
   <title>Color</title>
   <type>d:text</type>
   <mandatory>false</mandatory>
   <multiple>true</multiple>
   <default>blue</default>
   <constraints>
      <constraint name="mymodel:LIST_7bfcaacd-06c9-4c29-8c5e-1277190ac43c" type="LIST">
         <parameter name="allowedValues">
            <list>
               <value>red</value>
               <value>blue</value>
               <value>green</value>
               <value>yellow</value>
               <value>pink</value>
               <value>purple</value>
               <value>brown</value>
            </list>
         </parameter>
         <parameter name="sorted">
            <value>false</value>
         </parameter>
      </constraint>
   </constraints>
</property>


Now I want to specify "blue" and "red" as default, rather than blue. The Model Manager won't allow me to do this and a few obvious changes I tried to the XML file don't work:


<default>blue,red</default>



<default>blue</default>
<default>red</default>



<default>
      <list>
          <value>red</value>
           <value>blue</value>
       </list>
</default>


Is there a way to specify a multi-valued default value?
1 REPLY 1

steven_okennedy
Star Contributor
Star Contributor
Hi lercherl

Out of the box, no I don't think there's an easy way to this.  While Alfresco's modelSchema.xsd means that your configuration is valid and would be parseable as a valid model, it looks like Alfresco's Java representation of a Property expects to receive a single String only. So just by content modelling, I don't think so.

There's an alternative option, using a simple Behaviour, where you could programmatically set the color property value of newly created nodes of this type to red and blue (obviously be sure to only set the values if the property is null) - http://docs.alfresco.com/5.1/references/dev-extension-points-behaviors.html 

Regards

Steven