12-18-2009 03:56 AM
12-18-2009 09:41 AM
package org.alfresco.sample.CodeLabelExtend;
import java.util.ArrayList;
import java.util.List;
import java.sql.*;
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;
import java.io.Serializable;
import javax.faces.model.SelectItem;
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() {
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";//o mysql si es lo que utilizaras
String serverName = "167.175.55.207";
String mydatabase = "alfresco";
String username = "alfresco";
String password = "alfresco";
List<String> av = new ArrayList<String>();
List<String> al=new ArrayList<String>();
try {
Connection connection = null;
Class.forName(driverName);
String url = "jdbc:postgresql://" + serverName + "/" + mydatabase;
connection = DriverManager.getConnection(url, username, password);
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("select code,label from codelabel");
while (rs.next()) {
av.add(rs.getString("code"));
al.add(rs.getString("label"));
}
}
catch (Exception e) {}
super.setAllowedValues(av);
this.setAllowedLabels(al);
}
}
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;son las librerias que debes incluir en el proyecto;ésto lo harás de la siguiente forma (en Eclipse):12-21-2009 05:24 AM
12-21-2009 06:09 AM
No deberías tener ningún error, si es así exportas el proyecto. Del resultado de la exportación copias la carpeta alfresco que está dentro de /ListOfValuesQueryConstraint/org/ y lo ubicarás en /WEB-INF/classes/org/
12-22-2009 09:15 AM
12-23-2009 03:55 AM
12-28-2009 10:36 AM
<constraints>
<constraint name="tc:CodeLabel" type="org.alfresco.sample.CodeLabelExtend.ListOfValuesQueryConstraint"></constraint>
</constraints>12-29-2009 12:30 PM
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.