-1
所以我被要求做一個自定義的JSF控件來處理我公司網站的結果分頁。對於這個組件,支持bean的四種方法中的三種正常工作,但最後一種不起作用。也許我錯過了一些東西,但代碼看起來是正確的。我希望社區能夠了解正在發生的事情。自定義JSF控件沒有正確綁定
所以這裏的代碼。這是#{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();
}
偉大的工作!我一直盯着代碼幾個小時,從未注意到!我猜測眼睛只能看到它想看的東西! – user2980252