This is not a official/proper way to disable the row selection in <p:dataTable />
But a workaround since there is no way to disable the row selection at the moment.
<p:dataTable
value="#{myBean.resultList}"
selection="#{myBean.selection}"
var="var"
..... />
<p:column selectionMode="multiple" />
<p:column .... />
</p:dataTable>
To disable row selection in the above <p:dataTable />
we need to add <p:ajax /> into the <p:dataTable />
1. add the rowSelect event into dataTable
<p:dataTable id="myTable"
value="#{myBean.resultList}"
selection="#{myBean.selection}"
var="var"
..... />
<p:ajax event="rowSelect"listener="#{myBean.unselectDisabledRow}" update="myTable" />
<p:column selectionMode="multiple" />
<p:column .... />
</p:dataTable>vvv
2. remove the "disabled" from selection
public void unselectDisabledRow(AjaxBehaviorEvent e) {
for(MyObject myObject : resultList) {
if(disable condition) {
resultList.remove(myObject);
}
}
}
The idea is to remove the row that we wanted to disable from the selection immediately.
p/s: more <p:dataTable /> selection events here.
Done!!
It's a wrong approach, the code on the section 2 will throw a Concurrent Modification Exception.
ReplyDeleteSee at:
http://docs.oracle.com/javase/7/docs/api/java/util/ConcurrentModificationException.html
it's already mentioned this is not the proper way.
Deletebut It's working fine for me,
btw, I'm using PF3.5 for this implementation
Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. Disability niche
ReplyDeleteIt is essential to verify your gain is considered "base" gain, as base advantages are absolutely unbiased and could now no longer be decreased with the aid of using gain from social protection or different authorities programs.disability articles
ReplyDeleteSupport groups do not focus on "group process" and therefore are not meant to uncover or treat the psychological or pathological dynamics of the members NDIS Providers Kingscliff
ReplyDeleteTraining can last anywhere from six weeks to two years depending on the desired career and area of specialization. cna classes online
ReplyDelete