javax.el.PropertyNotFoundException:在类型上找不到属性'printIDs'但是此属性被注释

时间:2013-02-06 10:14:08

标签: java jsf openfaces

我得到了一个例外

javax.el.PropertyNotFoundException: Property 'printIDs' not found on type pl.com.pir.beans.SelectedItemBean
at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:237)
at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:214)
at javax.el.BeanELResolver.property(BeanELResolver.java:325)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:85)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstValue.getValue(AstValue.java:183)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
at com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:217)
at com.sun.faces.facelets.el.ELText$ELTextComposite.toString(ELText.java:157)
at com.sun.faces.facelets.compiler.CommentInstruction.write(CommentInstruction.java:77)
at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
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:437)
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:1822)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

但在我的代码中这个方法被评论,我试图清除Web浏览器catche和cookie,在代码中搜索'printIDs'字符串,并且所有事件都被注释,我查看face-config.xml和web.xml ,删除tomcat webapps目录下的webapp,甚至重新启动我的电脑,没有任何帮助。

        <!-- MENU GENERATOR -->
    <h:panelGroup layout="block" id="produktMenu">
            <o:dataTable value="#{productBean.productList}" var="produkt" pageSize="10"
                         style="margin-top: 15px; width: 100%; height: 420px;">
                         <o:multipleRowSelection rowDatas="#{productBean.list}" style="background: #a4aec5; color: white;" />
            <o:columnReordering />
            <f:facet name="columnMenu">
                <o:columnMenu />
            </f:facet>

            <o:column header="Kategoria" width="7%"
                sortingExpression="#{produkt.kategoria}"
                bodyStyle="padding-left: 5px; padding-right: 5px;"
                headerStyle="text-align: left; padding-left: 5px; padding-right: 5px;">
                <f:facet name="subHeader">
                    <o:dropDownFieldFilter maxlength="4" customValueAllowed="false" />
                </f:facet>
                <h:outputText value="#{produkt.kategoria}" />
            </o:column>

            <o:selectionColumn style="width: 6%;" sortable="true"
                header="Selection">
                <f:facet name="header">
                    <o:selectAllCheckbox />
                </f:facet>
            </o:selectionColumn>
            <f:facet name="below">
                    <o:dataTablePaginator id="paginator" />
                </f:facet>
                <o:column id="symbolCol1" sortingExpression="#{produkt.symbol}">
                    <f:facet name="header">
                        Symbol
                    </f:facet>
                    <h:outputText value="#{produkt.symbol}" />
                </o:column>
                <o:column id="opisCol1" sortingExpression="#{produkt.opis}">
                    <f:facet name="header">
                        Opis
                    </f:facet>
                    <h:outputText value="#{produkt.opis}" />
                </o:column>
                <o:column id="cenaCol1" sortingExpression="#{produkt.cena}">
                    <f:facet name="header">
                        Cena
                    </f:facet>
                    <h:outputText value="#{produkt.cena}" />
                </o:column>
            </o:dataTable>

    </h:panelGroup>
    <h:commandButton value="Dodaj" action="#{selectedItemBean.submit}" />

    <o:dataTable value="#{productBean.list}" var="l" id="resultTable">
        <o:column id="resultSumbolCol" sortingExpression="#{l.symbol}">
            <f:facet name="header">
                        Symbol
                    </f:facet>


            <h:outputText value="#{l.symbol}" />
        </o:column>
        <o:column id="resultOpisCol" sortingExpression="#{l.opis}">
            <f:facet name="header">
                        Opis
                    </f:facet>
            <h:outputText value="#{l.opis}" />
        </o:column>
        <o:column id="resultCenaCol" sortingExpression="#{l.cena}">
            <f:facet name="header">
                        Cena
                    </f:facet>
            <h:outputText value="#{l.cena}" />
        </o:column>
    </o:dataTable>

SelectedItemBean来源:

    public String submit() {
    for (Map.Entry<Integer, Boolean> entry : selectedIDs.entrySet()) {
        if (entry.getValue() == true) {
            System.out.println("id: " + entry.getKey() + ", "
                    + entry.getValue());
            id.add(entry.getKey());
        }
    }
    System.out.println("SelectedItemBean.submit() --> " + id.size());
    return "selected";
}

public String printIDs() {
    int i = 0;
    if (id.isEmpty())
        return null;
    System.out.println("printIDs <--");
    Iterator<Integer> it = id.iterator();
    while (it.hasNext()) {
        i++;
        System.out.println(it.next());
    }
    System.out.println("suma produktow: " + i + "\nprintIDs -->");
    pb = new ProductBean();
    StringParse sp = new StringParse();
    idList = sp.prepareInStatement(id);
    try {
        list = pb.getProductByID(idList, 2);
        suma = cumputeCosts(list);
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return "TESTprintIDs";
}

为什么我一直得到这个例外?

2 个答案:

答案 0 :(得分:3)

您没有显示已注释的代码,但我猜您使用了经典的xml注释

<!--  ...   -->

我必须说,默认情况下EL即使在评论中也会被执行。您可以使用以下两种解决方案之一解决此问题:

首先,您可以通过添加以下内容全局禁用评论中的EL解析:

<context-param>
  <param-name>facelets.SKIP_COMMENTS</param-name>
  <param-value>true</param-value>
</context-param>

web.xml文件中。

另一种解决方案是将您的评论附在ui:remove代码中。

答案 1 :(得分:2)

SelectedItemBean应该有printIDs字段的访问者。

public class SelectedItemBean{
    private String printIDs;

    private getPrintIDs(){
      return printIds;
    }
}

表达式语言使用getter方法进行属性解析。

您可以通过以下方式更改现有代码:

public String getPrintIDs() { //Notice new signature
    int i = 0;
    if (id.isEmpty())
        return null;
    System.out.println("printIDs <--");
    Iterator<Integer> it = id.iterator();
    while (it.hasNext()) {
        i++;
        System.out.println(it.next());
    }
    System.out.println("suma produktow: " + i + "\nprintIDs -->");
    pb = new ProductBean();
    StringParse sp = new StringParse();
    idList = sp.prepareInStatement(id);
    try {
        list = pb.getProductByID(idList, 2);
        suma = cumputeCosts(list);
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return "TESTprintIDs";
}