The following code in my .xhtml works fine:
<h:commandButton id="btnConsultar"
action="#cadastrarProponenteBean.consultarCnpj}"
value="#{messages.tx_consultar}"
styleClass="btnAcao" />
But, when I add a4j:support:
<h:commandButton id="btnConsultar"
action="#{cadastrarProponenteBean.consultarCnpj}"
value="#{messages.tx_consultar}"
styleClass="btnAcao">
<a4j:support event="onclick" />
</h:commandButton>
the application breaks, I get strange errors, and my validation messages('getFacesContext().addMessage') are not shown.
Since I'm using a4j:support just to show a loading gif when user clicks, any advice on how to fix this problem?
I'm using JSF and RichFaces.
PS: already tried a4j:commandButton instead of h:commandButton but same problems...
You should use <a4j:status> similar to:
<a4j:status id="ajaxstatus" rendered="true">
<f:facet name="start">
<h:panelGroup>
<h:graphicImage value="/images/loading.gif" />
</h:panelGroup>
</f:facet>
<f:facet name="stop">
</f:facet>
</a4j:status>
I have it in template. Loading image is displayed during any long action.
I am using JSF 2.2 with PrimeFaces 4.0. I have a <p:dataTable> with live scrolling, lazy loading, row-expansion and cell-editing, etc.
<p:dataTable
id="dtaTable"
selection="#{cont.selectedArray}"
resizableColumns="true"
draggableColumns="true"
var="dataModel"
value="#{cont.yieldBondsModel}"
editable="true"
editMode="cell"
selectionMode="multiple"
rowSelectMode="add"
scrollable="true"
scrollHeight="650"
rowKey="#{modeld.id}+#{model.name}"
rowIndexVar="rowIndex"
filterEvent="enter"
styleClass="screenScrollStyle"
scrollRows="25"
liveScroll="true"
lazy="true"
rows="50"
filteredValue="#{cont.filteredModel}"
widgetVar="dt4"
>
<p:rowExpansion>
<h:panelGrid id="display" columns="2" cellpadding="4" style="width:300px;" styleClass="ui-widget-content grid">
<f:facet name="header" styleClass="dataTableHeader">Other Data</f:facet>
<h:outputText value="id " />
<h:outputText value="#{dataModel.id}"/>
<h:outputText value="Name" />
<h:outputText value="#{dataModel.name}" />
</h:panelGrid>
</p:rowExpansion>
<p:column width="15">
<p:rowToggler />
</p:column>
...
</p:dataTable>
On the first page everything works like a charm. Once I scroll it down, data is getting lazy-loaded perfectly fine, but it has some problems during row-expansion and cell-editing:
In row-expansion, I am getting wrong values. Maybe overlapped values from other row.
Cell-editing is also not working. Once I edit any cell, values are not getting displayed in cell-editor. I have checked in Firebug, there is no value in <h:outputText> as confirmed by the generated HTML <div class="ui-cell-editor-output" style="display: none;"></div>. As you can see, there is no value inside the div.
The backing bean is #SessionScoped.
How is this caused and how can I solve it?
This is a known issue on PrimeFaces, and already reported and fixed in Elite version (4.0.7 if I remember well). However community release does not contain this fix yet. There is an RC for PrimeFaces 5.0 which contains this fix. You can download it and test if it's suits for you needs, but be aware that this is only a release candidate, not a final release. AFAIK the ETA for the 5.0 final is the first half of May.
I get a javax.el.PropertyNotFoundException value="#{col.getValue(row)}": Property 'getValue' not found on the tooltip line. The other #{col.getValue(row)} in the outputPanel and outputText evaluate just fine, which makes me believe there might be a bug in primefaces. Am I doing something wrong? Is there a workaround?
<p:dataTable id="myTable" var="row" value="#{myBean.getRows(5)}">
<p:columns var="col" headerText="#{col.name}" value="#{myBean.columns}">
<p:outputPanel id="tableColumn">
#{col.getValue(row)}
</p:outputPanel>
<h:outputText value="#{col.getValue(row)}" />
<p:tooltip for="tableColumn" value="#{col.getValue(row)}" />
</p:columns>
</p:dataTable>
Using Tomcat 7.0.39 and Primefaces 3.5
Just write #{col.Value(row)} or #{col.value(row)}
So in the following code the ajax inside the header facet does not call the backing bean (but it seems to call the execute and render I think) but the link outside the datatable works perfectly fine does anyone have any Idea why?
<h:commandLink value="Types" >
<f:ajax listener="#{typeBean.sortTypeList()}" execute="#this" render="#this"/>
</h:commandLink>
<p:dataTable id="fluidTable" widgetVar="fluidTable" var="vehBase" value="#{vehicleBean.currentVehicleBaseSet}" >
<p:columnGroup type="header">
<p:row>
<p:column rowspan="" >
<f:facet name="header">
<h:panelGroup>
<h:commandLink value="Types" >
<f:ajax listener="#{typeBean.sortTypeList()}" execute="#this" render="#this"/>
</h:commandLink>
</h:panelGroup>
</f:facet>
</p:column>
</p:row>
</p:columnGroup>
Put data table inside of primefaces panel and instead of h:commandLink use primefaces commandlink or button, if you use primefaces in the page, all components should be in primefaces.
I have a strange situation where using #parent, or even explicit id-s dont work in the update attribute. But #form works fine.
I've made a very simple test case, that includes a simple grid whose behaviour is like this :
Every record inside the grid has a modify button
After the modify button is clicked, it'll modify the server data, and the button will be gone, since it'll be only rendered if the record has NOT been modified.
The modify button is like this :
<!-- this works, since it's using #form in the update attribute -->
<p:column>
<p:commandLink
value="modify record"
process="#this"
action="#{testUserBean.modifyRecord(user)}"
update="#form"
rendered="#{not testUserBean.isRecordModified(user)}" />
</p:column>
Notice that the update attribute makes use of #form which makes it work: when the modify button is clicked, it rerenders and disappears.
Substitute it with #this or #parent or the id of the grid, then it will NOT work. For me it's very logical to use the id of the grid in the update attribute, since i would like to refresh the grid after clicking on the buttton.
I tried making use of rowIndexVar="rowIndex" and myGridId:#{rowIndex}:link, but still aint working.
<!-- this does not work -->
<p:column>
<p:commandLink id="link"
value="modify record"
process="#this"
action="#{testUserBean.modifyRecord(user)}"
update="tblUser"
rendered="#{not testUserBean.isRecordModified(user)}" />
</p:column>
Here are the resources for this simple example :
The xhtml file
The JSF Bean file
The user POJO bean
Im using tomcat 7, and these are my dependencies :
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.4-b09</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.4-b09</version>
<scope>compile</scope>
</dependency>
Tried out primefaces 3.0.M1 also, but it got the same behavior also.
Please share your ideas. Is this a bug or i did something wrong ?
UPDATE
Hello,
I've just finished some testing, but all still fails.
Test 1 (making use of update=":gridRPBDetails") :
The JSF File :
<p:commandLink id="undoLink" value="Undo" process="#this"
action="#{tInputBean.actionUndoRemoveRecord(rpbDetail)}"
update=":gridRPBDetails"
rendered="#{tInputBean.isRemoveRecord(rpbDetail)}"
title="Batalkan buang data" />
The generated xhtml :
<a title="Batalkan buang data" onclick="PrimeFaces.ajax.AjaxRequest('/cashbank/faces/TInput.xhtml',
{formId:'j_idt38',async:false,global:true,source:'gridRPBDetails:0:undoLink',
process:'gridRPBDetails:0:undoLink',update:':gridRPBDetails'});"
href="javascript:void(0);" id="gridRPBDetails:0:undoLink">Undo</a>
Test 2 (making use of update=":gridRPBDetails:#{rowIndex}:undoLink") :
The JSF File :
<p:commandLink id="undoLink" value="Undo" process="#this"
action="#{tInputBean.actionUndoRemoveRecord(rpbDetail)}"
update=":gridRPBDetails:#{rowIndex}:undoLink"
rendered="#{tInputBean.isRemoveRecord(rpbDetail)}"
title="Batalkan buang data" />
The generated xhtml :
<a title="Batalkan buang data" onclick="PrimeFaces.ajax.AjaxRequest('/cashbank/faces/TInput.xhtml',
{formId:'j_idt38',async:false,global:true,source:'gridRPBDetails:0:undoLink',
process:'gridRPBDetails:0:undoLink',update:':gridRPBDetails:0:undoLink'});"
href="javascript:void(0);" id="gridRPBDetails:0:undoLink">Undo</a>
Both tests still fail in terms of clicking the undo button cannot refresh the record of the grid, or even the grid itself.
UPDATE
I've just updated my test using :
<p:commandLink
value="modify record"
process="#this"
action="#{testUserBean.modifyRecord(user)}"
update=":mainForm:tblUser"
rendered="#{not testUserBean.isRecordModified(user)}" />
Notice i used the :mainForm:tblUser, and i've tried the other options and still failed :
:mainForm:tblUser:
:tblUser (when i dont define the form name)
:mainForm:tblUser:#{rowIndex}:linkId
But 1 thing i notice is,nNo matter what i choosed for the update, the update always ends up as tblUser:0
<a onclick="PrimeFaces.ajax.AjaxRequest('/cashbank/faces/test.xhtml',
{formId:'mainForm',async:false,global:true,source:'tblUser:0:j_idt33',
process:'tblUser:0:j_idt33',
update:'tblUser:0'
});" href="javascript:void(0);" id="tblUser:0:j_idt33">modify record</a>
I tried modifying tblUser:0 on the fly using firebug to just tblUser, the partial rendering on the grid works fine.
Im beginning to think that this is a bug when trying to update a grid from inside a grid record.
This has been answered in here.
Here is the quote from the answer :
This is more like a mojarra issue, it should work fine with myfaces
without a wrapper. Workaround is to put a wrapper.
Code:
<h:form id="frm">
<p:outputPanel id="wrapper">
<p:dataTable id="tbl">
//...
<p:commandButton update=":frm:wrapper" />
//...
<p:dataTable>
<p:outputPanel>
</h:form>
Sorry for the late update !
Look at the generated HTML. Since the <p:commandLink> is placed in a <p:dataTable>, its generated client ID is something like this
<a id="someformid:tblUser:0:link">
The 0 is the table row index.
So when you use the relative identifier update="tblUser" on <p:commandLink>, then it will basically search for someformid:tblUser:0:tblUser to update. But this does not exist. You'd like to use an absolute identifier instead, starting with :.
<p:commandLink update=":someformid:tblUser">
<p:dataTable id="mytable"
value="#{dataTableWithLinkBean.list}" var="item">
<p:column>
<f:facet name="header">
Code
</f:facet>
<p:commandLink actionListener="#{dataTableWithLinkBean.viewDetail}"
oncomplete="dlg.show()" process="#this"
update=":mainform:dialog_content">
<h:outputText value="#{item.code}"/>
<f:param name="code" value="#{item.code}"/>
</p:commandLink>
</p:column>
</p:dataTable>
<p:dialog widgetVar="dlg" modal="true" id="dialog"
width="300" height="300">
<h:panelGrid id="dialog_content">
<h:outputText value="#{dataTableWithLinkBean.selectedCode}"/>
</h:panelGrid>
</p:dialog>
Above is the example of link in the datatable that render the dialog.
may be you can try to change
update=":mainform:dialog_content"
to
update=":mainform:mytable"
in this case my tag form is using id mainform, shown as below:
Please note that I've not been trying this. I just have used in my example above to rendering the dialog panel partially. Good luck
Update:
Well I give it a try like this, combine with your updated post
<p:dataTable id="mytable"
value="#{dataTableWithLinkBean.list}" var="item">
<p:column>
<f:facet name="header">
Code
</f:facet>
<h:outputText value="#{item.code}"/>
</p:column>
<p:column>
<p:commandLink value="Modify"
action="#{dataTableWithLinkBean.removeDetail(item)}"
process="#this"
update="mytable"
rendered="#{not dataTableWithLinkBean.isModifier(item)}">
</p:commandLink>
</p:column>
</p:dataTable>
And in the backing bean
public String removeDetail(ClassForTest item){
for(ClassForTest o: list){
if(o.equals(item)){
//do something update to database
item.setModified(true);
break;
}
}
return "";
}
public boolean isModifier(ClassForTest item){
return item.isModified();
}
And it's worked! after I click on the modify button, call the removeDetail method, do some actions, update the modified status. then do update="mytable", and the link modify is gone.
I'm using Mojarra 2.0.4 and primefaces 3.0.M2
FYI, I'm using DataModel in the backing bean, just a simple List
so no rowIndexVar. Maybe when using the DataModel, can produce this problem.