<constraint name="toto" type="org.test.testValeurDynamique">
<parameter name="allowedValues">
</parameter>
</constraint>
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.atosorigin.test.DbUtils;
import org.atosorigin.test.SqlRequete;
public class testValeurDynamique extends ListOfValuesConstraint {
private static Log logger = LogFactory.getLog("org.test.DbUtils");
public testValeurDynamique() {
super();
logger.debug("Appel supperConstructeur");
}
public List<String> getAllowedValues()
{
logger.debug("getAllowedValues ");
return super.getAllowedValues();
}
public void setAllowedValues(List allowedValues)
{
if (allowedValues == null)
{
allowedValues=getValeur();
}
logger.debug("setAllowedValues Avant super.set");
super.setAllowedValues(allowedValues) ;
logger.debug("setAllowedValues Aprés super.set");
}
/**
* Va rechercher la liste des Civilites dans la base de données
* @return la liste des Civilites
*/
private ArrayList<String> getValeur(){
ArrayList<String> valeurs=null;
Connection conn=null;
try {
conn = DbUtils.getDbConnection();
String requete = "SELECT NAME FROM VALEURS WHERE NAMECONTRAINT='maConstraint";
valeurs = SqlRequete.postGetRequete(conn,requete);
DbUtils.closeDbConnection(conn);
} catch (Exception e) {
logger.error(e.getMessage());
}
return valeurs;
}
}
<constraint name="toto" type="org.test.testValeurDynamique">
<parameter name="allowedValues">
</parameter>
<parameter name="categorieValeurs">
<value>toto</value>
</parameter>
</constraint>
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.