私はデータブルを持っており、その中にコマンドボタンを列として持っています。選択時と選択解除時のコマンドボタンの色を変更したいと思います。たとえば、選択されていない/選択解除されている場合は赤色、選択されている場合は緑色です。
私のデータテーブルは次のようになります。
<p:dataTable id="interfaces"
value="#{studentBean.studentDataModel}"
var="studentDetails" emptyMessage="No Student found."
selection="#{studentBean.selectedStudents}" >
<p:column headerText="Select this Student" style="width:1%">
<p:commandButton value="Select"
action="#{studentBean.saveThisStudent}"
styleClass="non-selected-button-background-color">
</p:commandButton>
</p:column>
</p:dataTable>
以下は、default.cssの中にあるものです
.non-selected-button-background-color {
background-color: blue
}
.selected-button-background-color {
background-color: green
}
どうすれば機能を実現できますか?
機能を更新しました:
1) すべてのコマンドボタンは最初は青色です
2) ボタンをクリックすると、色が緑色に変わります
3) 同じボタンをもう一度クリックすると、色が青色に変わります
4) 別のボタンをクリックすると機能します下 -
- 緑色のボタンがある場合は、最初に青色にします
- 次に、クリックしたボタンの色を緑に変更します。