Primefaces p:ajax disabled attribute doesn't work - ajax

I'm working with JSF 2.2 (MyFaces) and Primefaces 5. The disabled attribute of p:ajax component in a p:datatable doesn't work.
<p:dataTable id="transactionListTable"
value="#{cardsTransactionsList}"
var="transaction"
selectionMode="single"
rowExpandMode="single" >
<p:ajax event="rowSelect"
disabled="#{condition}"
listener="#{cardTransactionsListCBean.onRowSelect}"
update=":cardsForm:transactionListTable" />
If disabled has value true the ajax call is not disabled. I want disable the row expansion feature when condition is true. Some idea, please? Bye.

Related

JSF and primefaces p:booleancheckbox not rendering correctly

I have a strange behaviour in my code that for some reason I'm unable to solve.
I'm using PF4 and mojarra 2.1.28 running on jboss eap 6.4.
Here's the code
<p:column>
<f:facet name="header">
<p:selectBooleanCheckbox id="checkAll" value="#{backingBean.allowAll}">
<p:ajax listener="#{backingBean.confirmAllowAlla}" process="tablaDoc" update="tablaDoc :form1:facesMessages" onstart="mask();" oncomplete="unmask();" />
</p:selectBooleanCheckbox>
<p:outputLabel for="checkAll" value="Allow all" />
</f:facet>
<p:selectBooleanCheckbox id="checkTipo" value="#{tipoDocumento.allowed}" >
<f:param name="idTipoDocumento" value="#{tipoDocumento.idTipoDocumento}"/>
<f:param name="secuencia" value="#{tipoDocumento.secuencia}"/>
<p:ajax listener="#{backingBean.confirmChange(tipoDocumento)}" process="#this" update="tablaDoc :form1:facesMessages" onstart="mask();" oncomplete="unmask();" />
</p:selectBooleanCheckbox>
</p:column>
Getters and setters exist, backing bean is invoked as it should... apparently everything works but...
when I click in the booleanCheckbox placed in the header all the other checkboxes should be checked.
First time I click internally everything seems to go ok. Model is updated correctly and my datatable is updated accordingly but for the checks. Visually they are not checked (checked="checked" is missing in the output html) but all the expected behaviour is just fine. A button for each row is enabled/disabled and even if I add a column to display the internal value used for the check it renders the expected value.
If I uncheck the main checkbox and check it again, normal behaviour is restored and the checks for each row start rendering ok (checked="checked is in the output html).
I cannot modify my DTOs so I cannot implement SelectableDataModel from PrimeFaces.
Any ideas?

How to set global="false" on primefaces datatable pagination buttons and select

I've been struggling to set global="false" as the attribute of ajax on primefaces that makes ajaxStatus skips this component, however I've handled column filtering event and resize,reorder also sorting, Yet couldn't find any suitable ajax event name to set global to false for datatable pagination buttons/selects events.
On the primefaces datatable
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
Filter reorder, resize, filter and sort events :
<p:ajax event="colReorder" listener="#{dyna.onColumnReorder}" global="false" />-->
<p:ajax event="colResize" listener="#{dyna.onColumnResize}" update=":center_form:tabexam" global="false"/>
<p:ajax event="filter" global="false"/>
<p:ajax event="sort" global="false"/>
What i need now is the pagination event name, i hope that i made my self clear, also a link to all primefaces ajax event names, would be highly appreciated.
I don't believe there is an event for pagination.
Refer to : http://www.primefaces.org/documentation download which ever version but there is a section called Ajax Behaviour Events - page 154 in 4.0.
Page 134 shows all the attributes you can set on the p:datatable
Done.
Using :
<p:ajax event="page" global="false"/>

Primefaces: Update (refresh) p:panel inside p:rowExpansion

I have the following configuration:
JSF: Apache MyFaces JSF-2.1 Core API (Version: 2.1.10)
PrimeFaces 3.4.2
Tomcat 7.0.35
I have a DataTable with rowExpansion and a panel with button in the rowExpansion. I would like to refresh only the panel inside the rowExpansion when the user clicks on the button.
<p:dataTable id="vmt" var="vmtemplate" value="#{myViewBean.myList}" rowKey="#{vmtemplate.id}">
<p:ajax event="rowToggle" listener="#{myViewBean.onRowToggle}" update=":growl" />
<p:column style="width:2%"><p:rowToggler /></p:column>
<p:column>...</p:column>
<p:rowExpansion>
<p:panel id="exp_panel" header="#{vmtemplate.name} Instances">
<h:form id="instancesForm">
<p:commandButton id="refreshRowExpPanel" title="Refresh" update=":growl" action="#{myViewBean.reloadData}"/>
</h:form>
</p:panel>
</p:rowExpansion>
</p:dataTable>
I think I have to set the update property of the refreshRowExpPanel button in order to refresh the exp_panel, but when I set it to update=":growl :expanel" I get an error:
Cannot find component with identifier ":expanel" referenced from
"mainForm:vmt:0:refreshRowExpPanel".
so the generated ID of the panel is "mainForm:vmt:0:refreshRowExpPanel", but when I specify this to the update (update=":mainForm:vmt:0:refreshRowExpPanel") I got the same error:
Cannot find component with identifier
":mainForm:vmt:0:refreshRowExpPanel" referenced from
"mainForm:vmt:0:refreshRowExpPanel".
with update=":mainForm" it works, but it refreshes the whole dataTable and my expanded row will be closed, so it's not fine.
Could you please suggest a solution how to refresh only my panel inside the rowExp, maybe from JS, or any other idea?
thx!
I recommend you to try using ID of the panel without colon on the beginning, so:
update="mainForm:vmt:0:refreshRowExpPanel"
Also you may like to read this post about making references.
I've just realized, that I had a form outside my dataTable:
<h:form id="outerForm">
<p:dataTable id="vmt" var="vmtemplate" value="#{myViewBean.myList}" rowKey="#{vmtemplate.id}">
pansion>
...
</p:dataTable>
</form>
by removing the outer form, and changing the update value to "#form" solved the problem

Primefaces Inline DataTable Delete functionality

I'm using primefaces inline editing datatable.which consists of primefaces RowEditor and a CommandButton to delete the record.My Problem is when i deleted any record from the the database,the row is successfully deleted and the deleted record is showing when i click on the edit button for editing the next record.This edit problem continues with all the records .It is showing the present value in h:outputText and the old value in h:inputText which comes when we click on edit button.
Could anyone help me on this ?
Thankyou all.
There are a lot of Primefaces bugs logged on the <p:dataTable> component, so I am not going to search through all of them.
I do know however that there is an open bug as of Primefaces 2.2.1 stating that components within a row of a <p:dataTable> will not correctly update (refresh) the appropriate values within the dataTable. This problem MAY be fixed in Primefaces 3.0. If you are interested you can search the known bugs here.
Fortunately I have figured out a workaround for this. You need to perform an asynchronous operation from a component OUTSIDE of the <p:dataTable> and make sure that component sets the id of the dataTable in its update attribute.
<h:form id="form1">
<p:commandButton widgetVar="updateButton" update="form1:table1" ... />
<p:dataTable id="table1" ...>
<p:column ...>
<p:commandButton id="deleteButton" action="#{managedBean.doDelete}" oncomplete="javascriptFunction();" ... />
</p:column>
</p:dataTable>
</h:form>
And in a javascript:
function javascriptFunction() {
updateButton.jq.click();
}

Attaching f:ajax to h:panelGroup

Whenever I try to attach a f:ajax to h:panelGroup I get an error:
Parent is not composite component or
of type ClientBehaviorHolder
I used to be able to do it with Richfaces and JSF 1.2.
Is there a workaround? Should I bring in Richfaces 4.0?
It's odd since it's obviously possible (I do it with jQuery for client side actions)
UPDATE
Richfaces 4.0 won't help. Tried it and get the same error.
Code Sample:
<li>
<f:param value="#{contact.getUUID}" name="currContactUUID" />
<f:ajax event="click" onevent="console.log('Event Happend in panelgroup')" >
<h:panelGroup styleclass="contacts_tab_contacts_list_quickview_box">
<h:outputText value="#{contact.firstName} #{contact.familyName}"/>
</h:panelGroup>
</ajax>
</li>
That shouldn't be possible for a panelGroup. f:ajax can only be used for components that implement the javax.faces.component.behavior.ClientBehaviorHolder interface and h:panelGroup doesn't.
You can wrap your components inside the panelGroup with a surrounding ajax tag:
<f:ajax>
... (your components here)
</f:ajax>

Resources