I am having a problem with nested EL for <t:inputText> required Attribute. I am using tomahawk implementation.
I have a dataTable with 2 columns of inputText. I have forceId=true for both the inputText
boxes. When you look at view source of page, id's looks as postal[0] and zone[0] where postalCode and zone are the id's of textBox and the number 0 is the rowId of dataTable.
My requirement here is zone inputText is required only when postal is not empty.
I have written something like below which I know is not right.
required="#{!empty param['postalCode[#{rowIndex}]']}">
Can some one suggest how to do it?
This should work:
required="#{!empty paramValues.postalCode[rowIndex]}"
The #{paramValues.name} returns a String[] with values in the indexed order.
Related
I have an editable Primefaces Datatable configured to call an onCellEdit() method when a cell is edited. Everything works great except that CellEditEvent.rowKey is always null in spite of setting it explicitly to a valid value in the Datatable declaration with 'rowKey='. The Primefaces Datatable documentation leads me to believe that I need the rowKey to get the contents of the row containing the cell being edited. I need the entire row's contents so I can compare the displayed data with the same data in the database to determine if the persisted data had been changed by another client since the Datatable was rendered, catching concurrent edits.
After reading a dozen or more posts on the rowKey being null with row-selectable Datatables I finally realized that rowKey is populated on row select, not on cell edit. rowIndex, however, is not null on cell edit, and reliably gives me the row number (zero-based) so I can retrieve the entire row's contents, and the values of the object used to populate the row (which in my case includes the value I wanted to put into rowKey) from Datatable.getValue(). The purpose of rowKey is not clear in the documentation (to me), so I thought I would share this for anyone encountering a similar problem.
The root cause has been explained by #snakedog already. I will add the code for remedying the issue.
Here is the attribute that you should put within p:datatable:
selectionMode="single"
If you do not want the selection highlight to be seen visually, add disabledSelection="true" as well.
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?
I have a dataTable on JSF that has the following column:
<ice:column style="width:25px;">
<ice:selectBooleanCheckbox value="#{historyBean.checked[mapEntry2.id]}" partialSubmit="true" id="playlist-select" style="width:25px;">
</ice:selectBooleanCheckbox>
</ice:column>
As you can see it's formed by checkboxes that are bound to an map where keys are ids and values are booleans.
It all works well pretty good. But sometimes the dataTable can have as many as a few thousand rows, and then, when a user checks or unchecks one of the checkboxes, the partialSubmit starts to get sluggish.
What I want, at the end of the day, is to perform an operation on the server on the data of each selected row. So far I'm using the partialSubmit and a map on the server to store the Ids of the selected data.
How can I make the check/uncheck operation be reflected faster on the server? Any clues?
Thank you.
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
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.