I'm using JSF 2.1, Richfaces 4.2.2 and for below mentioned code I'm getting java.io.NotSerializableException: org.richfaces.component.SavedState exception.
Bean Scope: Session
Facelet code:
<rich:dataTable id="table" value="#{mapActivityGroup.addActivityGroupModelList}"
var="model">
<rich:column>
<h:selectBooleanCheckbox id="checkBox" value="#{model.selected}" />
</rich:column>
<rich:column filterValue="#{mapActivityGroup.categoryFilter}"
filterExpression="#{fn:containsIgnoreCase(model.categoryName,
mapActivityGroup.categoryFilter)}" >
<f:facet name="header">
<h:panelGroup>
<h:outputText value="Category" />
<h:inputText value="#{mapActivityGroup.categoryFilter}">
<a4j:ajax render="table" execute="#this" event="blur" />
</h:inputText>
</h:panelGroup>
</f:facet>
<h:outputText value="#{model.categoryName==null?'':model.categoryName}"/>
</rich:column>
</rich:dataTable>
Exception:
java.io.NotSerializableException: org.richfaces.component.SavedState
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
java.util.HashMap.writeObject(HashMap.java:1100)
sun.reflect.GeneratedMethodAccessor1947.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1362)
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1170)
java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1362)
I have googled but couldn't found anything substantial. Does anyone has any idea why is it happening ?
In web.xml I changed javax.faces.STATE_SAVING_METHOD to server and it worked.
Related
Consider the following Primefaces 5.3 JSF code fragment:
<p:column sortBy="#{benutzer.emailAdresse}" headerText="#{res.com_lbl_column_header_email}"
filterBy="#{benutzer.emailAdresse}" filterStyle="margin-top:5px;" filterPosition="bottom" filterOptions="contains">
<f:facet name="filter">
<p:autoComplete id="dynaEmail" dropdown="true" inputStyleClass="inputFilterM" queryDelay="300"
value="#{benutzerListBean.dyna_search_email}" completeMethod="#{benutzerListBean.completeTextEmail}"
style="margin-left:10px;" cache="false" onchange="PF('tblBenutzer').filter()">
<p:ajax event="keyup" update="dynaVorname, dynaNachname" listener="#{benutzerListBean.dynaSearchStringValueChanged}" />
<p:ajax event="itemSelect" update="dynaVorname, dynaNachname"
listener="#{benutzerListBean.dynaSearchStringValueChanged}" />
</p:autoComplete>
<p:commandButton icon="ui-icon-trash" style="margin-left:35px;">
<f:param name="sender" value="dyna_search_email" />
<p:ajax event="click" update="tblBenutzer, dynaEmail" listener="#{benutzerListBean.resetCurrentFilter}" />
</p:commandButton>
</f:facet>
<h:outputText value="#{benutzer.emailAdresse}" />
</p:column>
So autocomplete in filter.The autocomplete dropdown menu works perfectly, but as I type something in I have a strange exception:
2015-12-21 19:08:30,739 INFO [javax.enterprise.resource.webcontainer.jsf.context] (http-/0.0.0.0:8443-5) java.lang.ClassCastException: javax.faces.component.UIPanel cannot be cast to javax.faces.component.ValueHolder: java.lang.ClassCastException: javax.faces.component.UIPanel cannot be cast to javax.faces.component.ValueHolder
at org.primefaces.component.datatable.feature.FilterFeature.populateFilterMetaDataWithoutColumnGroups(FilterFeature.java:346) [primefaces-5.3.jar:5.3]
at org.primefaces.component.datatable.feature.FilterFeature.populateFilterMetaData(FilterFeature.java:259) [primefaces-5.3.jar:5.3]
at org.primefaces.component.datatable.feature.FilterFeature.decode(FilterFeature.java:90) [primefaces-5.3.jar:5.3]
at org.primefaces.component.datatable.DataTable.processValidators(DataTable.java:716) [primefaces-5.3.jar:5.3]
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:575) [jsf-impl-2.2.12.jar:2.2.12]
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183) [jsf-impl-2.2.12.jar:2.2.12]
at org.primefaces.component.api.UIData.visitTree(UIData.java:822) [primefaces-5.3.jar:5.3]
I've tried to move the code to "header" facet, and it worked.. but this way the sorting works weard.
How can I fix the exception?
I'm trying to fill my input with a value from a parametrized method as I can't access to this value directly with a getter.
<c:forEach items="#{operationBean.tableFields}" var="tableField" varStatus="status">
<rich:column>
<f:facet name="header">
<h:panelGroup>
<h:outputText value="#{operationBean.findLabel(tableField)}"/>
<h:inputText value="#{operationBean.filters[tableField]}" layout="block">
<a4j:ajax event="keyup" render="table" execute="#table"/>
</h:inputText>
</h:panelGroup>
</f:facet>
<c:choose>
<c:when test="#{operationBean.editableColumn(tableField)}">
<rich:inplaceInput value="#{operationBean.findOperationFieldValue(operation, tableField)}"
valueChangeListener="#{operationBean.changeOperationFieldValue}"
saveOnBlur="false">
<f:attribute name="tableField" value="#{tableField}"/>
<f:attribute name="operation" value="#{operation}"/>
<a4j:ajax execute="#this"/>
</rich:inplaceInput>
</c:when>
<c:otherwise>
<h:outputText value="#{operationBean.findOperationFieldValue(operation, tableField)}"/>
</c:otherwise>
</c:choose>
</rich:column>
</c:forEach>
Obviously, JSF tries to call a setter for the rich:inplaceInput, cannot find it, and throws
javax.el.PropertyNotWritableException: /faces/operations/table.xhtml #29,56 value="#{operationBean.findOperationFieldValue(operation, tableField)}": Illegal Syntax for Set Operation
I don't need this attempted call to a setter, as the valueChangeListenerdoes what I need.
I could create my own component and override UIInput.updateModel() but that would be a pain.
I'm implementing a p:dataTable component, based on the Primefaces Showcase
The code is:
<p:dataTable
id="newDataTable"
editable="true"
editMode="cell"
var="item"
value="#{myBean.listNewDataTable}">
<p:ajax event="cellEdit" listener="#{myBean.newCellEditListener}" update="#this"/>
<p:column width="150" >
<p:cellEditor>
<f:facet name="output">
<h:inputText value="#{item.description}" readonly="true"/>
</f:facet>
<f:facet name="input">
<p:selectOneMenu value="#{item.id}" style="width: 90%;">
<f:selectItems value="#{myBean.productsMap.entrySet()}" var="entry" itemValue="#{entry.key}" itemLabel="#{entry.value}" />
</p:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
-- More Data --
</p:dataTable>
And the backing bean method:
public void newCellEditListener(CellEditEvent event){
... Some work here ...
}
When the value on the editable cell is changed, the p:cellEditor works as expected.
The problem is:
When the value on the editable cell remains unchanged, the p:cellEditor shows the item.id when it should actually be showing the item.description.
Am I missing something obvious? Do I need additional configuration?
I have been googling for a tip or an answer, without success.
UPDATE
Same problem persists on the following code:
<p:column headerText="Money" width="150" >
<p:cellEditor >
<f:facet name="output">
<h:inputText value="#{actual.money}" readonly="true">
<f:convertNumber type="currency" />
</h:inputText>
</f:facet>
<f:facet name="input">
<h:inputText value="#{actual.money}">
</h:inputText>
</f:facet>
</p:cellEditor>
</p:column>
The value on the backing bean its the same for input and output, the difference between each other should be the 'currency' format.
UPDATE
As a workaround I used "p:commandButton" to update the Datatable.
<p:commandButton icon="ui-icon-refresh" update="newDataTable" value="Update" />
The app is running on:
Primefaces 3.5
Primefaces Extensions 0.7.1
Mojarra 2.1.22
Tomcat 7
Thanks for your help.
Kind regards.
Values in output and input should be the same. Try to fix that.
Found the issue reported and fixed on the Primefaces issue site: http://code.google.com/p/primefaces/issues/detail?id=6116
I downloaded the 4.0.RC1 and I do see the issue as being resolved as reported but there are some major differences in 4.0 versus 3.5 so I'm going to be waiting for 3.5.15 to be released.
i'm using richfaces 3.3.3 I've a rich:dataTable inside another rich:dataTable and both have a rich:dataScroller but the inner doesn't work:
<rich:dataTable id="dataTableVisibility" value="#{jsfGridUtenti.itemKeys}"
var="roleName" cellspacing="1"
cellpadding="1" border="1"
styleClass="tab" style="width:60%"
rowClasses="rdispari,rpari"
headerClass="headTab" rows="3"
rendered="#{jsfGridUtenti.renderPanelReportVisibility}">
<f:facet name="footer">
<rich:datascroller for="dataTableVisibility"
fastStep="10" pagesVar="pageCountCl"
pageIndexVar="pageIndexCl"
maxPages="9" renderIfSinglePage="false"
selectedStyle="font-weight:bold;">
</rich:datascroller>
</f:facet>
<h:column>
<f:facet name="header">
#{applicationMessages.ruolo}
</f:facet>
<a4j:commandLink reRender="reportUserVisibilityCompanyRoleClass" action="#{jsfGridUtenti.deleteAssociationRole(roleName)}">
<h:graphicImage styleClass="toolbarLabel" url="../resources/img/cancella.png" />
</a4j:commandLink>
<rich:spacer height="1" width="8" />
<h:outputText style="font-size:11px" value="#{roleName}"/>
</h:column>
<h:column>
<f:facet name="header">
#{applicationMessages.companyAssociate}
</f:facet>
<h:column>
<rich:dataTable id="dataTableCompany"
var="company" value="#{jsfGridUtenti.findCompanyInHashMap(roleName)}"
style="width:100%" rows="5"
rowClasses="rdispari,rpari"
columnsWidth="10%,10%,80%"
headerClass="headTab">
<f:facet name="footer">
<rich:datascroller for="dataTableCompany"
fastStep="10" pagesVar="pageCountCls"
pageIndexVar="pageIndexCls"
maxPages="9" ajaxSingle="true"
selectedStyle="font-weight:bold;"
renderIfSinglePage="false">
</rich:datascroller>
</f:facet>
<h:column>
<a4j:commandLink reRender="reportUserVisibilityCompanyRoleClass" action="#{jsfGridUtenti.deleteAssociationCompany(roleName,company)}">
<h:graphicImage styleClass="toolbarLabel" url="../resources/img/cancella.png" />
</a4j:commandLink>
</h:column>
<h:column>
<a4j:commandLink immediate="true" action="#{jsfGridUtenti.setCompanyToShow(roleName,company)}"
reRender="showClassi,panelGridReport">
<h:graphicImage styleClass="toolbarLabel" url="../resources/img/lente.png" />
</a4j:commandLink>
</h:column>
<h:column>
<h:outputText style="font-size:11px" value="#{company.label}"/>
</h:column>
</rich:dataTable>
</h:column>
</h:column>
</rich:dataTable>
Now when I click on the outer rich:dataScroller it works well, instead when I click on the inner nothing happens. How can I fix?
This is a known issue. rich:datascroller doesn't support nested iteration components such as dataTable, repeat etc.
There is a JIRA issue for this.
Did you say 'nothing happens'? Did you look at your console? Doesn't it display a warning like this?
The requested page #2 isn't found in the model containing 1 pages. Paging is reset to page #1
I got the same warning message and solved it by adding a session variable like:
<rich:dataScroller for="table" page="#{sessionBean.page}" />
In my case the bean wasn't accessible (due to scope) before I changed the code. I was on the wrong track because I would have expected a warning/error pointing out that the problem is related to the expression language.
I have problem with datatable using Primefaces 2.2.1 and JSF 2.0.
I have used filtering and paging in the datatable. When I try to filter the selected data is displayed and when i remove the filter the entire data is displayed. But after this when i try to use paging then suddendly all the rows becomes blank(empty)
See screenshot below
Any suggestions. Please help.
.xhtml file
<p:dataTable var="user" value="#{userManagedBean.searchUsersResults}"
selection="#{userManagedBean.selectedUser}" selectionMode="single"
dynamic="true"
onRowSelectUpdate="userUpdateForm"
onRowUnselectUpdate="userUpdateForm"
rowSelectListener="#{userManagedBean.onUserSelect}"
rowUnselectListener="#{userManagedBean.onUserUnselect}"
paginator="true" rows="10" style="width: 70% ">
<p:column sortBy="#{user.userId}" filterBy="#{user.userId}" >
<f:facet name="header">
<h:outputText value="Id" />
</f:facet>
<h:outputText value="#{user.userId}" />
</p:column>
<p:column sortBy="#{user.username}" filterBy="#{user.username}">
<f:facet name="header">
<h:outputText value="Name" />
</f:facet>
<h:outputText value="#{user.username}" />
</p:column>
<p:column sortBy="#{user.emailId}" filterBy="#{user.emailId}">
<f:facet name="header">
<h:outputText value="Email" />
</f:facet>
<h:outputText value="#{user.emailId}" />
</p:column>
<p:column sortBy="#{user.dob}" filterBy="#{user.dob}">
<f:facet name="header">
<h:outputText value="DOB" />
</f:facet>
<h:outputText value="#{user.dob}" >
<f:convertDateTime pattern="MM/dd/yyyy" />
</h:outputText>
</p:column>
</p:dataTable>
<p:panel id="userDetailsPanelId" header="Users Details" style="width:60%;">
<h:panelGrid columns="2" cellpadding="2" id="userUpdateForm" border="0" >
<h:outputLabel for="#{userManagedBean.selectedUser.userId}" value="UserId"/>
<h:inputText value="#{userManagedBean.selectedUser.userId}" style="width: 100%;" readonly="true"></h:inputText>
<h:outputLabel for="#{userManagedBean.selectedUser.username}" value="Username"/>
<h:inputText value="#{userManagedBean.selectedUser.username}" readonly="true"></h:inputText>
<h:outputLabel for="#{userManagedBean.selectedUser.emailId}" value="EmailId"/>
<h:inputText value="#{userManagedBean.selectedUser.emailId}" readonly="true"></h:inputText>
<h:outputLabel for="#{userManagedBean.selectedUser.gender}" value="Gender"/>
<h:inputText value="#{userManagedBean.selectedUser.gender}" readonly="true"></h:inputText>
<h:outputLabel for="#{userManagedBean.selectedUser.dob}" value="DOB"/>
<h:inputText value="#{userManagedBean.selectedUser.dob}" readonly="true">
<f:convertDateTime pattern="MM/dd/yyyy" />
</h:inputText>
</h:panelGrid>
</p:panel>
</h:form>
</center>
I encountered the same problem and eventually discovered it was caused by my value object (in this case your user object) not implementing Serializable.
I'm pretty sure that this known issue has been resolved in both the 2.2.RC and the 2.2 final. I suggest updating your jar file.