Changer dynamiquement background color
Bonjour a tous (et a toutes)
Alors voila, en fait tout est dans le titre ^^ je cherche à changer dynamiquement la valeur background color dans des balises <div>.
Voici l'essai que j'ai tenté :
Code:
1 2 3 4 5 6
| <div t:type="loop" t:source="instanceList" t:value="instances">
<div id="Liste" t:source="instanceState" t:value="color" style="background-color: $(color)">
${instances.nomInstance}
</div></div>
</div> |
Mais (assez logiquement) ça ne marche pas...
Avez vous une idée de comment je pourrais procéder?
Merci d'avance!!!
Edit : après avoir essayé ceci :
Code:
1 2 3 4 5 6
| <div t:type="loop" t:source="instanceList" t:value="instances">
<div id="Liste" t:source="instanceState" t:value="color" style=$(color)>
${instances.nomInstance}
</div>
</div> |
Ou mes fonctions instanceState et instanceList son :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| public List<Instances> getInstanceList()
{
try {
return (List<Instances>) instanceManager.sortAll();
} catch (BusinessException e) {
e.printStackTrace();
return null;
} catch (TechnicalException e) {
e.printStackTrace();
return null;
}
}
public String getInstanceState()
{
InstanceService service = new InstanceService();
color = "background-color: ";
color = color + service.instanceState(instances.getIdAo());
return color;
} |
J'obtient le message d'erreur suivant :
Citation:
Failure parsing template classpath:com/applira/web/pages/common/Accueil.tml: Unexpected character '$' (code 36) in start tag Expected a quote at [row,col {unknown-source}]: [23,68]
Donc apparemment il aime pas trop les variables à l'intérieur d'un div... Mais je ne vois malheureusement pas trop comment procéder autrement...