cancel
Showing results for 
Search instead for 
Did you mean: 

constraint error

lazaro
Champ in-the-making
Champ in-the-making
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.io.Serializable;
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{

   @SuppressWarnings("unused")
   private static Log logger = LogFactory.getLog(BaseComponentGenerator.class);
   private static final long serialVersionUID=1;
   private List<String> allowedLabels;
   @SuppressWarnings("unchecked")
   public void setAllowedValues(List allowedValues) {}
   public void setCaseSensitive(boolean caseSensitive) {}
   public void initialize() {
          super.setCaseSensitive(false);
          this.loadDB();
   }
   public List<String> getAllowedLabels() {
         return this.allowedLabels;
   }
   public void setAllowedLabels(List<String> allowedLabels) {
         this.allowedLabels=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>();
        av.add("av1");
        av.add("av2");
        av.add("av3");
        /*
        try {
           Connection connection = null;
            Class.forName(driverName);
            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 (rs.next()) {
                   av.add(rs.getString("JMBG"smiley);
               }
        }
        catch (Exception e) {}

        */
    }
}

later, I based in share-sample-DataLists for me here on my own I got it http://code.google.com/p/share-extras/wiki/DataLists
Basically what I have done is unzip the. jar and re-tune it compressed into jar, so that has been so

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

      <type name="dlexample:book">
          ….
            <property name="dlexample:lista1">
               <title>lista1</title>
               <type>d:text</type>
               <constraints>
           <constraint ref="dlexample:l01" />
               </constraints>
            </property>
        ….

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
Thanks
2 REPLIES 2

mitpatoliya
Star Collaborator
Star Collaborator
what is the error you are getting in your logs?
Is it calling your class first make sure that.

lazaro
Champ in-the-making
Champ in-the-making
sorry am a newbie in alfresco development and not where the log file.
I think calling the class because if I change the call "type = fail.fail.miclass" fails because it can not find it in WEB-INF/lib

I've also tried to do this

<parameter name="allowedValues" type="com.tecnausa.meconecto.ListOfValuesQueryConstraint">
            <list>
            </list>
         </parameter>

I've also edited directly datalistmodel.xml and share-datalist-form-config.xml but still giving me the error
Do I something is missing to do?
Could it be that the error is because export the. Jar directly without using ant?

thanks for replying
regards from Spain
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.