cancel
Showing results for 
Search instead for 
Did you mean: 

Multi-Select Checkbox Property

howejr77
Champ in-the-making
Champ in-the-making
Hello,

I'm trying to create a custom aspect containing a property which I will tie to a multi-select set of checkboxes. I'm looking for a dynamic way to generate the contents for the checkboxes. In my searches so far, the most concrete way I've seen to do something like this appears to be to define a constraint in the model and place the constraint on aspect property. I assume then I could just specify the CheckboxGenerator as my component-generator in web-client-config-custom. This will really not allow me to be dynamic though.

What I would really like to do is be able to pull the different values for the checkboxes from a database table (and am open to putting them in the alfresco database, if possible/allowed or another database). I'm looking at the component generator framework but don't really understand from the documentation on how you actually get your data into it? Should I be looking at writing something that extends CheckboxGenerator? Is there a way for me to use CheckBoxGenerator and pass it the data? Is there a way for me to configure some new bean that really utilizes CheckboxGenerator but allows me to define the content in an XML file (I might be open to this as a place to store the content instead of a database table, if the database is significantly more effort).

Would really appreciate any suggestions…

Thanks
Ryan
6 REPLIES 6

howejr77
Champ in-the-making
Champ in-the-making
Well, I have successfully retrieved the contents of the constraint list by creating a custom constraint that extends ListOfValuesConstraint. Now when I visit the properties page of a piece of content with that aspect attached to it, I successfully get a component displayed on the page that has my list of values from a database table.

I'm now having an issue where I'm trying to access the getSelectItemList() method on my custom constraint from a custom JSP page in a custom wizard but I don't appear to have a reference to the instance that is being created during the Alfresco startup. Could someone give me some advice on how to access it? I've seen the posts on making a class ApplicationContextAware but when I implement those examples, my setApplicationContext method never seems to be called as I get a null pointer when I try to access the ApplicationContext. Is there some configuration I need to do with a class that I make applicationContextAware?

Is there a way to reference my custom constraint class via the FacesContext?

Please help! I keep trying to post to these forums but it seems like no one ever replies…

Thank You
Ryan

howejr77
Champ in-the-making
Champ in-the-making
OK, solved my problem with the nullPointer in getting access to the ApplicationContext.

Could anyone give me any clue on the name of the bean I want to retreive?

Assuming this is my custom model constraint definition:

    <constraints>
        <constraint name="pfxSmiley TonguefxPossibleRoles" type="com.sample.constraint.AllowedRoleConstraint" />
   </constraints>

howejr77
Champ in-the-making
Champ in-the-making
Could someone please help or at least give me a clue that I'm going down the correct path?

I've create my "Add Content" dialog and am trying to display a Select Many Checkbox using the getSelectItems from my custom constraint. I've gone through all the activity of above and have access to ApplicationContext now but really don't see how to access the instance of my custom constraint that was created at Alfresco startup.

I see the DictionaryBootStrap bean for my custom model but don't see anyway to get my constraint…

Please help… Someone…

I've posted several different posts through this forum and only one thread received any responses….

giafar
Champ in-the-making
Champ in-the-making
Hi
I have the same problem you are talking about.
Can you provide some example file for model.xml and web-client.xml ?
Thanks in advance.

howejr77
Champ in-the-making
Champ in-the-making
Hi,

I struggled through this a little while ago so all the various problems I hit, are a little fuzzy to me right now. Definitely want to help though as I know I had to just search and search for the most part. I'm assuming you are trying to access the values in a ListOfValuesConstraint which you created? That is what I'll try to describe here. If I'm not covering what you need, let me know what you are after…

The main thing you need is a reference to the DictionaryService object. In my tasks, I was creating dialogues/wizards that ulimately extended BaseDialogBean which has a reference for you.

Once I had DictionaryService, from searching all over I ended up writing these two methods:


        private PropertyDefinition getProperyDefinition(String aspectLocalName, String propertyLocalName) {

      AspectDefinition pbContentPropsAspect = ds.getAspect(QName.createQName(CustomModelHelper.PB_NAMESPACE_URI, aspectLocalName));
      Iterator<PropertyDefinition> propDefIter = pbContentPropsAspect.getProperties().values().iterator();
      while (propDefIter.hasNext()) {
         PropertyDefinition propDef = propDefIter.next();
         if (propDef.getName().getLocalName().equalsIgnoreCase(propertyLocalName)) {
            return propDef;
         }
      }
      
      return null;       
        }
 
   public PBListOfValuesConstraint getPBValueConstraint(String aspectLocalName, String propertyLocalName) {

      PBListOfValuesConstraint pbLOVConstraint = null;
      
      PropertyDefinition pbRoleAccessPropertyDef = getProperyDefinition(aspectLocalName, propertyLocalName);
      ListIterator<ConstraintDefinition> constraintDefIter = pbRoleAccessPropertyDef.getConstraints().listIterator();
      while (constraintDefIter.hasNext()) {
         Constraint constraint = ((ConstraintDefinition)constraintDefIter.next()).getConstraint();
         if (constraint instanceof PBListOfValuesConstraint) {
            pbLOVConstraint = (PBListOfValuesConstraint) constraint;
         }
      }
      
      return pbLOVConstraint;
   }

I believe I found the logic of these two methods in the forums somewhere but just restructured them a bit. Let me know if this helps you or you need more information (or if you were asking for something other than finding your constraint via the DictionaryService). With Labor Day weekend, I may not be able to respond before next week..

Ryan

jetty
Champ in-the-making
Champ in-the-making
can u just send me a sample code how to insert an check boxes for an advance search metadata .
i have been struck off with this .i was not able to get an idea whether i have to edit browse.jsp or write a custom java file .