找不到JSF EL Property

时间:2014-12-16 23:35:51

标签: jsf jsf-2 primefaces el

你好我有EL的问题,如果有人可以帮助我,我会很高兴。 我正在尝试创建Primefaces DataTable,我收到了以下错误:

javax.el.PropertyNotFoundException: /WEB-INF/flows/account/challangeList.xhtml @27,56 value="#{list.userName2}": Property 'userName2' not found on type com.example.j2eeapp.data.ChallangeList
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
javax.faces.component.UIOutput.getValue(UIOutput.java:174)
com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
org.primefaces.component.datatable.DataTableRenderer.encodeCell(DataTableRenderer.java:963)
org.primefaces.component.datatable.DataTableRenderer.encodeRow(DataTableRenderer.java:923)
org.primefaces.component.datatable.DataTableRenderer.encodeRows(DataTableRenderer.java:834)
org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:781)
org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:744)
org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:258)
org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:220)
org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:84)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:85)
org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:68)
org.primefaces.component.fieldset.FieldsetRenderer.encodeContent(FieldsetRenderer.java:94)
org.primefaces.component.fieldset.FieldsetRenderer.encodeMarkup(FieldsetRenderer.java:76)
org.primefaces.component.fieldset.FieldsetRenderer.encodeEnd(FieldsetRenderer.java:47)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)
javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
org.springframework.faces.support.LifecycleWrapper.render(LifecycleWrapper.java:54)
org.springframework.faces.webflow.JsfView.render(JsfView.java:87)
org.springframework.webflow.engine.ViewState.render(ViewState.java:293)
org.springframework.webflow.engine.ViewState.refresh(ViewState.java:242)
org.springframework.webflow.engine.ViewState.resume(ViewState.java:220)
org.springframework.webflow.engine.Flow.resume(Flow.java:537)
org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:228)
org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:57)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

我的程序之前正在运行,但我正在尝试创建另一个DataTable,但我失败了......这是我的文件(没有不必要的方法):

challangeList.xhtml

    <?xml version="1.0" encoding="UTF-8" ?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/templates/general.xhtml"> 

        <ui:define name="title"><h:outputText value="Your Challenges" /></ui:define>
        <ui:define name="header"><h:outputText value="Your Challenges" /></ui:define>
        <ui:define name="menu">
            <h:form id="lolAccountForm1">
                 <p:commandButton id="accountButton" action="account" immediate="true" icon="ui-icon-person" value="Account" />
                 <p:commandButton id="challangeButton" action="challangeUser" immediate="true" icon="ui-icon-plus" value="Challenge User" /> 
                 <p:commandButton id="challangeListButton" action="challangeList" immediate="true" icon="ui-icon-note" value="Challenge List" />

            </h:form>
        </ui:define>


    <ui:define name="content">
        <h:form id="challangeForm">
                <p:fieldset styleClass="fieldset3" legend="Your Challanges">

                    <p:dataTable var="list" value="#{dtChallangeList.list}">
                        <p:column headerText="Id">
                            <h:outputText value="#{list.userName2}" />
                        </p:column>

                        <p:column headerText="Year">
                            <h:outputText value="" />
                        </p:column>

                        <p:column headerText="Brand">
                            <h:outputText value="" />
                        </p:column>

                        <p:column headerText="Color">
                            <h:outputText value="" />
                        </p:column>
                    </p:dataTable>

                </p:fieldset>
            </h:form>


        </ui:define>              


</ui:composition>

challangeList.Java

package com.example.j2eeapp.data;

import java.io.Serializable;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.view.ViewScoped;

import com.example.j2eeapp.domain.ChallangeEntity;
import com.example.j2eeapp.services.impl.ChallangeServiceImpl;

@ManagedBean(name="dtChallangeList")
@ViewScoped
public class ChallangeList implements Serializable{
    private static final long serialVersionUID = -6783797869385338367L;

    private List<ChallangeEntity> list;

    @ManagedProperty("#{challangeService}")
    private ChallangeServiceImpl service;

    public void init() {
        list = service.getChallangeListByUserName(null);
    }

    public List<ChallangeEntity> getList() {
        init();
        return list;
    }

    public void setService(ChallangeServiceImpl service) {
        this.service = service;
    }


}

ChallangeServiceImpl.Java

package com.example.j2eeapp.services.impl;
import java.util.List;
import java.util.ResourceBundle;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;

import com.example.j2eeapp.dao.ChallangeDao;
import com.example.j2eeapp.dao.UserDao;
import com.example.j2eeapp.domain.ChallangeEntity;
import com.example.j2eeapp.domain.UserEntity;
import com.example.j2eeapp.services.ChallangeService;

@ManagedBean(name="challangeService")
@ApplicationScoped
public class ChallangeServiceImpl implements ChallangeService {


    private ChallangeDao challangeDao;
    private UserDao userDao;

    public List<ChallangeEntity> getChallangeListByUserName(Long id) {
        System.out.println(id);
        List<ChallangeEntity> list =challangeDao.getChallangeListByUserName(id);

        return list;
    }


    public UserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

}

ChallangeJpaDao

package com.example.j2eeapp.dao;

import java.util.List;

import javax.persistence.NoResultException;
import javax.persistence.Query;

import com.example.j2eeapp.commons.dao.GenericJpaDao;
import com.example.j2eeapp.domain.ChallangeEntity;


public class ChallangeJpaDao extends GenericJpaDao<ChallangeEntity, Long> implements ChallangeDao {

    public ChallangeJpaDao() {
        super(ChallangeEntity.class);
    }


    public List<ChallangeEntity> getChallangeListByUserName(Long id){

        System.out.println("query "+id );
        String hql=("from ChallangeEntity");
        Query query = getEntityManager().createQuery(hql); 

        List<ChallangeEntity> list =query.getResultList();
        System.out.println(id);

                return list;}
}

ChallangeEntity:

package com.example.j2eeapp.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.example.j2eeapp.commons.domain.ChallangeBaseEntity;
import com.example.j2eeapp.domain.UserEntity;
@Entity
@Table(name="APPCHALLANGE")
public class ChallangeEntity extends ChallangeBaseEntity implements Serializable {

    private static final long serialVersionUID = 7857150946757677310L;

    @Column(name="USERNAME2")
    private String userName2; 
    private Integer bid;
    private String result;
    private String confirm;
    private String result1;
    private String result2;
    private String a1;
    private String a2;
    @ManyToOne
    @JoinColumn(name="Id")
    private UserEntity userEntity;

    public ChallangeEntity(){}
    public ChallangeEntity(String userName2, Integer bid){
        this.userName2=userName2;
        this.bid=bid;
    }

// getters and setters



}

请帮助我,我将与我的文凭论文推广会面。

2 个答案:

答案 0 :(得分:0)

您在ChallangeEntity类中缺少userName2的Getter / Setter。

答案 1 :(得分:0)

我解决了这个问题。我的challangeList.xhtml中有变量(list)的相同名称,challangeList.java和Primefaces不知道该怎么做。我需要做的就是在这里更改变量列表的名称:

<p:dataTable var="list" value="#{dtChallangeList.list}">