Uploaded image for project: 'CMS'
  1. CMS
  2. CMS-10592

Default value of content attribute on attribute value

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • 4.4.0
    • 4.4.0
    • None
    • None
    • 4.4 RC2

      Select a default value which is a filter on a attribute value (for example a code) like this:

      <default-value type="attributeFilter">code:LIC</default-value>

       

          [CMS-10592] Default value of content attribute on attribute value

          Bérénice Maurel added a comment - - edited

          The problem is detected on inherited or abstract types only.

          Bérénice Maurel added a comment - - edited The problem is detected on inherited or abstract types only.

          I also reproduced the same problem with this attribute defined to the root of the content type and not multiple:

                  <cms:metadata name="genre1" type="content" contentType="content-type.TypeGenre" multiple="false">
                      <cms:label i18n="false">Genre</cms:label>
                      <cms:description i18n="false">Genre</cms:description>
                      <cms:widget>edition.select-referencetable-content</cms:widget>
                      <default-value type="attribute" name="libelleCourt1">H</default-value>
                  </cms:metadata>

          (I have commented the other one)

          Bérénice Maurel added a comment - I also reproduced the same problem with this attribute defined to the root of the content type and not multiple: <cms:metadata name= "genre1" type= "content" contentType= "content-type.TypeGenre" multiple= " false " > <cms:label i18n= " false " >Genre</cms:label> <cms:description i18n= " false " >Genre</cms:description> <cms:widget>edition.select-referencetable-content</cms:widget> < default -value type= "attribute" name= "libelleCourt1" >H</ default -value> </cms:metadata> (I have commented the other one)

          Bérénice Maurel added a comment - - edited

          Doesn't work into repeater entries.

          On loading, I get the following exception:

          Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class org.apache.avalon.framework.configuration.Configuration (java.lang.String is in module java.base of loader 'bootstrap'; org.apache.avalon.framework.configuration.Configuration is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @49ded83f)
          	at org.ametys.cms.contenttype.ContentAttributeDefinition.checkDefaultValue(ContentAttributeDefinition.java:113)
          	at org.ametys.cms.contenttype.DefaultContentType._checkContentAttributes(DefaultContentType.java:1698)
          	at org.ametys.cms.contenttype.DefaultContentType._checkContentAttributes(DefaultContentType.java:1706)
          	at org.ametys.cms.contenttype.DefaultContentType.postInitialize(DefaultContentType.java:1631)
          	at org.ametys.cms.contenttype.ContentTypeExtensionPoint.postInitialize(ContentTypeExtensionPoint.java:312)
          	at org.ametys.cms.contenttype.ContentTypeExtensionPoint.initializeExtensions(ContentTypeExtensionPoint.java:114)
          	at org.ametys.runtime.plugin.component.PluginsComponentManager$ExtensionPointFactory.newInstance(PluginsComponentManager.java:242)
          	at org.ametys.runtime.plugin.component.PluginsComponentManager$ExtensionPointFactory.newInstance(PluginsComponentManager.java:207)
          	at org.ametys.runtime.plugin.component.ThreadSafeComponentManager.lookup(ThreadSafeComponentManager.java:162)
          	... 182 more

          In my case, it is a multiple default value based on attribute filter of a content attribute:

              <cms:repeater name="hebergements" initial-size="0">
                  <cms:header-label>{typeHebergement} </cms:header-label>
                  <cms:label i18n="false">Hébergements</cms:label>
                  <cms:description i18n="false">Hébergements</cms:description>
                  <cms:add-label i18n="false">Ajouter un hébergement</cms:add-label>
                  <cms:del-label i18n="false">Supprimer l'hébergement</cms:del-label>
                  <cms:metadata name="typeHebergement" type="content" contentType="content-type.TypeHebergement" multiple="false">
                      <cms:label i18n="false">Type d'hébergement </cms:label>
                      <cms:description i18n="false">Type d'hébergement</cms:description>
                      <cms:widget>edition.select-referencetable-content</cms:widget>
                  </cms:metadata>
                  <cms:metadata name="genre" type="content" contentType="content-type.TypeGenre" multiple="true">
                      <cms:label i18n="false">Genre</cms:label>
                      <cms:description i18n="false">Genre</cms:description>
                      <cms:widget>edition.select-referencetable-content</cms:widget>
                      <cms:default-value type="attribute" name="libelleCourt1">H</cms:default-value>
                      <cms:default-value type="attribute" name="libelleCourt1">F</cms:default-value>
                  </cms:metadata>
              </cms:repeater>

          Note that the both default values exists.
          Also tested with one default value.
          Also tested without the cms namespace in the tag name.

          Bérénice Maurel added a comment - - edited Doesn't work into repeater entries. On loading, I get the following exception: Caused by: java.lang.ClassCastException: class java.lang. String cannot be cast to class org.apache.avalon.framework.configuration.Configuration (java.lang. String is in module java.base of loader 'bootstrap' ; org.apache.avalon.framework.configuration.Configuration is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @49ded83f) at org.ametys.cms.contenttype.ContentAttributeDefinition.checkDefaultValue(ContentAttributeDefinition.java:113) at org.ametys.cms.contenttype.DefaultContentType._checkContentAttributes(DefaultContentType.java:1698) at org.ametys.cms.contenttype.DefaultContentType._checkContentAttributes(DefaultContentType.java:1706) at org.ametys.cms.contenttype.DefaultContentType.postInitialize(DefaultContentType.java:1631) at org.ametys.cms.contenttype.ContentTypeExtensionPoint.postInitialize(ContentTypeExtensionPoint.java:312) at org.ametys.cms.contenttype.ContentTypeExtensionPoint.initializeExtensions(ContentTypeExtensionPoint.java:114) at org.ametys.runtime.plugin.component.PluginsComponentManager$ExtensionPointFactory.newInstance(PluginsComponentManager.java:242) at org.ametys.runtime.plugin.component.PluginsComponentManager$ExtensionPointFactory.newInstance(PluginsComponentManager.java:207) at org.ametys.runtime.plugin.component.ThreadSafeComponentManager.lookup(ThreadSafeComponentManager.java:162) ... 182 more In my case, it is a multiple default value based on attribute filter of a content attribute: <cms:repeater name= "hebergements" initial-size= "0" > <cms:header-label>{typeHebergement} </cms:header-label> <cms:label i18n= " false " >Hébergements</cms:label> <cms:description i18n= " false " >Hébergements</cms:description> <cms:add-label i18n= " false " >Ajouter un hébergement</cms:add-label> <cms:del-label i18n= " false " >Supprimer l'hébergement</cms:del-label> <cms:metadata name= "typeHebergement" type= "content" contentType= "content-type.TypeHebergement" multiple= " false " > <cms:label i18n= " false " >Type d'hébergement </cms:label> <cms:description i18n= " false " >Type d'hébergement</cms:description> <cms:widget>edition.select-referencetable-content</cms:widget> </cms:metadata> <cms:metadata name= "genre" type= "content" contentType= "content-type.TypeGenre" multiple= " true " > <cms:label i18n= " false " >Genre</cms:label> <cms:description i18n= " false " >Genre</cms:description> <cms:widget>edition.select-referencetable-content</cms:widget> <cms: default -value type= "attribute" name= "libelleCourt1" >H</cms: default -value> <cms: default -value type= "attribute" name= "libelleCourt1" >F</cms: default -value> </cms:metadata> </cms:repeater> Note that the both default values exists. Also tested with one default value. Also tested without the cms namespace in the tag name.

          Definitive syntax:

          <default-value type="attribute" name="attributeName">attributeValue</default-value>

          Bérénice Maurel added a comment - Definitive syntax: < default -value type= "attribute" name= "attributeName" >attributeValue</ default -value>

          This issue is quite linked to the use case CMS-9992.

          Bérénice Maurel added a comment - This issue is quite linked to the use case CMS-9992 .

            cbayle Caroline Bayle
            bmaurel Bérénice Maurel
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: