Primefaces: selectionMode multiple/ set Value of Checkbox - jsf

I´ve implemented a datatable in JSF with a column with a attribute selectionMode="multiple".
Everything is working so far.
Is there a way to manipulate the value of the checkbox? I want to set the checkbox on the first load to checked or to unchecked, depending on a specific value.
The function i have implemented (in java) returns already true or false, but i need to set the checkboxValue to that value. What do i have to do to ?

You can manipulate the checkbox value through the value attribute like for any other component. See the DataTable demo with multiple selection:
DataTable - RadioCheckbox

Related

Is it possible to get localized value of boolean expression in PrimeFaces?

I use primefaces <p:datatable> component for displaying table data. Among the others, the table contains column with boolean values expressed by <p:selectBooleanCheckbox> component (chosen because of nice look).
However, when I try to export data using <p:dataExporter>, PF always renders logical values as 'true' or 'false' independently from the language. I would like to have values of those components rendered in language which I set in locale.
I have made localization of PrimeFaces calendar by adding global variable
PrimeFaces.locales['pl']= {...}
to javascript supporting PF and it works great for <p:calendar> component. Is it possible to do the same for boolean values?

select All/deselect all checkbox in Datatable JSF without using Javascript

I am making datatable in JSF using (dataTable tag).
I am having several rows in that with check box( selectBooleanCheckbox ) in front of every record.
I have commandLink button for selecting all check box and deselected all check box..
i am trying to select/unselect all checkboxes in the datatable using a single commandLink. As I am trying to set it on the server, I am unable to do so. I have looked around for solutions but could not get how to accomplish on the server side.
thnks

How to make Selection Disable/Enable dynamically in DataTable

How can I make the Primefaces p:dataTable selection Enable or Disable or Multiple or Single dynamically based on some condition.
There is disabledSelection attribute of p:dataTable in PrimeFaces 5+. Using this attribute with proper data table update, enable/disable row selection can be reached.

XPages SSJS add options to combo

In SSJS I'm looping through document in a view and I want to add a new option to a hidden combo for each document and once finished then show that hidden combo.
I've tried building an array with value|string and adding that to the getComponent("apm").setValue(myArray), but no luck and how do I grab the combo and make it visible because dojo.byId("#{id:apm}").setRendered(true); gives error about dojo not found, so do I need to include something?
Any ideas?
Add your array to a viewScope var.
In your combo, add a formula value and point it to the viewScope.
After your array is built make sure the combo is refreshed. You can set the rendered property based on whether or not your viewScope var exists.

Dynamically set cell/row style jsf 2.0

I am using an h:datatable which shows a summary of the data entered by a user in a session. The rows of the table are deletable at the users discretion. if the data meets certain criterion, the specific row in the table must be in red font color, else it should be black.
The methods I have tried so far are:
- Set the style value for h:outputtext component in each column value to red programmatically. But this changes entire columns color.
- Set the rowclasses programmatically, this again changes the style for all previous rows.
I am unable to target just one row or cell. I thought about using javascript, but without the id of the component I am not sure how to get the element.
Thanks.
Use the rowClasses attribute.
<h:dataTable value="#{bean.items}" var="item" rowClasses="#{bean.rowClasses}">
The getRowClasses() must return a comma separated string of CSS class names which are to be applied on rows (more specifically, the <tr> elements) repeatedly. You can create it based on the items inside bean's (post)constructor, action methods and/or even inside the getter.
For some reason, the StringBuffer was being overwritten thats the reason the change wasn't showing. I went with a simpler approach of adding an alert img to the rows that needed to be modified.

Resources