0
Hello, I have the following situation:
On my jsf page I have some components selectBooleanCheckbox
. I need that when clicking on one of them some others are unchecked, and also disabled, making it impossible to select.
Is it possible? If yes, does anyone have any information, material that can help me? Thank you
xhtml:
<h:selectBooleanCheckbox value="#{simpleReport.colunaCliente}" />
<h:outputText escape="false" value="Cliente" />
<h:selectBooleanCheckbox value="#{simpleReport.colunaCondutor}" />
<h:outputText escape="false" value="Condutor" />
<h:selectBooleanCheckbox
value="#{simpleReport.colunaCondicaoTempo}" />
<h:outputText escape="false" value="Cond. Tempo" />
<h:selectBooleanCheckbox value="#{simpleReport.colunaOcorrencia}" />
<h:outputText escape="false" value="Ocorrência" />
In the bean:
boolean colunaId = false, colunaCliente = false, colunaCondutor = false, colunaPeriodo = false,
colunaCondicaoTempo = false, colunaStatus = false, colunaOcorrencia = false, colunaSoma = false,
colunaQtdCond = false, colunaQtdCli = false;
Update 01:
xhtml
<p:toolbar id="colunas" style="margin-top: 20px">
<p:toolbarGroup>
<h:selectBooleanCheckbox id="id" value="#{simpleReport.colunaId}" />
<h:outputText escape="false" value="Cód." />
<h:selectBooleanCheckbox id="cli"
value="#{simpleReport.colunaCliente}" />
<h:outputText escape="false" value="Cliente" />
<h:selectBooleanCheckbox id="cond"
value="#{simpleReport.colunaCondutor}" />
<h:outputText escape="false" value="Condutor" />
<h:selectBooleanCheckbox id="CondTemp"
value="#{simpleReport.colunaCondicaoTempo}" />
<h:outputText escape="false" value="Cond. Tempo" />
<h:selectBooleanCheckbox id="ocor"
value="#{simpleReport.colunaOcorrencia}" />
<h:outputText escape="false" value="Ocorrência" />
<h:selectBooleanCheckbox id="sta"
value="#{simpleReport.colunaStatus}" />
<h:outputText escape="false" value="Status" />
<h:selectBooleanCheckbox id="per"
value="#{simpleReport.colunaPeriodo}" />
<h:outputText escape="false" value="Período" />
<h:selectBooleanCheckbox id="soma"
value="#{simpleReport.colunaSoma}" />
<h:outputText escape="false" value="Soma" />
<h:selectBooleanCheckbox id="qtdCli"
value="#{simpleReport.colunaQtdCli}" />
<h:outputText escape="false" value="QtdCli" />
<h:selectBooleanCheckbox value="#{simpleReport.colunaQtdCondTemp}" />
<h:outputText escape="false" value="Qtd Cond Temp." />
</p:toolbarGroup>
</p:toolbar>
<p:toolbar style="margin-top: 20px">
<p:toolbarGroup>
<p:selectBooleanCheckbox id="groupCLiente"
value="#{simpleReport.groupByCLiente}">
<p:ajax update="id cond CondTemp ocor sta per"
listener="#{simpleReport.resetValue1}" />
<h:outputText escape="false" value="Cliente" />
</p:selectBooleanCheckbox>
<p:selectBooleanCheckbox id="groupCondicao"
value="#{simpleReport.groupByCondicaoTempo}">
<p:ajax update="id cond CondTemp ocor sta per"
listener="#{simpleReport.resetCondicaoTempo}" />
<h:outputText escape="false" value="Condição" />
</p:selectBooleanCheckbox>
</p:toolbarGroup>
</p:toolbar>
In the bean:
public void resetValue1() {
this.colunaId = false;
this.colunaCondutor = false;
this.colunaCondicaoTempo = false;
this.colunaOcorrencia = false;
this.colunaStatus = false;
this.colunaPeriodo = false;
this.colunaSoma = false;
}
public void resetCondicaoTempo() {
this.colunaId = false;
this.colunaCondutor = false;
this.colunaOcorrencia = false;
this.colunaStatus = false;
this.colunaPeriodo = false;
this.colunaSoma = false;
}
public void resetCondutor() {
this.colunaId = false;
this.colunaCondicaoTempo = false;
this.colunaOcorrencia = false;
this.colunaStatus = false;
this.colunaPeriodo = false;
this.colunaSoma = false;
}
Update02:
xhtml:
<h:selectBooleanCheckbox id="id" value="#{simpleReport.colunaId}"
disabled="#{simpleReport.groupByCLiente || simpleReport.groupByCondicaoTempo}"
enabled="#{not simpleReport.groupByCLiente}"/>
I found this post on Soen : http://stackoverflow.com/questions/8709112/single-select-checkbox-using-jsf is basically what I need but I couldn’t implement it yet because, in my case, by clicking on one of
selectBooleanCheckbox
I need to clear more than one.– Rodrigo
I don’t know if this fits your need, but you couldn’t use a Radiogroup Checkbox instead
– R.Santos
@ R.Santos I believe that due to the various options I need to control would not be a good option. Thank you.
– Rodrigo