4つの可能な値のString属性を持つオブジェクトがあります。各値に対して、別のCSSクラスをセルに配置したいと思います。 はここで、複合条件を記述する方法があるかどうか、私は疑問に思って:また、私は関数呼び出しが間違っていると思う、tdのクラス属性内の複数の条件
<ui:repeat value="#{row.info}" var="wui" >
<td class="#{wui.status eq 'In execution'? 'inexec' : '' }">
<!--<td id="wuitd" onLoad="classfunction()" >-->
<h:outputText value="#{wui.status}" />
<h:outputText value="#{wui.remainingEffort} effort units" />
</td>
</ui:repeat>
私はjavascript関数を書いてみましたが、私はそれが正しいかどうかを確認していない:
<td id="wuitd" onLoad="classfunction()" >
<h:outputText value="#{wui.status}" />
</td>
<script>
function classfunction(){
char status = document.getElementById("wuistatus").value;
switch(status) {
case 'In execution':
document.getElementById("wuitd").style.parentRule('inexec');
break;
case 'Ready for execution':
document.getElementById("wuitd").style.parentRule('ready');
break;
case 'Finished':
document.getElementById("wuitd").style.parentRule('finished');
break;
case 'Not ready':
document.getElementById("wuitd").style.parentRule('notExec');
break;
default:
code block
}
}
</script>
'td'要素から' onload'を起動することはできません。つまり、https:// stackoverflowです。com/questions/4057236/how-to-add-onload-event-to-a-div要素 –
はい、あなたは右の読み込みはtdのイベントではありません。しかし私は自動的にjs機能をトリガーしたい。ユーザーイベントではありません – Lujain