AnsweredAssumed Answered

constraint error

Question asked by lazaro on Feb 18, 2013
Latest reply on Feb 18, 2013 by lazaro
Hi, I'm trying to create a list to access a table in a database and II have found that does not work.
Step as I have done everything step by step

First I have created a class and have exported. jar and put it in webapps/alfresco/WEB-INF/lib
in case you missed the access to the database I have done a simulation manually adding items to the list

package com.tecnausa.meconecto;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

import java.util.List;
import javax.faces.model.SelectItem;
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
import org.alfresco.web.bean.generator.BaseComponentGenerator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class ListOfValuesQueryConstraint extends ListOfValuesConstraint implements Serializable{

   private static Log logger = LogFactory.getLog(BaseComponentGenerator.class);
   private static final long serialVersionUID=1;
   private List<String> allowedLabels;
   public void setAllowedValues(List allowedValues) {}
   public void setCaseSensitive(boolean caseSensitive) {}
   public void initialize() {
   public List<String> getAllowedLabels() {
         return this.allowedLabels;
   public void setAllowedLabels(List<String> allowedLabels) {
   public List<SelectItem> getSelectItemList() {
         List<SelectItem> result = new ArrayList<SelectItem>(this.getAllowedValues().size());
         for(int i=0;i<this.getAllowedValues().size();i++) {
            result.add(new SelectItem((Object)this.getAllowedValues().get(i),this.allowedLabels.get(i)));
         return result;
    protected void loadDB() {
        String driverName = "org.postgresql.Driver";
        String serverName = "localhost";
        String mydatabase = "alfresco";
        String username = "alfresco";
        String password = "admin";
        String port = "5432";
        List<String> av = new ArrayList<String>();
        List<String> al=new ArrayList<String>();
        try {
           Connection connection = null;
            String url = "jdbcsmileyostgresql://" + serverName + ":"+ port + "/" + mydatabase;
            connection = DriverManager.getConnection(url, username, password);
            Statement stmt = connection.createStatement();
            ResultSet rs = stmt.executeQuery("select mi_id from t_equipos"smiley;
            while ( {
        catch (Exception e) {}


later, I based in share-sample-DataLists for me here on my own I got it
Basically what I have done is unzip the. jar and re-tune it compressed into jar, so that has been so

      <constraint name="dlexample:l01" type="LIST">
         <parameter name="allowedValues">
               <value>Equipo de red</value>
               <value>Ordenador PC</value>
      <constraint name="dlexample:l02" type="com.tecnausa.meconecto.ListOfValuesQueryConstraint"></constraint>

      <type name="dlexample:book">
            <property name="dlexample:lista1">
           <constraint ref="dlexample:l01" />

when I change the line <constraint ref="dlexample:l01" /"> by <"constraint ref =" dlexample: l02 "/>
alfresco completely stops working

sorry for my english, is terribly wrong