03-09-2009 09:52 AM
03-11-2009 07:39 AM
03-11-2009 08:28 AM
03-11-2009 08:46 AM
package org.contezza.customConstraints;
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.gjt.mm.mysql.Driver";
String serverName = "localhost";
String mydatabase = "denza";
String username = "root";
String password = "root";
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 JMBG,name,address,city from klijenti");
while (rs.next()) {
av.add(rs.getString("JMBG"));
av.add(rs.getString("name"));
av.add(rs.getString("address"));
av.add(rs.getString("city"));
//???? al.add(rs.getString("JMBG"));
}
}
catch (Exception e) {}
super.setAllowedValues(av);
this.setAllowedLabels(al);
}
}
<property name="mm:city">
<title>City</title>
<type>d:text</type>
<mandatory>true</mandatory>
<constraints>
<constraint ref="mm:CodeLabel"></constraint>
</constraints>
</property>
<property name="mm:test">
<title>Test</title>
<type>d:text</type>
<mandatory>false</mandatory>
<constraints>
<constraint ref="mm:CodeLabel" component-generator="TextFieldGenerator"></constraint>
</constraints>
</property>
03-11-2009 10:08 AM
03-11-2009 10:44 AM
So, your java class returns query output..
You get multiple rows with:
while (rs.next())
And inside that, get your document's nodeRef, and put query veraiable to your content model properties.
Or am I not getting the essence of your problem?
03-11-2009 10:49 AM
So, your java class returns query output..
You get multiple rows with:
while (rs.next())
And inside that, get your document's nodeRef, and put query veraiable to your content model properties.
Or am I not getting the essence of your problem?
05-26-2010 01:38 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.