Im trying to populate a JSF Datatable with data that I am retrieving from a DynamoDB Table (The Amazon NoSQL DB). At the moment everything is working fine right up to the Iteration over the scanResults. The debugger shows that my scanResult has a list of all the accounts but when I try to iterate over those results in order to construct my List nothing seems to be added to the allUserSummary List and I end up with a nullpointer exception.
The basic User POJO:
public class User {
private String uuid;
public User(String uuid) {
this.uuid = uuid;
}
}
The managed bean:
private List<User> allUserSummary;
private List<String> uuid;
private User selectedUser;
public List<User> getAllUserSummary() throws Exception {
populateData();
return allUserSummary;
}
private void populateData() throws Exception {
// Create a new AmazonDynamoDBClient and mapper
AmazonDynamoDBClient client = dynamoClient.getDynamoClient();
DynamoDBMapper mapper = new DynamoDBMapper(client);
try {
// Create a new scan expression and filter to find the required data from the db
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
Map<String, Condition> scanFilter = new HashMap<String, Condition>();
Condition scanCondition = new Condition().withComparisonOperator(ComparisonOperator.NOT_NULL);
scanFilter.put("uuid", scanCondition);
scanExpression.setScanFilter(scanFilter);
// Run the scan
List scanResults = mapper.scan(UserAccounts.class, scanExpression);
// Iterate over the scanned results and add the required data to a new User
for (Iterator it = scanResults.iterator(); it.hasNext();) {
allUserSummary.add(new User(scanResults.get(1).toString()));
}
} catch (Exception e) {
// TODO
}
}
The Datatable (Im using primefaces but the problem is the same with standard JSF DT):
<h:form>
<pou:dataTable id="users"
var="user"
value="#{accountManager.allUserSummary}"
paginator="true"
rows="10"
selection="#{accountManager.selectedUser}">
<f:facet name="header">
UUID
</f:facet>
<pou:column selectionMode="multiple" />
<pou:column headerText="Uuid">
#{user.uuid}
</pou:column>
<f:facet name="footer">
<pou:commandButton id="multiViewButton"
value="View"
icon="ui-icon-search"
update=""
oncomplete=""/>
</f:facet>
</pou:dataTable>
</h:form>
STACK TRACE:
java.lang.IllegalArgumentException: ""
at javax.faces.component.UIComponentBase.findComponent(UIComponentBase.java:570)
at org.primefaces.util.ComponentUtils.findClientIds(ComponentUtils.java:244)
at org.primefaces.renderkit.CoreRenderer.buildAjaxRequest(CoreRenderer.java:222)
at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeMarkup(CommandButtonRenderer.java:81)
at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeEnd(CommandButtonRenderer.java:53)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at org.primefaces.component.datatable.DataTableRenderer.encodeFacet(DataTableRenderer.java:839)
at org.primefaces.component.datatable.DataTableRenderer.encodeTFoot(DataTableRenderer.java:823)
at org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:247)
at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:224)
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:108)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:380)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:680)
here you go...
Set values into update="" and oncomplete="" or remove them from your button...
<pou:commandButton id="multiViewButton"
value="View"
icon="ui-icon-search"
update=""
oncomplete=""/>
EDIT
try the following changes :
private List<User> allUserSummary = new ArrayList<User>();
.
.
.
#PostConstruct
public void populateData() throws Exception {
.
.
.
.
public List<User> getAllUserSummary() throws Exception {
return allUserSummary;
}
Related
In my JSF/PrimeFaces mini web project I want to use a drop down list to select Enum items, then add them to a database when I fill in the 'create' form.
I used Netbeans to create an Entity class from a database, and then used to the wizard 'JSF pages from Entity classes', with PrimeFaces as the template. This creates Create / Edit / List / View xhtml pages automatically.
At the moment I've got:
Enum class:
public enum InterestsEnum {
FOOTBALL,
SKIING,
CYCLING,
MUSIC;
}
Entity class:
#Entity
public class Person implements Serializable {
#Column(name="ID")
#Id
#NotNull
#GeneratedValue(strategy = GenerationType.AUTO)
private Long personId;
#Column(name="FIRSTNAME")
#Basic(optional=false)
#NotNull
#Size(min=1,max=45)
private String firstName;
#Column(name="SURNAME")
#Basic(optional=false)
#NotNull
#Size(min=1,max=45)
private String surname;
#ElementCollection(fetch = FetchType.EAGER, targetClass = InterestsEnum.class)
#JoinTable(name = "Person_INTERESTS", joinColumns = #JoinColumn(name = "PERSON_ID"))
#Column(name = "INTERESTS", nullable = false)
#Enumerated(EnumType.STRING)
Collection<InterestsEnum> interests;
//Getters and Setters:
Managed Bean:
#ManagedBean
#ApplicationScoped
public class Data {
public InterestsEnum[] getInterests() {
return InterestsEnum.values();
}
}
PrimeFaces Create page extract:
<p:selectOneMenu value="#{person.interests}" >
<f:selectItems value="#{InterestsEnum}" />
</p:selectOneMenu>
PrimeFaces List page extract:
<p:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonTitle_interests}"/>
</f:facet>
<h:outputText value="#{item.interests}"/>
</p:column>
When I run the project there are no errors until I open 'List', when the following happens:
Severe: Error Rendering View[/person/List.xhtml]
javax.faces.FacesException: Cannot find component with expression "interests" referenced from "PersonCreateForm:j_idt34".
at org.primefaces.expression.SearchExpressionFacade.resolveComponentInternal(SearchExpressionFacade.java:422)
at org.primefaces.expression.SearchExpressionFacade.resolveComponent(SearchExpressionFacade.java:266)
at org.primefaces.expression.SearchExpressionFacade.resolveComponent(SearchExpressionFacade.java:228)
at org.primefaces.component.outputlabel.OutputLabelRenderer.encodeEnd(OutputLabelRenderer.java:47)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at org.primefaces.component.panelgrid.PanelGridRenderer.encodeDynamicBody(PanelGridRenderer.java:89)
at org.primefaces.component.panelgrid.PanelGridRenderer.encodeBody(PanelGridRenderer.java:60)
at org.primefaces.component.panelgrid.PanelGridRenderer.encodeEnd(PanelGridRenderer.java:49)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)
at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:114)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:582)
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
at javax.faces.component.UIForm.visitTree(UIForm.java:381)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:403)
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:322)
at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:60)
at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1004)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:432)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)
If I submit the 'create' form I get the following error:
Severe: javax.faces.component.UpdateModelException: javax.el.PropertyNotFoundException: /person/Create.xhtml #24,71 value="#{Person.interests}": Target Unreachable, identifier 'Person' resolved to null
There is no drop down list to select Enum choices from (see screenshot). Also 'List' shows all the Enum members, not just one.
After simplifying my project and using one table instead of two and updating my Entity class to:
#Column(name = "INTERESTS")
#Enumerated(EnumType.STRING)
private InterestsEnum interests;
I now have a working project which allows a user to choose Enum members when creating or updating entries.
<h:selectOneMenu value="#{personController.selected.interests}" >
<f:selectItems value="#{data.interests}" />
</h:selectOneMenu>
This can be seen below:
actualy my question is how to display a collection in my view :
ex:
<h:outputText value="#{item.machineCollection.get(0).id != null ? item.machineCollection.get(0).id : ''}"/>
even after testing my code if the result is null i got this error
Array index out of range: 0
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
at java.util.Vector.get(Vector.java:694) at
org.eclipse.persistence.indirection.IndirectList.get(IndirectList.java:401)
at sun.reflect.GeneratedMethodAccessor194.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:779) at
javax.el.BeanELResolver.invoke(BeanELResolver.java:528) at
javax.el.CompositeELResolver.invoke(CompositeELResolver.java:257) at
com.sun.el.parser.AstValue.getValue(AstValue.java:134) at
com.sun.el.parser.AstValue.getValue(AstValue.java:183) at
com.sun.el.parser.AstNotEqual.getValue(AstNotEqual.java:58) at
com.sun.el.parser.AstChoice.getValue(AstChoice.java:64) at
com.sun.el.parser.AstDeferredExpression.getValue(AstDeferredExpression.java:63)
at
com.sun.el.parser.AstCompositeExpression.getValue(AstCompositeExpression.java:68)
at
com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:224)
at
org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:169) at
com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
at
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
at
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
at
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at
org.primefaces.component.datatable.DataTableRenderer.encodeRegularCell(DataTableRenderer.java:741)
at
org.primefaces.component.datatable.DataTableRenderer.encodeRow(DataTableRenderer.java:693)
at
org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:601)
at
org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:220)
at
org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:192)
at
org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:74)
at
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at
org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:59)
at
org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:43)
at
org.primefaces.component.panel.PanelRenderer.encodeContent(PanelRenderer.java:198)
at
org.primefaces.component.panel.PanelRenderer.encodeMarkup(PanelRenderer.java:115)
at
org.primefaces.component.panel.PanelRenderer.encodeEnd(PanelRenderer.java:55)
at
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168) at
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at
org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:55)
at
org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:43)
at
org.primefaces.component.layout.LayoutUnitRenderer.encodeEnd(LayoutUnitRenderer.java:51)
at
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
at
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at
javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at
com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:680)
if someone have a solution urgently pleas and thanks
The problem is that you have
item.machineCollection.get(0).id
If you have an empty collection, item.machineCollection.get(0) will not work.
In primeface datatable you can use the var attribute. So if you add var="row" you can do
<p:datatable var="row" value="#{item.machineCollection}" >
<p:column>
<f:facet name="header">
<h:outputText value="Id" />
</f:facet>
<h:outputText value="#{row.id}"/>
</p:column>
....
</p:datatable>
Use not empty operator:
<h:outputText value="#{not empty item.machineCollection ? item.machineCollection.get(0).id : ''}
or write custom JSF function, as described in this topic:
How to create a custom EL function to invoke a static method?
I have two classes that there is a relationship # OneToMany (Pay and Split) the code below:
#Entity
#Table(name="pagamento")
public class Pagamento implements Serializable { //Class Pay
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
#Column(name="idpagamento")
private int id;
...
#ManyToOne()
#JoinColumn(name="idconta")
private Divida coddivida;
and below class Split
#Entity
#Table(name="divida")
public class Divida implements Serializable{
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
#Column(name = "idconta")
private int id;
...
#OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER, mappedBy="coddivida", targetEntity = Pagamento.class)
private List<Pagamento> pagamento;
And I search through the data code below:
public List<Divida> getDividas(){
return getCleanListOfObjects(Divida.class,"from Divida divida");
}
And I'm trying to display in a datatable is as below:
<p:dataTable id="paneluser" value="#{dividaFaces.listofDivida}" var="divida" selection="#{dividaFaces.selectedDivida}"
rowKey="#{divida.id}" selectionMode="sigle" emptyMessage="Não existe Dívida" paginator="true" rows="10">
<f:facet name="header">
Panel de Dívidas Cadastradas
</f:facet>
<p:column headerText="Descricão">
#{divida.descricao}
</p:column>
<p:column id="pagar" headerText="Tela de Pagamento">
<p:commandButton value="Pagar">
<p:ajax oncomplete="pagetela.show()" update="telapgamento"/>
</p:commandButton>
</p:column>
<f:facet name="footer">
Financé v#{sistema.VERSION}
</f:facet>
</p:dataTable>
But it is giving the error below:
Hibernate:
/*
from
Divida divida */ select
divida0_.idconta as idconta0_,
divida0_.datadeinicio as datadein2_0_,
divida0_.descricaodespesa as descrica3_0_,
divida0_.empresa as empresa0_,
divida0_.exercicio as exercicio0_,
divida0_.observacao as observacao0_,
divida0_.operacaobancaria as operacao7_0_,
divida0_.parcela as parcela0_,
divida0_.tipolancamento as tipolanc9_0_,
divida0_.vencimento as vencimento0_
from
divida divida0_
Lista de Dividas: []
Hibernate:
/*
from
Divida divida */ select
divida0_.idconta as idconta0_,
divida0_.datadeinicio as datadein2_0_,
divida0_.descricaodespesa as descrica3_0_,
divida0_.empresa as empresa0_,
divida0_.exercicio as exercicio0_,
divida0_.observacao as observacao0_,
divida0_.operacaobancaria as operacao7_0_,
divida0_.parcela as parcela0_,
divida0_.tipolancamento as tipolanc9_0_,
divida0_.vencimento as vencimento0_
from
divida divida0_
Mar 26, 2013 8:34:31 PM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
SEVERE: Error Rendering View[/menu/principal.xhtml]
java.lang.ClassCastException: br.com.finance.model.Divida cannot be cast to java.util.List
at org.primefaces.component.datatable.DataTable.findSelectedRowKeys(DataTable.java:977)
at org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:624)
at org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:234)
at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:196)
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:82)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:881)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:851)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:439)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Can anyone help me?
You are using selectionMode="sigle". Please notice the missing 'n' in single. The exception you are encoutering here has nothing to do with Hibernate.
I am working on small project and after everything was correctly working suddenly I started to get a javax.el.PropertyNotFoundException: and I still don't what caused the problem, the only changed that I did to the code between its last working version, was a new xhtml, document, that called the categoryController. I don't really know what happened and don't know how to approach the solution. Does anyone has a idea how to tackle this?
I did some research and found that adding the beans.xml, however, I do have have the beans.xml before the problem happened. This is the content of beans.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
This is the categoryController bean:
#Named
#RequestScoped
public class CategoryController {
#EJB
private CategoryEJB categoryEjb;
private Category category = new Category();
private List<Category> categories = new ArrayList<Category>();
// ------------------------------------------------------------- Constructor
public CategoryController() {
}
// -------------------------------------------------------- Business Methods
public String doCreateCategory()
{
category = categoryEjb.createCategory(category);
categories = categoryEjb.findAllCategory();
return "listCategory?faces-redirect=true";
}
This is the form that is being called:
<h:form>
<h1><h:outputText value="Create New Catergory"/></h1>
<h:panelGrid columns="2">
<h:outputLabel value="Name:" for="name" />
<h:inputText id="name" value="#{categoryController.category.name}" title="Name" />
<h:outputLabel value="Description:" for="description" />
<h:inputText id="description" value="#{categoryController.category.description}" title="Description" />
</h:panelGrid>
<h:commandButton value="Create Category" action="#{categoryController.doCreateCategory()}"/>
</h:form>
This is the complete stack I'm getting:
javax.el.PropertyNotFoundException: /product/createCategory.xhtml #15,103 value="#{categoryController.category.name}": Target Unreachable, identifier 'categoryController' resolved to null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
at javax.faces.component.UIInput.validate(UIInput.java:960)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)
at javax.faces.component.UIInput.processValidators(UIInput.java:698)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIForm.processValidators(UIForm.java:253)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1172)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
EDIT:
#Entity
#NamedQueries({
#NamedQuery(name= "findAllCategory", query="SELECT c FROM Category c")
})
public class Category implements Serializable
{
private static final long serialVersionUID = 1L;
#Id #GeneratedValue(strategy= GenerationType.AUTO)
private int category_id;
private String name;
private String description;
#OneToMany(mappedBy = "category_fk")
private List<Product> product_fk;
// ------------------------------------------------------------- Constructor
public Category() {
}
public Category(String name, String description, List<Product> product_fk) {
this.name = name;
this.description = description;
this.product_fk = product_fk;
}
// ---------------------------------------------------- Getters and Setters
public int getCategory_id() {
return category_id;
}
public void setCategory_id(int category_id) {
this.category_id = category_id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<Product> getProduct_fk() {
return product_fk;
}
public void setProduct_fk(List<Product> product_fk) {
this.product_fk = product_fk;
}
The exception says, the property of your bean could not be found. Do you have correct and visible getter/setter methods for category in your bean and the field name in the category object?
Edit:
I just saw, the PropertyNotFoundException does refer to the bean itself, not to fields in the bean. Does your bean have a name? Your #Named should be something like #Named("categoryController") to be found in the context.
I have a datatable inside confirmDialog, I try to put multipleSelection checkbox on it but causing error & data not visible
page:
<h:form>
<p:commandButton update="msgfiles" actionListener="#{globalCounter.reloadList()}"
oncomplete="choose.show()"/>
<p:confirmDialog widgetVar="choose">
<p:dataTable id="msgfiles" var="obj" rows="5" value="#{globalCounter.objectList}"
rowKey="#{obj[0]}" selection="#{globalCounter.selectedObjectList}">
<p:column selectionMode="multiple"/>
<p:column headerText="id">
<h:outputText value="#{obj[0]}"/>
</p:column>
<p:column headerText="name">
<h:outputText value="#{obj[1]}"/>
</p:column>
</p:dataTable>
</p:confirmDialog>
</h:form>
bean:
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
#ManagedBean(name = "globalCounter")
#SessionScoped
public class TestBean implements Serializable {
private List<Object[]> objectList;
public List<Object[]> getObjectList() {
return objectList;
}
public void setObjectList(List<Object[]> objectList) {
this.objectList = objectList;
}
public void reloadList() {
objectList = new ArrayList<Object[]>();
objectList.add(new Object[]{"1", "one"});
objectList.add(new Object[]{"2", "two"});
objectList.add(new Object[]{"3", "three"});
objectList.add(new Object[]{"4", "four"});
objectList.add(new Object[]{"5", "five"});
}
private List<Object[]> selectedObjectList;
public List<Object[]> getSelectedObjectList() {
return selectedObjectList;
}
public void setSelectedObjectList(List<Object[]> selectedObjectList) {
this.selectedObjectList = selectedObjectList;
}
}
error message:
[#|2012-10-03T16:28:36.390+0700|SEVERE|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=29;_ThreadName=Thread-1;|javax.faces.FacesException
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:86)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at atiits.filter.AuthenticateAuthorize.doFilter(AuthenticateAuthorize.java:100)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.comet.CometEngine.executeServlet(CometEngine.java:473)
at com.sun.grizzly.comet.CometEngine.handle(CometEngine.java:341)
at com.sun.grizzly.comet.CometAsyncFilter.doFilter(CometAsyncFilter.java:84)
at com.sun.grizzly.arp.DefaultAsyncExecutor.invokeFilters(DefaultAsyncExecutor.java:161)
at com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java:137)
at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:88)
at com.sun.grizzly.http.TaskBase.run(TaskBase.java:189)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
at java.lang.reflect.Array.newArray(Native Method)
at java.lang.reflect.Array.newInstance(Array.java:52)
at org.primefaces.component.datatable.feature.SelectionFeature.decodeMultipleSelection(SelectionFeature.java:53)
at org.primefaces.component.datatable.feature.SelectionFeature.decode(SelectionFeature.java:39)
at org.primefaces.component.datatable.DataTableRenderer.decode(DataTableRenderer.java:53)
at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:790)
at org.primefaces.component.api.UIData.processDecodes(UIData.java:224)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1042)
at javax.faces.component.UIForm.processDecodes(UIForm.java:216)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1042)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1042)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:941)
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
... 32 more
|#]
[#|2012-10-03T16:28:36.390+0700|WARNING|glassfish3.0.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=29;_ThreadName=http-thread-pool-8080-(1);|StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
at java.io.Writer.write(Writer.java:140)
at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:200)
at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:119)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at atiits.filter.AuthenticateAuthorize.doFilter(AuthenticateAuthorize.java:100)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.comet.CometEngine.executeServlet(CometEngine.java:473)
at com.sun.grizzly.comet.CometEngine.handle(CometEngine.java:341)
at com.sun.grizzly.comet.CometAsyncFilter.doFilter(CometAsyncFilter.java:84)
at com.sun.grizzly.arp.DefaultAsyncExecutor.invokeFilters(DefaultAsyncExecutor.java:161)
at com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java:137)
at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:88)
at com.sun.grizzly.http.TaskBase.run(TaskBase.java:189)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:619)
|#]
[#|2012-10-03T16:28:36.390+0700|WARNING|glassfish3.0.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=29;_ThreadName=http-thread-pool-8080-(1);|StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
at java.io.Writer.write(Writer.java:140)
at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:200)
at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:119)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at atiits.filter.AuthenticateAuthorize.doFilter(AuthenticateAuthorize.java:100)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.comet.CometEngine.executeServlet(CometEngine.java:473)
at com.sun.grizzly.comet.CometEngine.handle(CometEngine.java:341)
at com.sun.grizzly.comet.CometAsyncFilter.doFilter(CometAsyncFilter.java:84)
at com.sun.grizzly.arp.DefaultAsyncExecutor.invokeFilters(DefaultAsyncExecutor.java:161)
at com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java:137)
at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:88)
at com.sun.grizzly.http.TaskBase.run(TaskBase.java:189)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:619)
|#]
If I remove <p:column selectionMode="multiple" style="width:18px" /> from the page everything is fine and data displayed
Where did I go wrong?
Primefaces 3.4/ Mojarra 2.0.2 (FCS b10)/Glassfish 3.0.1
I had the same problem and I solved it using <h:form> and <p:ajax>
<p:dataTable id="msgfiles" var="obj" rows="5" value="#{globalCounter.objectList}" rowKey="#{obj[0]}" selection="#{globalCounter.selectedObjectList}">
<p:ajax event="rowSelectCheckbox" process="#this"/>
<p:ajax event="rowUnselectCheckbox" process="#this"/>
<p:ajax event="toggleSelect" process="#this"/>
</p:dataTable>
That should force your component to populate the array in your bean
I had similar issues and I solved it using <p:ajax>.
First I would do as akoskm says and have a unique row key.
Then I would use an array (List[]) (List is more generic than ArrayList) for selectedItems
And finally you can add:
<p:dataTable ...>
<p:ajax event="rowSelectCheckbox" process="#this"/>
<p:ajax event="rowUnselectCheckbox" process="#this"/>
<p:ajax event="toggleSelect" process="#this"/>
</p:dataTable>
Just make sure you have an <h:form> around the table
That will make sure that the component pushes the data to the bean.
Your problem is very similar to this one:
Primefaces datatable: Unable to retrieve selected rows and selection get lost with pagination.
I would try to use
rowKey="#{obj}" as key.