Jahia Dev Forum > Dependent choicelist

0 (0 Good)
0 (0 Bad)

Dependent choicelist

by  joewei »  2013/12/09 19:13

I'd need to implement a dependent choicelist where the choice list values are dependent on a previous selection, for example the user would select a state first and then the next dropdown would be populated with corresponding cities in that state.

I'm wondering whether this is possible as it looks to me as if the getChoiceListValues is called already during the initialization.

Any help would be highly appreciated.

Thanks
Joerg

  • Dependent choicelist
    2013/12/09 19:13

    joewei <p> I&#39;d need to implement a dependent choicelist where the choice list values are dependent on a previous selection, for example the user would select a state first and then the next dropdown would be populated with corresponding cities in that state.</p> <p> I&#39;m wondering whether this is possible as it looks to me as if the&nbsp;getChoiceListValues&nbsp;is called already during the initialization.</p> <p> Any help would be highly appreciated.</p> <p> Thanks<br /> Joerg</p>

  • Number of messages  6
    Registration date Dec 9, 2013
    0 (0 Good)
    0 (0 Bad)

    Re: Dependent choicelist

    by  pvollenweider »  2013/12/17 15:04

    Hello,
     
    An idea would be to use mixin to add properties to a node. 
    Depending ofthe choosen mixin you will get different choicelists.
    Please check following example (it should work with some adjustments).
     
     
    Here is my definition:
     
    [mymix:myfield1] > jmix:templateMixin mixin 
    extends=mynt:mycomponent 
    - field1 (string, choicelist[resourceBundle]) = 'value1' < 'value1', 'value2', 'value3', 'value4'
     
    [mymix:myfield2] > jmix:templateMixin mixin 
    extends=mynt:mycomponent 
    - field2 (string, choicelist[resourceBundle]) = 'valueA' < 'valueA', 'valueB', 'valueC', 'valueD'
     
    [mynt:mycomponent] > jnt:content, jmix:droppableContent, jmix:editorialContent
    - chooseField (string, choicelist[myfieldInitializer,resourceBundle]) = 'myfield1' < 'myfield1', 'myfield1' 
     
    So in the mynt:mycomponent component I can choose "myfield1" or "myfield2". Depending of the choosen value jahia will add a field1 or field2 property.
     
    Your bean in the spring file will look like this
     
        <bean id="myfieldInitializer" class="com.jahia.modules.initializers.MyfieldInitializer">
            <property name="key" value="myfieldInitializer"/>
        </bean>
     
    And the complete initilaizer should look like this:
     
    package com.jahia.modules.initializers;
     
    import org.jahia.services.content.JCRPropertyWrapper;
    import org.jahia.services.content.nodetypes.ExtendedPropertyDefinition;
    import org.jahia.services.content.nodetypes.ValueImpl;
    import org.jahia.services.content.nodetypes.initializers.ChoiceListValue;
    import org.jahia.services.content.nodetypes.initializers.ModuleChoiceListInitializer;
    import org.jahia.services.content.nodetypes.renderer.AbstractChoiceListRenderer;
    import org.jahia.services.content.nodetypes.renderer.ModuleChoiceListRenderer;
    import org.jahia.services.render.RenderContext;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
     
    import javax.jcr.PropertyType;
    import javax.jcr.RepositoryException;
    import javax.jcr.Value;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Locale;
    import java.util.Map;
     
     
    public class MyfieldInitializer extends AbstractChoiceListRenderer implements ModuleChoiceListInitializer, ModuleChoiceListRenderer  {
        private static final Logger logger = LoggerFactory.getLogger(MyfieldInitializer.class);
     
        private String key;
     
        public List<ChoiceListValue> getChoiceListValues(ExtendedPropertyDefinition epd, String param, List<ChoiceListValue> values,
                                                         Locale locale, Map<String, Object> context) {
     
            //Create the list of ChoiceListValue to return
            List<ChoiceListValue> myChoiceList = new ArrayList<ChoiceListValue>();
     
            if (context == null) {
                return myChoiceList;
            }
     
            HashMap<String, Object> myPropertiesMap = null;
     
       myPropertiesMap = new HashMap<String, Object>(); 
       myPropertiesMap.put("addMixin","mymix:myfield1"); 
       myChoiceList.add(new ChoiceListValue("myfield1",myPropertiesMap,new ValueImpl("myfield1", PropertyType.STRING, false))); 
     
       myPropertiesMap = new HashMap<String, Object>(); 
       myPropertiesMap.put("addMixin","mymix:myfield2"); 
       myChoiceList.add(new ChoiceListValue("myfield2",myPropertiesMap,new ValueImpl("myfield2", PropertyType.STRING, false))); 
     
            //Return the list
            return myChoiceList;
        }
     
        public void setKey(String key) {
            this.key = key;
        }
     
        public String getKey() {
            return key;
        }
     
        public String getStringRendering(RenderContext context, JCRPropertyWrapper propertyWrapper) throws RepositoryException {
            final StringBuilder sb = new StringBuilder();
            if (propertyWrapper.isMultiple()) {
                sb.append('{');
                final Value[] values = propertyWrapper.getValues();
                for (Value value : values) {
                    sb.append('[').append(value.getString()).append(']');
                }
                sb.append('}');
            } else {
                sb.append('[').append(propertyWrapper.getValue().getString()).append(']');
            }
            return sb.toString();
        }
     
        public String getStringRendering(Locale locale, ExtendedPropertyDefinition propDef, Object propertyValue) throws RepositoryException {
            return "[" + propertyValue.toString() + "]";
        }
    }
     
     
    I hope it helps.
     
    Philippe.
     

    Philippe Vollenweider (pvollenweider)

    Number of messages  11
    Registration date
    0 (0 Good)
    0 (0 Bad)

    Re: Dependent choicelist

    by  shyrkov »  2013/12/18 11:23

    Hello Joerg,

     

    just for reference I will re-post here a solution our colleague provided for one of the customers, which is explaining the usage of dependent list initializers.

    Internally, we also use this feature, e.g. in the:

    [jmix:renderableList] mixin
     itemtype = layout
     - j:subNodesView (string, choicelist[templates=subnodes,resourceBundle,dependentProperties='j:allowedTypes']) nofulltext
     

    The corresponding initializer code is: org.jahia.services.content.nodetypes.initializers.TemplatesChoiceListInitializerImpl

    ( http://maven.jahia.org/maven2/org/jahia/server/jahia-impl/6.6.2.0/jahia-impl-6.6.2.0-sources.jar )

     

    Kind regards

    Sergiy

     

    And here is the repost:

    I will give you an whole example:

    Let's say we have to fields (both choicelists) j:field1 and j:field2 and j:field2 has a dependency to j:field1, that means when you change the value of j:field1 the values of j:field2 will changed dependent to the selected value on j:field1.

    The definition for that would look like:

     - j:field1 (string, choicelist[resourceBundle]) analyzer='keyword' < 'A1', 'A2', 'A3'
     - j:field2 (string, choicelist[myInit=j:field1,dependentProperties='j:field1'])

    j:field1 has three default values A1, A2, and A3
    j:field2 has no defaultvalues but an own initiliazer, which I named myInit, and I have to set the dependency with dependentProperties='j:field1'

    Next I have to define my initializer (myInit). I can do that in file applicationcontext-jcr.xml which can be found in WEB-INF/lib/jahia-impl-6.*.jar\org\jahia\defaults\config\spring\jcr (you could make a copy of this file in WEB-INF/etc/spring and do your changes in the copied file. You only have to add changed and new beans in this file, so you don't need all other default config, see attached applicationcontext-jcr.xml).
    For your initializer you need to define first an own bean like:

    <bean id="myInitializer" class="org.mycompany.initializers.MyInitializer"/>

    And you have to add this initializer to the choiceListInitializers:

       <bean id="choiceListInitializers"
              class="org.jahia.services.content.nodetypes.initializers.ChoiceListInitializerService"
              factory-method="getInstance">
            <property name="initializers">
                <map>
                    <entry key="resourceBundle" value-ref="rbInitializer"/>
                    <entry key="country" value-ref="countryInitializerRenderer"/>
                    <entry key="templates" value-ref="templatesInitializer"/>
                    <entry key="templatesNode" value-ref="templatesNodeInitializer"/>

                    <entry key="users" value-ref="usersInitializer"/>
                    <entry key="nodetypes" value-ref="nodetypesInitializer"/>
                    <entry key="subnodetypes" value-ref="subNodetypesInitializer"/>
                    <entry key="nodes" value-ref="nodesInitializer"/>
                    <entry key="menus" value-ref="menuInitializer"/>
                    <entry key="script" value-ref="scriptInitializer"/>
                    <entry key="flag" value-ref="countryFlagInitializer"/>
                    <entry key="sortableFieldnames" value-ref="sortableFieldnamesInitializer"/>
                    <entry key="moduleImage" value-ref="moduleImageInitializer"/>
                    <entry key="linkerProps" value-ref="commponentLinkerInitializer"/>
                    <entry key="workflow" value-ref="workflowInitializer"/>
                    <entry key="workflowTypes" value-ref="workflowTypesInitializer"/>
                    <entry key="sort" value-ref="sortInitializer"/>
                    <entry key="componenttypes" value-ref="componentTypesInitializer"/>
                    <entry key="channels" value-ref="channelInitializer"/>
                    <entry key="propertyValues" value-ref="propertyValuesChoiceListInitializer"/>
                    <entry key="myInit" value-ref="myInitializer"/>
                    
                </map>
            </property>
        </bean>


    And you have to implement your org.mycompany.initializers.MyInitializer.java
    I did it in a simple example, and I attached the java file for that, and you have to set a compiled version of this file in the class path. Like in a module, or you copy it in correct package in the WEB-INF/classes folder.
    I am not sure about your needs, but maybe you don't need an own Initializer, maybe you can reuse one of existant, like the ScriptInitializer. With my example I want to show you how you could define your own one, if an existant is not enough.

    I hope it helps,
    best regards
    Werner

     

    ----------------------- MyInitializer.java -------------------------

    package org.mycompany.initializers;
    
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.List;
    import java.util.Locale;
    import java.util.Map;
    
    import org.jahia.services.content.nodetypes.ExtendedPropertyDefinition;
    import org.jahia.services.content.nodetypes.initializers.ChoiceListInitializer;
    import org.jahia.services.content.nodetypes.initializers.ChoiceListValue;
    
    public class MyInitializer implements ChoiceListInitializer {
    
     public List<ChoiceListValue> getChoiceListValues(
       ExtendedPropertyDefinition epd, String param,
       List<ChoiceListValue> values, Locale locale,
       Map<String, Object> context) {
    
      List<ChoiceListValue> choiceListValues = new ArrayList<ChoiceListValue>();
      if (context.get(param) == null
        || ((List) context.get(param)).get(0) == null) {
       return Collections.emptyList();
      }
      String s = (String) ((List) context.get(param)).get(0);
    
      if (s.equals("A1")) {
       choiceListValues.add(new ChoiceListValue("A11", "A11"));
       choiceListValues.add(new ChoiceListValue("A12", "A12"));
      }
      if (s.equals("A2")) {
       choiceListValues.add(new ChoiceListValue("A21", "A21"));
       choiceListValues.add(new ChoiceListValue("A22", "A22"));
      }
      if (s.equals("A3")) {
       choiceListValues.add(new ChoiceListValue("A31", "A31"));
       choiceListValues.add(new ChoiceListValue("A32", "A32"));
      }
    
      return choiceListValues;
     }
    
    }
    
  • Re: Dependent choicelist
    2013/12/18 11:23

    shyrkov <p> Hello Joerg,</p> <p> &nbsp;</p> <p> just for reference I will re-post here a solution our colleague provided for one of the customers, which is explaining the usage of dependent list initializers.</p> <p> Internally, we also use this feature, e.g. in the:</p> <p> [jmix:renderableList] mixin<br /> &nbsp;itemtype = layout<br /> &nbsp;- j:subNodesView (string, choicelist[templates=subnodes,resourceBundle,dependentProperties=&#39;j:allowedTypes&#39;]) nofulltext<br /> &nbsp;</p> <p> The corresponding initializer code is: org.jahia.services.content.nodetypes.initializers.TemplatesChoiceListInitializerImpl</p> <p> ( http://maven.jahia.org/maven2/org/jahia/server/jahia-impl/6.6.2.0/jahia-impl-6.6.2.0-sources.jar )</p> <p> &nbsp;</p> <p> Kind regards</p> <p> Sergiy</p> <p> &nbsp;</p> <p> And here is the repost:</p> <p> I will give you an whole example:<br /> <br /> Let&#39;s say we have to fields (both choicelists) j:field1 and j:field2 and j:field2 has a dependency to j:field1, that means when you change the value of j:field1 the values of j:field2 will changed dependent to the selected value on j:field1.<br /> <br /> The definition for that would look like:<br /> <br /> &nbsp;- j:field1 (string, choicelist[resourceBundle]) analyzer=&#39;keyword&#39; &lt; &#39;A1&#39;, &#39;A2&#39;, &#39;A3&#39;<br /> &nbsp;- j:field2 (string, choicelist[myInit=j:field1,dependentProperties=&#39;j:field1&#39;])<br /> <br /> j:field1 has three default values A1, A2, and A3<br /> j:field2 has no defaultvalues but an own initiliazer, which I named myInit, and I have to set the dependency with dependentProperties=&#39;j:field1&#39;<br /> <br /> Next I have to define my initializer (myInit). I can do that in file applicationcontext-jcr.xml which can be found in WEB-INF/lib/jahia-impl-6.*.jar\org\jahia\defaults\config\spring\jcr (you could make a copy of this file in WEB-INF/etc/spring and do your changes in the copied file. You only have to add changed and new beans in this file, so you don&#39;t need all other default config, see attached applicationcontext-jcr.xml).<br /> For your initializer you need to define first an own bean like:<br /> <br /> &lt;bean id=&quot;myInitializer&quot; class=&quot;org.mycompany.initializers.MyInitializer&quot;/&gt;<br /> <br /> And you have to add this initializer to the choiceListInitializers:<br /> <br /> &nbsp;&nbsp;&nbsp;&lt;bean id=&quot;choiceListInitializers&quot;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class=&quot;org.jahia.services.content.nodetypes.initializers.ChoiceListInitializerService&quot;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;factory-method=&quot;getInstance&quot;&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=&quot;initializers&quot;&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;map&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;resourceBundle&quot; value-ref=&quot;rbInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;country&quot; value-ref=&quot;countryInitializerRenderer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;templates&quot; value-ref=&quot;templatesInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;templatesNode&quot; value-ref=&quot;templatesNodeInitializer&quot;/&gt;<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;users&quot; value-ref=&quot;usersInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;nodetypes&quot; value-ref=&quot;nodetypesInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;subnodetypes&quot; value-ref=&quot;subNodetypesInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;nodes&quot; value-ref=&quot;nodesInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;menus&quot; value-ref=&quot;menuInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;script&quot; value-ref=&quot;scriptInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;flag&quot; value-ref=&quot;countryFlagInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;sortableFieldnames&quot; value-ref=&quot;sortableFieldnamesInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;moduleImage&quot; value-ref=&quot;moduleImageInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;linkerProps&quot; value-ref=&quot;commponentLinkerInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;workflow&quot; value-ref=&quot;workflowInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;workflowTypes&quot; value-ref=&quot;workflowTypesInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;sort&quot; value-ref=&quot;sortInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;componenttypes&quot; value-ref=&quot;componentTypesInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;channels&quot; value-ref=&quot;channelInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;propertyValues&quot; value-ref=&quot;propertyValuesChoiceListInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;entry key=&quot;myInit&quot; value-ref=&quot;myInitializer&quot;/&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/map&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/property&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&lt;/bean&gt;<br /> <br /> <br /> And you have to implement your org.mycompany.initializers.MyInitializer.java<br /> I did it in a simple example, and I attached the java file for that, and you have to set a compiled version of this file in the class path. Like in a module, or you copy it in correct package in the WEB-INF/classes folder.<br /> I am not sure about your needs, but maybe you don&#39;t need an own Initializer, maybe you can reuse one of existant, like the ScriptInitializer. With my example I want to show you how you could define your own one, if an existant is not enough.<br /> <br /> I hope it helps,<br /> best regards<br /> Werner</p> <p> &nbsp;</p> <p> ----------------------- MyInitializer.java -------------------------</p> <pre> package org.mycompany.initializers; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.Map; import org.jahia.services.content.nodetypes.ExtendedPropertyDefinition; import org.jahia.services.content.nodetypes.initializers.ChoiceListInitializer; import org.jahia.services.content.nodetypes.initializers.ChoiceListValue; public class MyInitializer implements ChoiceListInitializer { public List&lt;ChoiceListValue&gt; getChoiceListValues( ExtendedPropertyDefinition epd, String param, List&lt;ChoiceListValue&gt; values, Locale locale, Map&lt;String, Object&gt; context) { List&lt;ChoiceListValue&gt; choiceListValues = new ArrayList&lt;ChoiceListValue&gt;(); if (context.get(param) == null || ((List) context.get(param)).get(0) == null) { return Collections.emptyList(); } String s = (String) ((List) context.get(param)).get(0); if (s.equals(&quot;A1&quot;)) { choiceListValues.add(new ChoiceListValue(&quot;A11&quot;, &quot;A11&quot;)); choiceListValues.add(new ChoiceListValue(&quot;A12&quot;, &quot;A12&quot;)); } if (s.equals(&quot;A2&quot;)) { choiceListValues.add(new ChoiceListValue(&quot;A21&quot;, &quot;A21&quot;)); choiceListValues.add(new ChoiceListValue(&quot;A22&quot;, &quot;A22&quot;)); } if (s.equals(&quot;A3&quot;)) { choiceListValues.add(new ChoiceListValue(&quot;A31&quot;, &quot;A31&quot;)); choiceListValues.add(new ChoiceListValue(&quot;A32&quot;, &quot;A32&quot;)); } return choiceListValues; } } </pre>

  • Number of messages  407
    Registration date Dec 18, 2013
    0 (0 Good)
    0 (0 Bad)

    Re: Re: Dependent choicelist

    by  shyrkov »  2013/12/18 11:27

    One side note.

    In order to register a custom choice list initializer from your module you could let your class implement ModuleChoiceListInitializer than it will be automatically registered in Jahia.

    We have an example of registering custom initializers from a module in formbuiler: https://github.com/Jahia/formbuilder/blob/1_x/src/main/webapp/META-INF/spring/mod-formbuilder.xml

     

    Kind regards

    Sergiy

     

  • Re: Re: Dependent choicelist
    2013/12/18 11:27

    shyrkov <p> One side note.</p> <p> In order to register a custom choice list initializer from your module you could let your class implement ModuleChoiceListInitializer than it will be automatically registered in Jahia.</p> <p> We have an example of registering custom initializers from a module in formbuiler: https://github.com/Jahia/formbuilder/blob/1_x/src/main/webapp/META-INF/spring/mod-formbuilder.xml</p> <p> &nbsp;</p> <p> Kind regards</p> <p> Sergiy</p> <p> &nbsp;</p>

  • Number of messages  407
    Registration date Dec 18, 2013
    0 (0 Good)
    0 (0 Bad)

    list initializers on choiceList with multiple property

    by  dongmo »  2014/11/25 15:37

    Hello  shyrkov,

    I have a question, Can  i use use dependent list initializers on choiceList with multiple property?

    It seems doesn't work,

    Dongmo

     

    dongmo
    Number of messages  1
    Not registered
    Contact
    Share
    Feedback

    Get in touch

    Whether you are a current user or if you are just evaluating Jahia, we are here to help.

    Contact us

    Share this page