Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Bean (View Scope) in JSF to show data
    primarykey
    data
    text
    <p>I'm creating an web application, using <strong>JSF (2.0)</strong>. It has <strong>"ViewProducts.xhtml"</strong> to view Product with page. Each time this page loaded, if parameter has some thing (Eg: <strong>page=1 (ViewProduct.xhtml?page=1)</strong>), it's will automatically set the id to setPage property in that Bean. But, i'm keeping getting this error:</p> <blockquote> <p>Unable to create managed bean <strong>categories</strong>. The following problems were found: - Bean or property class bean.Categories for managed bean categories cannot be found.</p> </blockquote> <p>Here is my code (Categories act like a product container):</p> <p><strong>faces-config.xml:</strong></p> <pre><code>&lt;faces-config version="2.0" 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/web-facesconfig_2_0.xsd"&gt; &lt;navigation-rule&gt; &lt;from-view-id&gt;/template/header.xhtml&lt;/from-view-id&gt; &lt;navigation-case&gt; &lt;from-outcome&gt;ViewCategories&lt;/from-outcome&gt; &lt;to-view-id&gt;/ViewCategories.xhtml&lt;/to-view-id&gt; &lt;/navigation-case&gt; &lt;/navigation-rule&gt; &lt;managed-bean&gt; &lt;managed-bean-name&gt;categories&lt;/managed-bean-name&gt; &lt;managed-bean-class&gt;bean.Categories&lt;/managed-bean-class&gt; &lt;managed-bean-scope&gt;view&lt;/managed-bean-scope&gt; &lt;/managed-bean&gt; </code></pre> <p></p> <p><strong>ViewProducts.xhtml</strong></p> <pre><code>xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" &lt;f:metadata&gt; &lt;f:viewParam name="page" value="#{categories.page}"/&gt; &lt;/f:metadata&gt; &lt;h:dataTable value="#{categories.listProduct}" var="cus"&gt; &lt;h:column&gt; &lt;f:facet name="header"&gt;Name&lt;/f:facet&gt; &lt;h:outputText value ="#{cus.name}"&gt;&lt;/h:outputText&gt; &lt;/h:column&gt; &lt;h:column&gt; &lt;f:facet name="header"&gt;Price&lt;/f:facet&gt; &lt;h:outputText value ="#{cus.price}"&gt;&lt;/h:outputText&gt; &lt;/h:column&gt; &lt;/h:dataTable&gt; </code></pre> <p>Categories.java (ManagedBean)</p> <pre><code>public class Categories implements Serializable { /** Creates a new instance of categories */ public Categories() { } private int page = 0; public int getPage() { return page; } public void setPage(int page) { this.page = page; } public List&lt;Product&gt; listProduct = null; public List&lt;Product&gt; getListProduct() { if (listProduct != null) { return listProduct; } else { listProduct = dataAccess.DataAccess.getCategories(this.page); return listProduct; } } public void setListProduct(List&lt;Product&gt; listProduct) { this.listProduct = listProduct; } } </code></pre> <p><strong>Stack trace:</strong></p> <pre><code>com.sun.faces.mgbean.ManagedBeanCreationException: Unable to create managed bean categories. The following problems were found: - Bean or property class bean.Categories for managed bean categories cannot be found. - Bean or property class bean.Categories for managed bean categories cannot be found. - Bean or property class bean.Categories for managed bean categories cannot be found. - Bean or property class bean.Categories for managed bean categories cannot be found. at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:263) at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:86) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54) at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72) at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:69) at org.apache.el.parser.AstValue.getValue(AstValue.java:112) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:102) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178) at javax.faces.component.UIData.getValue(UIData.java:554) at javax.faces.component.UIData.getDataModel(UIData.java:1248) at javax.faces.component.UIData.setRowIndex(UIData.java:447) at com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:81) at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:823) at javax.faces.component.UIData.encodeBegin(UIData.java:937) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1611) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616) at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380) at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127) 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:313) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:662) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload