Primefaces remoteCommand refreshing datatable automatically, setting to first page of DataTable - jsf

When Im on other than frist page of DatTable and im using button from rowExpansion or even commandLink used in row, page is beeing set to first automatically
<p:remoteCommand name="xyz" action="#{xBean.refreshXList()}" process="#this"/>
when this code is deleted DataTable page is not changing to first, ingoreAutoUpdate="true" not helping with it.

Related

Primefaces <p:dataExporter> does not produce Excel download

I'm having a problem with the PrimeFaces component p:dataExporter. Here is my code:
<p:commandButton value="Export to Excel" ajax="false">
<p:dataExporter type="xls" target=":mainForm:mainTable" fileName="export" />
</p:commandButton>
When I click on the button it just refreshes the XHTML page and produces no XLS downloads. I have tried both h:commandButton and h:commandLink but it still doesn't work. Also, I have tried linking POI v3.10 and v3.7 but still the same error. I have no idea how to proceed. Please help.
I'll say my problem that I had with this, I hope this helps:
My problem was that, when the page was reloaded my dataTable was reloaded every time and when I change my data by filter o sort something, the values was newly reloaded and when the user filter by something the dataTable change, but when him click to export, the page newly charge and the values charge again, and the export doesn't had the correct values. I've changed the scope of my ManagedBean from: #ViewScoped to #SessionScoped, of that way when the page is reloaded the values of the query is permanent and when I filter by something and refresh the page, the same values are permanent therefore when i click to export, the correct values are exported.

Primefaces multiple select checkbox bean values in Javascript function

I have a primefaces multiple select table populated from a backing bean. I am using the table.getSelectedRowsCount() javascript widget var to validate atleast one selection and it is working fine.
I now want to throw up a javascript confirmation dialog based on the state of the selected rows. for ex I have a button at the bottom of the table for printing the details of selected rows. I need to check a certain field of the bean and then allow printing.
IN pseudo code
if (#{bean.isComplete})
allowPrinting();
else
// alert user that this row is not yet in complete state
Update and panelGroup on button ajax event as shown in follow.
<h:panelGroup id="validateRerpot">
<h:panelGroup rendered="#{bean.isComplete}">
<script type="text/javascript">alert('show Dialog inplace');</script>
</h:panelGroup>
</h:panelGroup>
Try to update validateReport panel

Skip form validation on command button

I have a JSF page that includes a tree form tag which is rendered depending on some bean property. There are two buttons for next and previous page. I want to skip form validation on the button which goes to the previous page.
I tried the following ways to disable the validation:
Set h:commandButton immediate="true"
Change button by a4j:commandButton ajaxSingle="true" rerender="someparts"
It does not work. Why does the navigation fail when I want to skip validation?
immediate="true" does skip the validation. Make sure you have redeployed successfully, and the there aren't any errors.
I solve problem using a4j:commandButton ajaxSingle="true" reRender=":outhercomponent:formconteningcomponent:component"
reRender needs absolute path to component even if component id unique

refreshing a datatable

dudes, does any of you know how to do this?
i have a page that has a datatable on it. it has a button to delete a row. the button works as expected, when you click it, it will delete the selected row/s. i also have another button that opens a popup window where you search for items and them add them to the said datatable. i am having a hard time figuring out how to refresh the datatable once you click the "select" button on the popup window.
my solution is having a hidden button that will refresh the datatable. it works when i litterally click it. but when i trigger the click event on the popup window using javascript, it doesnt always work. sometime it refreshes, sometimes it doesnt.
what's actually the best way to refresh a datatable?
If you use JSF2.0, there is an option to update part of your application with
<h:form>
...
...(here you have the binding data)
<h:commandButton action="#{yourbean.updateRows}" >
<f:ajax render="tableName" />
</h:commandButton>
</h:form>
EDITED
If you want to invoke it from JAVASCRIPT use:
document.getElementById('elementName').click();
How are you accessing your DataTable in the popup window ? by keeping it in some session variable and in you parent page are you displaying the datatable through some UI Component like GridView ? In that case you can reload your parent window from where you opned the popu windo through javascript. E.g. window.opener.location.reload();
I can think of .. Datatable.AcceptChanges(); But that's for C#..

JSF Datatable current Page Primefaces

I would like to display the current page of a datatable outside of the table (I actually need it for paging a the items on a google maps component). How can I get the current page of the datatable?
Thanks,
D
In tomahawk you can use dataScroller pageIndexVar (only inside datascroller component)
<t:dataScroller for="data_table" pageIndexVar="current_page">
<h:outputText value="#{current_page}" />
</t:dataScroller>
http://myfaces.apache.org/tomahawk-project/tomahawk/tagdoc/t_dataScroller.html

Resources