Expand a specific row of a p:dataTable - primefaces

I have a screen where I have a list of items and an expansion button left. In the filter if the user enter with a specific information it will bring the same entire list BUT I need to expand the specific row.
<p:rowExpansion>
<p:dataTable var="inventoryPartsItems"
value="#{partnerInventory.getInventoryItems(inventoryPart)}"
emptyMessage="#{msgs.common_no_registries}" id="tableItems">
<p:column style="width:16px">
<p:rowToggler
rendered="#{inventoryPartsItems.sapOperation != null}" />
</p:column>

Related

Primefaces dataTable populate (search) doesn't work well after filtering

I have a Primefaces dataTable like this in a <h:form> block:
<p:dataTable id="basicDT" var="partyDB" value="#{mbRechercheAbonne.listPartyDB}"
paginator="true"
emptyMessage="Aucun abonné ne correspond aux critères"
paginatorPosition="bottom"
paginatorAlwaysVisible="false"
rows="25"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="25,50,100"
currentPageReportTemplate="{startRecord} - {endRecord} sur {totalRecords} résultats"
filteredValue="#{mbRechercheAbonne.filteredListPartyDB}">
and a search button that populates the dataTable using a #ViewScoped bean that updates the value of listPartyDB when rechercheAbonne() is called:
<p:commandButton value="Rechercher" update="display :consultform:basicDT" icon="ui-icon-check"
actionListener="#{mbRechercheAbonne.rechercheAbonne()}" onstart="startRecherche()" oncomplete="stopRecherche()"/>
Searching multiple times works, the dataTable's content changes like expected.
However, when using filtering and then removing the filter (i.e. adding a letter in a filter field above a column and then removing that letter), the search no longer works. I found that the search does actually work, but I need to apply a filter again (and remove it to have the unfiltered list) to see the result of the new search.
Explaining with pictures :
Searching for "test":
Searching for "abc" right after, works as intended:
Searching for test again, filtering one column, works as intended:
Removing the filter (going back to pic 1), and then searching for "abc". Does not work:
Applying a filter again does it on the "abc" search that wasn't showing originally - removing the filter shows what the last search should have shown.
Thanks for your help.

Primefaces dataTable iterate list inside list by index

In my JSF example I am getting a list which contains two lists:
One for result returned from DB and another containing list of column header from DB.
In the first list(containing result) has row data per index.
e.g. **
transaction.transactionsList[0][1]
contain one row data in below code snippet:
<p:dataTable value="#{transaction.transactionsList[0]}" var="tran">
<p:columns value="#{transaction.transactionsList[1]}" var="column"
sortBy="#{tran[column.property]}">
<f:facet name="header">
<h:outputText value="#{column.header}" />
</f:facet>
<h:outputText value="#{tran[column.property]}" />
</p:columns>
</p:dataTable>
Please advise how to iterate based on length of list containing data and based on index over nested list, like:
transaction.transactionsList[0][i]

primefaces:datatable: custom filter: "contains" instead of "beginning"

By default, primeface filter dataTable's rows, by finding rows that columns begins with the string entered in the search area.
How do I filter the DataTable rows that the column contains (not begins with) the string entered in the search area?
You can do this using filterMatchMode attribute on p:column of the dataTable. A very good example can be found on PrimeFaces showcase.
So if we take the above mentioned example, you could have roughly something like this:
<p:dataTable var="car" value="#{dtFilterView.cars}" widgetVar="carsTable"
filteredValue="#{dtFilterView.filteredCars}">
<p:column filterBy="#{car.id}" headerText="Id" footerText="contains"
filterMatchMode="contains">
<h:outputText value="#{car.id}" />
</p:column>
</p:dataTable>
The attribute filterMatchMode accepts values such as contains, endsWith, startsWith, exact...

JSF how to split forms

is it possible to "split" a form?
e.g. i have two forms which would collide (one row of a table needs to stay in form 1, the other in form 2 and so on)
so i need a technique to make this possible like in HTML5 (form="formid")
all black fields must be the same form (content)
and all red fields are also one form together (actions for submit)
I need to be able to access both of them individually, they are just positined like the picture above. unfortunately I cannot make a form of a specific shape which includes some components and others not.
Just use
<ui:repeat>
<h:form>
...
</h:form>
</ui:repeat>
instead of
<h:form>
<ui:repeat>
...
</ui:repeat>
</h:form>

Datatable issues when presenting dynamic columns

I've got a NULLPointerException.
I have iplemented an object called Workhours, which has list of Hours and a workday (enum value).
Now, I have a list
I would like to present it in a datatable with the workday (enum) name as a row, and the hours as columns. Now, this is what I tried:
<p:dataTable id="dtWorkHours" var="workhour" value="#{uploadImagesPage.lwh}" >
<p:column>
<f:facet name="header">
<h:outputText value="Days"></h:outputText>
</f:facet>
<h:outputText value="#{workhour.workday}"></h:outputText>
</p:column>
<p:columns value="#{workhour.luh}" var="columnUntilHours" columnIndexVar="index">
<f:facet name="header">
#{columnUntilHours.untilhours}
</f:facet>
<h:selectBooleanCheckbox value="#{columnUntilHours.checked}" >
</h:selectBooleanCheckbox>
</p:columns>
</p:dataTable>
I checked initialization of WorkHours object and it seems everythings's in place. Is there any reason why I p:columns doesn't work (and when I put it out, the workday presentation as row works)?
Thanks in Advance !
I do not believe it is possible to mix dynamic and static columns within a single Primefaces dataTable. You must choose one method or the other.
If you wish to show the workday column within this then perhaps you can create create a viewable composite entity type that combines properties of both workday and the row entities into a single type. Workday can be just another object that always exist in your dynamic column collection.