12-16-2007 05:36 PM
03-14-2008 10:16 AM
…
<constraints>
<constraint name="tc:CodeLabel" type="org.alfresco.sample.CodeLabelExtend.ListOfValuesQueryConstraint" />
</constraints>
<types>
<type name="tc:codecontent">
<title>Contenu étendu</title>
<parent>cm:content</parent>
<properties>
<property name="tc:codestr">
<title>Code str</title>
<type>d:text</type>
<constraints>
<constraint ref="tc:CodeLabel" />
</constraints>
</property>
</properties>
</type>
</types>
…
package org.alfresco.sample.CodeLabelExtend;
import java.util.ArrayList;
import java.util.List;
import java.sql.*;
import org.alfresco.i18n.I18NUtil;
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.gjt.mm.mysql.Driver";
String serverName = "localhost";
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:mysql://" + 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);
}
}
08-29-2008 04:31 AM
09-30-2008 06:12 AM
09-30-2008 07:00 AM
09-30-2008 08:13 AM
10-01-2008 06:17 AM
10-01-2008 07:29 AM
<property name="acme:type">
<type>d:text</type>
<mandatory>true</mandatory>
<default>simple</default>
<constraints>
<constraint type="LIST">
<parameter name="allowedValues">
<list>
<value>simple</value>
<value>double</value>
<value>triple</value>
</list>
</parameter>
</constraint>
</constraints>
</property>
Cheers,10-13-2008 04:36 AM
10-13-2008 05:04 AM
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.