Primefaces function clearFilters() doesn't work - jsf

I have the following code:
<p:tree value="#{sessBean.root}" var="node" animate="true" id="idTree" selectionMode="single" selection="#{sessBean.selectedNode}" >
<p:ajax listener="#{reqBean.doBtnSearch}" event="select" onstart="PF('tblDataWidget').clearFilters();" update=":form1:tabView:tblData" />
<p:treeNode>
<h:outputText value="#{node.descr}" />
</p:treeNode>
</p:tree>
<p:commandButton value="Add" icon="ui-icon-plus" id="doBtnAdd" action="#{reqBean.doBtnAddEntry}" update="tblData" oncomplete="PF('tblDataWidget').clearFilters();" />
I have a dataTable (tblData) with many entries, which are loaded and displayed when a tree node is clicked. So far, no problems. Datatable has filters on some columns, which also works fine. The problem appears, when I want to clear the filter (on button and tree node click). When I click the 'Add' button (see the code above), the filters are cleared as expected, but when I click on a tree node, clearing the filters doesn't work. Both commandButton and tree component are contained in a tabView container.
What am I doing wrong?
Thank you for your suggestions!
PS: using PrimeFaces 5.1

Try it :
<p:ajax listener="#{reqBean.doBtnSearch}" event="select" onstart="PF('tblDataWidget').clearFilters();" update="#{p:component('tblData')},#{p:component('idTree')}" />

Related

Toggle primefaces Tree - Checkbox Selection by clicking just checkbox directly

Hi I'm using the component Tree - Selection with the variant Checkbox.
Everything in the component is working fine but I need to put a button next to every child of my nodes to make something happen with the id of that node, the problem is that if I press the button that unchecks that node.
This is my code:
<p:tree value="#{puntoscontrolController.rootDevices}" var="dev"
selectionMode="checkbox" selection="#{puntoscontrolController.selectedDevNodes}" style="border: none;"
>
<p:ajax event="select" listener="#{puntoscontrolController.selectUnidad(dev)}" update="growl"/>
<p:ajax event="unselect" listener="#{puntoscontrolController.unselectUnidad(dev)}" update="growl"/>
<p:treeNode type="ruta" icon="fa fa-list-ol">
<h:outputText value="#{dev.ruta}"/>
</p:treeNode>
<p:treeNode type="unidad" icon="fa fa-bus" >
<h:outputText value="#{dev.nombre}"/>
<button onclick="centrar(#{dev.idTraccar});">→</button>
</p:treeNode>
</p:tree>
And the result seems like this:
Image of tree checkbox selection
The problem is that if i click anything inside the darker area of the node it unchecks that node so my question is if I can make the checkbox tree to make the selection event to happen just in the checkbox and not in the things inside the p:treenode?
I'm aware that this was possible in previous versions like 3.4.1 but I'm currently using the 6.0 version because I need some new features.
I resolved that with stopping the event from propagating as suggested by #Kukeltje. To achieve that I used this code:
onclick="centrar(#{dev.idTraccar});event.stopPropagation();"

Render rich:extendedDataTable

I need a rich:popup that shows a rich:extendedDataTable, and when the user presses a button, the popup should be shown, and the extendedDataTable must be re-rendered, here is the code:
<rich:popupPanel id="popupId" show="false" modal="true">
<h:form>
<rich:extendedDataTable
value="#{bean.list}"
var="item" rows="5" id="table">
<rich:column>
<h:outputLabel value="#{item}" />
</rich:column>
</rich:extendedDataTable>
<a4j:commandButton value="x" immediate="true"
oncomplete="#{rich:component('popupId')}.hide(); return false;"/>
</h:form>
</rich:popupPanel>
<h:form>
<a4j:commandButton value="show"
oncomplete="#{rich:component('popupId')}.show(); return false;"
render="table" immediate="true" />
</h:form>
The first time I press the show it works fine, but when I close the panel with the X button and press again the show button, the extendedDataTable appears empty (It's rendered but appear empty, see image below).
The problem is fixed if I add an empty extendedDataTable before the popup, like this:
<rich:extendedDataTable />
<rich:popupPanel>
...
With rich:dataTable the problem doesn't exits, but I need a extendedDataTable.
And aditional extrange behaviour is when I resize the browser, the data appears.
Platform
RichFaces: 4.2.2.Final
Spring: 3.1.1.RELEASE
Cheers
Use onclick instead of oncomplete. ExtendedDataTable doesn't render properly inside invisible elements (it's a bug) so the popupPanel has to be made visible before the rerendering.
I had kinda the same issue.
I solved it in a not 100% richface correct way:
<a4j:commandButton
value="show"
action="#{actionForm.setShowEditor('true')}"
oncomplete="javascript:location.reload(true)"/>
<a4j:region layout="block" rendered="#{actionForm.showEditor}" id="panelArea">
<rich:popupPanel id="#{popupID}" modal="true" show="true" domElementAttachment="parent">
....
tabel
buttons
....
</rich:popupPanel>
</a4j:region>
The popup is always shown (show="true") inside the a4j:region.
But the a4j:region is only shown if variable to show the popup = true.
The full page refresh was in my case needed because otherwise my ckeditor had some initialisation errors. It should also work if you only rerender the a4j:region after you set the "#{actionForm.setShowEditor('true')}.

Primefaces blockUI stops responding

I have a datatable and a commandbutton. I want to use blockui when user either clicks to datatable paginators or refresh button. At first blockui works with paginators good but after when I click to commandbutton, blockui works once and then it stops working. Is there any idea?
<p:commandButton value="refreshDatatable"
id="refreshLogListButtonId2"
onclick="loading.show();"
oncomplete="loading.hide();"
immediate="true"
update="logsTableId"
icon="ui-icon-refresh"
actionListener="#{logViewerController.refreshLogsFromDB()}"/>
<p:dataTable id="logsTableId" var="log"....../>
<p:blockUI block="logsTableId" trigger="logsTableId" widgetVar="loading">
Refreshing<br />
<p:graphicImage library="images" name="loading.gif"/>
</p:blockUI>
Did you try to add the id of your in the trigger attribute of the separated by ",", like that:
<p:blockUI block="logsTableId" trigger="logsTableId,refreshLogListButtonId2" widgetVar="loading">
Refreshing<br />
<p:graphicImage library="images" name="loading.gif"/>
</p:blockUI>
Do not update blockUI component. Use either the trigger attribute or the widgetVar, there is no reason to use both.

RichFaces a4j:commandButton. first click does not work the action, it works in the secon click

I have a problem that a I couldn't solve. When I click first time on a a4j:commandButton there is not action. The second and following time it works perfectly. I have read about this problem however I have not clear the solucion.
I am new, and I have find this solucion: (h:commandButton/h:commandLink does not work on first click, works only on second click) however I do not know where should I introduce the script code.
I have found this: however I think is an old jsf version:
(https://community.jboss.org/thread/165031)
And I have tried to repare it with: https://community.jboss.org/wiki/ProgrammaticControlOfPartialProcessingInRichFaces4. However, I have not been success
If someone could explain me the #BalusC solution step by step, it could be really hepful
Thanks very much:
My code is: (everything in the same file)
<ui:define name="table">
<h:form id= "formListCompanies">
<a4j:outputPanel id="tablePaneRegion">
<rich:extendedDataTable ....
<rich:column sortable="false" width="100%">
...
<a4j:commandLink id="editCmd" styleClass="no-decor" render="editGrid, editPane"
execute="#this" oncomplete="#{rich:component('editPane')}.show()">
<a4j:param value="#{it.index}" assignTo="#{myBean.currentIndex}" />
<f:setPropertyActionListener target="#{myBean.selected}" value="#{mypojo}" />
</a4j:commandLink>
....</rich:column>
....
<rich:popupPanel id="editPane" header="#{...}" domElementAttachment="body"
moveable="true" modal="true" resizeable="false" autosized="true"
onshow="focus(#{rich:component('name')});">
....
<!-- h:Inputtext ..-->
<h:panelGrid columns="2">
<a4j:commandButton value="#{'save'}" action="#{myBean.edit}"
render="dataTable" execute="editPaneRegion" />
<a4j:commandButton value="#{...}"
onclick="#{rich:component('editPane')}.hide(); return false;" />
</h:panelGrid>
</h:form>
</a4j:outputPanel>
</rich:popupPanel>
What I have already tried is to take out the h:form id= formListCompanies, and put there a h:panelgrid and a h:panelgroup
Is the problem related to the doble clicking issue? Am i in the right way?
rerender panel and form (form state lost error in jsf spec)... render="richPanelMantenimientoTipoVisualAjaxWebPart,frmMantenimientoTipoVisual"

how to set a value of node in defaultTreeNode

I am using primefaces 3.0 M2, and I use DefaultTreeNode, with the component p:tree and it works fine.
My problem is that I want the value of node selected were be different from the the value of node displayed.
Need your help please!
You may display any text you like for each node. For example, this is a bit changed example from primefaces showcase (TreeBeen.java is the same):
<h:form>
<p:growl id="growl" showDetail="true" />
<p:tree id="treeSingle" value="#{treeBean.root}" var="node"
selectionMode="single" selection="#{treeBean.selectedNode}">
<p:treeNode>
<h:outputText value="Node" />
</p:treeNode>
</p:tree>
<p:commandButton value="Display Selected" update="growl"
actionListener="#{treeBean.displaySelectedSingle}" />
</h:form>
"Node" text is displayed for each node, but it's data value is displayed on button click event.

Resources