cancel
Showing results for 
Search instead for 
Did you mean: 

Property in a selectOneMenu

anusk
Champ in-the-making
Champ in-the-making
Hi all!!
I'm completely lost…
I want to create a property to be set in a selectOneMenu.
I wrote a method that retrieve the values that appears in the combo (all the groups created), but i don't know how to associate the String selected in the combo with the property.
I should create the property with a d:text type??then , if the answer is yes, how can i change the input text field into a oneSelectMenu??wich jsp's do i have to change???

anyone could help me?


thanks!
1 REPLY 1

anusk
Champ in-the-making
Champ in-the-making
Ok, I've been searching information and i found this blog http://blogs.alfresco.com/wp/jbarmash/2008/08/08/dynamic-data-driven-drop-downs-for-list-properties/
Aparentely, what i need is to implement my own constraint. I tried, but (of course) i did something wrong because alfresco throw a bootstrap context exception:
Failed to construct an instance of type 'org.alfresco.extension.MyListofValuesConstraint' for constraint 'custom:miLista'

I've red other posts, but people retrieve the information with lucene searchs and directly from the database, and unfortunately those things are really not my best. I wrote a method in Java that retrieve the information i want to display and i would like to use it.

Here is my code:
package org.alfresco.extension;

import java.util.List;

import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
import org.alfresco.extension.CustomGroupsBean;;



public abstract class MyListofValuesConstraint extends ListOfValuesConstraint{
  
  
   @Override
   public List<String> getAllowedValues()
   {
   CustomGroupsBean customGroup= new CustomGroupsBean();
   List<String> allowedValues = customGroup.getGroupList();
     
   super.setAllowedValues(allowedValues);
  
   return allowedValues;
   }
}

the constraint in the customModel
<constraints>
   <constraint name="custom:miLista" type="org.alfresco.extension.MyListofValuesConstraint">
      <parameter name="allowedValues">
         <list>
         </list>
      </parameter>
   </constraint>   
</constraints>
the property in the type in the customModel
<property name="custom:organizador">
<title>Grupo organizador</title>
<type>d:text</type>
<constraints>
<constraint ref="custom:miLista"/>
</constraints>
</property>

and the custom-model-context
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
<bean id="MyListofValuesConstraintInitializer"
                class="org.alfresco.extension.MyListofValuesConstraint">

               
</bean>

    <!– Registration of new models –>  
    <bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/customModel.xml</value>
            </list>
        </property>
    </bean>
         
</beans>


I'd appreciate any help, cause i'm really stuck with this issue.
Thanks!