PrimeFaces LazyDataModel advanced filters - jsf

I'm using PrimeFaces LazyDataModel and it's working fine. However, I need to add some advanced filters in my Facelets page. I don't want to use the PrimeFaces native filter, with the filters in the table header. I need advanced filters in a form, and a 'search' button for searching, using the features of primefaces lazy pagination.
Can I do this? Is there a way to call the 'load' method in my search button using my advanced filters?

'Load' method is called every time on update.
You can add ArrayList of filters for your implementation of lazy model and use them in 'load' method

Related

Primefaces fetch dropdown values on show

I have a strange situation where one needs to dynamically populate dropdown values. The best idea I have come up with is creating a button, which triggers ajax request that fetches new dropdown values and on complete updates the dropdown and displays it.
I was wondering if there is any other more elegant way of handling situations like this. I am using the latest primefaces version 11.0.0.
I suggest to use the p:autoComplete component with the dropdown attribute set to true instead. It allows you to get the values when the button is clicked or when a query is typed. You don't need to take care of updating the component yourself. The only thing you need to do is have a completeMethod in your bean or have a completeEndpoint (REST endpoint).
With PrimeFaces 12 you can even (re)use a LazyDataModel as a suggestions provider.

Generic CRUD using JSF and PRimeFaces

I was looking for some general guidelines for creating a generic CRUD page using JSF (2.1) and PrimeFaces (5.0)(specifically using PF's <p:dataTable> component). Some of my requirements are as follows:
Dynamic number of columns (based on the #of columns of a selected Database Table)
Inline editing
Popup (dialog) edit
I have tried using <p:columns> component to show the dunamic #of columns, however, it seems I cannot use the inline editing feature <p:rowEditor> when I use <p:columns>
Any help in terms of suggestions/recommendations is highly appreciated. My goal is not to create seperate pages for each table but to use the same page (component) for multiple DB tables.

How can I implement a custom column filter in icefaces using something like a checkbox?

I'm currently using "filterBy" for filtering via inputText components and its working very well. I'd like to be able to filter one of my columns with the selectBooleanCheckbox component.
It looks like this can be done in primefaces:
Custom filters and converters in p:dataTable
But I'm not quite sure how to do it in icefaces (if at all possible)
According to an ICEfaces developer himself, this is not possible.
http://www.icesoft.org/JForum/posts/list/0/22736.page
As explained in the link, you can use the "filterOptions" attribute to use a h:selectOneMenu with selectItems as a filter, which works for me.

Help needed to create a Search page using JSF, EJB, JPA & Primefaces with Pagination

I am trying to make a search page using JSF, EJB, JPA & Primefaces with Pagination from an Oracle database table.
The page has two regions (1) region for entering search parameters
(2) region with a datatable showing the search result. This datatable supports pagination.
I have used standard code generated using Netbeans IDE, but dont know how to pass the parameters while clicking the search button and show the results based on the search in the datatable.
Please help me with sample code.
Thanks in advance.
For the input, just use a normal form like as you've created in a hello world tutorial. For presentation and pagination of the results, use PrimeFaces LazyDataModel. See also their showcase example.

How to export an OpenFaces DataTable in Excel/CSV Format?

Unfortunately, OpenFaces Datatable has not yet an export capability unlike Primefaces or IceFaces.
While Exporting is a piece of cake, filtering an IceFaces or primefaces datatable is less easy, Yet primeFaces's filtering does not work with JSF DataModel (sad but true).
Using OpenFaces DataTable filtering is a piece of cake and so handy and powerful.
But how about The end user who wants to export a datatable that s/he filtered, to a format like CSV or MS Excel.
The great Dmitry from OpenFaces, gave me a hint :
Use OpenFaces DataTable method: getDisplayedRowDatas() that will grab the currently displayed rows from a datatable, then use some thrid library like Itext to export in PDF for example.
In my head, this should go this way:
Create a backing bean for this purpose.
Add Apache POI third library to the classpath
Write code using Apache POI to export the content of the OpenFaces datatable with its method getDisplayedRowsDatas() - but I am afraid this method does not return the names of columns' headers - or grab the HTML table rendered by an OpenFaces Datatable as a buffered string and use Apache POI to produce an Excel file streamed with the Buffer.
In the MyFaces example I came across recently: MyFaces Datatable Export Example, the developer uses Myfaces component <t:buffer value=#{myExportBean.myBufferString}> datatable here </t:buffer /> to transform the content of the datatable to a buffered String which makes things easier. JSF Core does not have such component unfortunately.
Did someone come across this before? Help or better alternatives are much appreciated.
You can check out the experimental DataTable export API, which is available in the current nightly build. We'll declare this API officially if it stands the test of time. For now, only CSV export is available, but you can write your own exporters for other formats. Here's the code that you should put in your action handler to make it work:
DataTable myTable = Faces.component("form:myTable", DataTable.class);
myTable.export(new CSVTableExporter());
It exports the data for all of the rows and columns as currently displayed by the table (only the current page of a paginated table is exported currently).

Resources