Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我很难将PrimeFaces数据表映射到我的托管Bean_Java_Jsf_Primefaces - Fatal编程技术网

Java 我很难将PrimeFaces数据表映射到我的托管Bean

Java 我很难将PrimeFaces数据表映射到我的托管Bean,java,jsf,primefaces,Java,Jsf,Primefaces,我认为我的问题与我的托管Bean构造函数似乎没有被调用有关。也就是说,如果我在构造函数中设置断点,应用程序不会在断点处停止 我得到的是标题,但不是构造函数中添加的行 以下是我的代码:首先是xhtml: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/x

我认为我的问题与我的托管Bean构造函数似乎没有被调用有关。也就是说,如果我在构造函数中设置断点,应用程序不会在断点处停止

我得到的是标题,但不是构造函数中添加的行

以下是我的代码:首先是xhtml:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <f:view contentType="text/html">
        <h:head>
            <f:facet name="first">
                <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
                <title>LOTTO CHECKER</title>
            </f:facet>
        </h:head>

        <h:body>

            <p:layout fullPage="true">

                <p:layoutUnit position="north" size="100" resizable="true" closable="true" collapsible="true">
                    LOTTO CHECKER
                </p:layoutUnit>

                <p:layoutUnit position="south" size="100" closable="true" collapsible="true">
                    Footer
                </p:layoutUnit>

                <p:layoutUnit position="west" size="175" header="Left" collapsible="true" >

                </p:layoutUnit>

                <p:layoutUnit position="center">
                    <h:form id="powerBallDrawingForm">
                        <p:dataTable  value="#(lottoCheckerBean.powerBallDrawings}" var="powerBallDrawing"   >
                            <p:column headerText="DATE">

                                <h:outputText  value ="#{powerBallDrawing.drawingDate}"/>
                            </p:column >
                            <p:column headerText="BALL 1">

                                <h:outputText value="#{powerBallDrawing.ball_1}" />
                            </p:column>                 
                            <p:column headerText ="BALL 2"> 

                                <h:outputText value="#{powerBallDrawing.ball_2}" />
                            </p:column>    
                            <p:column headerText ="BALL 3">

                                <h:outputText value="#{powerBallDrawing.ball_3}" />
                            </p:column>    
                            <p:column headerText ="BALL 4">

                                <h:outputText value="#{powerBallDrawing.ball_4}" />
                            </p:column>    
                            <p:column headerText="BALL 5">

                                <h:outputText value="#{powerBallDrawing.ball_5}" />
                            </p:column>    
                            <p:column headerText="POWER BALL">

                                <h:outputText value="#{powerBallDrawing.powerBall}" />
                            </p:column>    
                        </p:dataTable>
                    </h:form>
                </p:layoutUnit>

            </p:layout>

        </h:body>

    </f:view>
</html>

我怀疑我在某个地方违反了约定,但我没有看到它。

您在构造函数中编写的代码应该在以下方法中:

公共无效设置powerBallDrawings(列出powerBallDrawings){

}

这是因为无论何时尝试访问变量,都会调用相应的setter方法


试试这个。它应该会起作用

我已将您的类和jsf页面添加到现有项目中以查看错误

你唯一的错误是在这条线上

<p:dataTable  value="#(lottoCheckerBean.powerBallDrawings}" var="powerBallDrawing">

如评论中所述,EL表达式中有一个),正确的定义是

<p:dataTable  value="#{lottoCheckerBean.powerBallDrawings}" var="powerBallDrawing">


除此之外没有其他错误。

更改为可以消除错误,但我仍然不执行构造函数,因此我得到了标题但没有数据。您拼写错误了value属性:将
更改为
:检查EL表达式必须括在大括号中而不是括号中。托管bean应标记为..@ManagedBean(name=“lottoCheckerBean”)@rags:OP只是使用默认值:谢谢你的时间和你敏锐的眼睛。我不知道我盯着它看了多久,也没有注意到我想要一个卷发括号的地方。
<p:dataTable  value="#(lottoCheckerBean.powerBallDrawings}" var="powerBallDrawing">
<p:dataTable  value="#{lottoCheckerBean.powerBallDrawings}" var="powerBallDrawing">