自定义JSF控件没有正确绑定

时间:2014-12-26 15:00:56

标签: jsf jsf-2

所以我被要求制作一个自定义的JSF控件来处理我公司网站的结果分页。对于此组件,支持bean的四种方法中的三种正常工作,但最后一种方法不起作用。也许我错过了什么,但代码看起来是正确的。我希望社区能够了解正在发生的事情。

所以这里是代码。这是行为不端的#{cc.attrs.goToLastPage}

<cc:interface>
    <cc:attribute name="showingRecordMin" required="true" />
    <cc:attribute name="showingRecordMax" required="true" />
    <cc:attribute name="totalRecords" required="true" />
    <cc:attribute name="resultsPerPage" required="true" />
    <cc:attribute name="currentPageNum" required="true" />
    <cc:attribute name="totalPagesNum" required="true" />
    <cc:attribute name="resultsPerPageItems" required="true" />
    <cc:attribute name="resultPagesItems" required="true" />

    <cc:attribute name="goToNextPage" 
        method-signature="java.lang.String action()" required="true"/>
    <cc:attribute name="goToPreviousPage"
        method-signature="java.lang.String action()" required="true"/>
    <cc:attribute name="goToFirstPage"
        method-signature="java.lang.String action()" required="true"/>
    <cc:attribute name="goToLastPage"
        method-signtature="java.lang.String action()" required="true"/>
</cc:interface>

<!-- Question: We can't have a form inside of a form. Do we ecapsulate form operations here or 
    should the client handle them? -->
<cc:implementation>
    <div
        style="background-color: #F0F3FA; border: 1px solid #ABABAB; height: 25px; margin: 0px; padding: 2px 8px; position: relative; vertical-align: middle;">
        <h:panelGroup>
            <div style="float: left; width: auto;">
                Showing Results <h:outputLabel value="#{cc.attrs.showingRecordMin}" />  - <h:outputLabel value="#{cc.attrs.showingRecordMax}" /> of
                #{cc.attrs.totalRecords} Results per Page:
                <h:selectOneMenu value="#{cc.attrs.resultsPerPage}" onchange="$j(document).find('.pageBarSubmitBtn').click();">
                    <f:selectItems value="#{cc.attrs.resultsPerPageItems}" />
                </h:selectOneMenu>
            </div>
            <div style="float: right; width: auto;">
                Showing Page #{cc.attrs.currentPageNum} of #{cc.attrs.totalPagesNum} Jump
                to Page
                <h:selectOneMenu id="_pagesMenu" value="#{cc.attrs.currentPage}" onchange="$j(document).find('.pageBarSubmitBtn').click();">
                    <f:selectItems value="#{cc.attrs.resultPagesItems}" />
                </h:selectOneMenu>
                <!-- These three work properly -->
                <h:commandLink style="position: relative; top: 3px;" action="#{cc.attrs.goToFirstPage}"> 
                    <h:graphicImage value="/images/arrow-first.gif" />
                </h:commandLink>
                <h:commandLink style="position: relative; top: 3px;" action="#{cc.attrs.goToPreviousPage}">
                    <h:graphicImage value="/images/arrow-previous.gif" />
                </h:commandLink>
                <h:commandLink style="position: relative; top: 3px;" action="#{cc.attrs.goToNextPage}">
                    <h:graphicImage value="/images/arrow-next.gif" />
                </h:commandLink>
                <!-- This one is the bad guy -->
                <h:commandLink style="position: relative; top: 3px;" action="#{cc.attrs.goToLastPage}">
                    <h:graphicImage value="/images/arrow-last.gif" />
                </h:commandLink>

            </div>
            <h:commandButton style="visibility: hidden;" styleClass="jsfHidden pageBarSubmitBtn"/>
        </h:panelGroup>
    </div>
</cc:implementation>

继续,这是从控制台抛出的异常

09:23:15,108 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http-localhost-  127.0.0.1-3333-5) Unable to resolve composite component from using page using EL expression '#  {cc.attrs.goToLastPage}': javax.faces.FacesException: Unable to resolve composite component from   using page using EL expression '#{cc.attrs.goToLastPage}'

以下是我的页面中控件的使用方法:      句法                            

最后,这是我的支持bean实现的用于此控件的接口

public interface PagableResults {
    public int getShowingRecordMin();
    public int getShowingRecordMax();

    public ResultsPerPage getResultsPerPage();
    public void setResultsPerPage(ResultsPerPage rpp);

    public int getCurrentPageNum();
    public void setCurrentPageNum(int pageNum);

    public int getTotalPagesNum();
    public int getTotalRecordsNum();

    public List<SelectItem> getResultsPerPageItems();
    public List<SelectItem> getResultsPagesItems();

    public void goToFirstPage();
    public void goToLastPage();
    public void goToPreviousPage();
    public void goToNextPage();
}

1 个答案:

答案 0 :(得分:0)

你有拼写错误的方法签名:

<cc:attribute name="goToLastPage"
    method-signtature="java.lang.String action()" required="true"/>
相关问题