1
我已經儘可能檢查了,但是我找不到問題所在,我已經看到了幾個與我的相關的堆棧溢出問題,但大多都是失蹤 # 。 和我已經看到的地方,舊版本的mojora lib可能會導致這種異常。我檢查了名稱,我在冬眠豆他們都看起來不錯,但無法找到問題.....在類型java.lang.String中找不到屬性'productCategoryName'
我的Html頁面:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:t="http://myfaces.apache.org/tomahawk">
<h:body>
<ui:composition template="/WEB-INF/templates/layout.xhtml">
<ui:param name="category" value="Admin" />
<ui:param name="item" value="Create User" />
<ui:param name="user" value="#{createUserAccountBean}" />
<ui:define name="content">
<h:form id="productsForm">
<div class="headerbg">
<div id="innerheaderbg">
<div id="iconarea">
<img src="#{request.contextPath}/images/headerimages/productlist.png" />
</div>
<div id="headertextarea">
<p class="headingtext">Order</p>
<p id="breadCrumbtext">Order  <img src="#{request.contextPath}/images/error-bullet.gif" />
 Product Category List
</p>
</div>
<div id="otherarea"></div>
</div>
</div>
<p:growl />
<div class="widget widget-table action-table">
<div class="widget-header"> <i class="icon-th-list"></i>
<h3>Product List</h3>
<p:spacer width="10px" height="30px"/>
<h:outputLabel value="Product Category" style="color:#0A8FFF;font-weight:bold;margin-bottom:50px;"/>
<p:selectOneMenu value="#{productBean.productCategoryId}" id="pFilter" >
<f:selectItem itemLabel="--All--" itemValue="all" noSelectionOption="false"/>
<f:selectItems value="#{productCategoryBean.categoriesList}" var="category"
itemLabel="#{category.productCategoryName}"
itemValue="#{category.productCategoryId}" />
<p:ajax update=":productsForm:productsTable" event="change" listener="#{productBean.filterProducts}" />
</p:selectOneMenu>
</div> <!-- /widget-header -->
<div class="widget-content">
<p:dataTable id="productsTable" value="#{productBean.products}" var="products" rowIndexVar="rowIndex"
paginator="true" rows="10" paginatorPosition="bottom"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}" widgetVar="dt_products">
<p:column headerText="S.No">#{rowIndex+1}</p:column>
<p:column headerText="Product Name">#{products.name}</p:column>
<p:column headerText="Product Code">#{products.code}</p:column>
<p:column headerText="Price">#{products.price}</p:column>
</p:dataTable>
</div> <!-- /widget-content -->
</div>
</h:form>
<br></br>
</ui:define>
</ui:composition>
</h:body>
</html>
,這裏是我的豆,ProductCategoryBean.java:
@Named(value = "productCategoryBean")
@Scope("session")
public class ProductCategoryBean
{
private java.util.List<ProductCategory> categoriesList;
public java.util.List<ProductCategory> getCategoriesList()
{
categoriesList.removeAll(Collections.singleton(null));
return categoriesList;
}
public void setCategoriesList(java.util.List<ProductCategory> categoriesList)
{
this.categoriesList = categoriesList;
}
}
上午初始化類列表,而登錄在LoginBean.java
@Named(value = "loginBean")
@Scope("session")
public class LoginBean {
@Inject
private UserService userService;
@Inject
private StocktrackService stocktrackService;
@Inject
private MenuController menuController;
@Inject
private CheckOut checkOut;
@Inject
private ProductCategoryBean categoryBean;
@Inject
private ProductsBean productsBean;
private String userName;
private String password;
private String statusMessage;
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getStatusMessage() {
return statusMessage;
}
public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage;
}
public String login() throws EncryptionException, ServiceException
{
StringEncrypter se = new StringEncrypter("DES");
String encpassword = se.encrypt(getPassword());
UserAccount userAccount = userService.validateLogin(userName,
encpassword);
if (userAccount == null) {
statusMessage = "The username or password is incorrect.";
return "login.xhtml";
}
session.setAttribute("UserAccount", userAccount);
statusMessage = "";
menuController.setTopmenu(menuLoader(userAccount));
checkOut.setUserId(userAccount.getUserId());
checkOut.setUsername(userAccount.getUserName());
checkOut.setUserAccount(userAccount);
//setting category list of ProductCategoryBean
categoryBean.setCategoriesList(stocktrackService.getProductCategory());
//setting product list of ProductListBean
productsBean.setProducts(stocktrackService.getProduct());
return "/pages/leave/home.xhtml?faces-redirect=true";
}
}
正在以下錯誤:
> Feb 09, 2015 1:04:54 PM
> com.sun.faces.application.view.FaceletViewHandlingStrategy
> handleRenderException SEVERE: Error Rendering
> View[/pages/order/products.xhtml] javax.faces.FacesException:
> javax.el.PropertyNotFoundException: /pages/order/products.xhtml @52,59
> itemLabel="#{category.productCategoryName}": Property
> 'productCategoryName' not found on type java.lang.String at
> javax.faces.component.UIComponentBase$AttributesMap.get(UIComponentBase.java:2364)
> at
> org.primefaces.renderkit.InputRenderer.createSelectItem(InputRenderer.java:102)
> at
> org.primefaces.renderkit.InputRenderer.getSelectItems(InputRenderer.java:86)
> at
> org.primefaces.component.selectonemenu.SelectOneMenuRenderer.encodeMarkup(SelectOneMenuRenderer.java:71)
> at
> org.primefaces.component.selectonemenu.SelectOneMenuRenderer.encodeEnd(SelectOneMenuRenderer.java:65)
> at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
> 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:845)
> 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:419)
> at
> com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
> at
> com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
> at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
:太好了,其工作.could請你告訴我最好的做法,以避免和調試這種在網絡錯誤的applications.Normally你是什麼做調試這種情況。因爲代碼已經寫了一些,現在正在執行.....浪費了6個小時的兄弟.... – 2015-02-09 11:15:45