我正在開發一個seam應用程序(2.1.1.GA下的JBoss AS 4.2.2),其中一個特定的部分(有時很大)部分不需要被渲染,直到用戶與該特定部分交互,請按照用戶點擊標題的文章標題的行,並將其展開以顯示包含文本的框。延遲加載接縫頁面的部分?
我可以在Seam和Richfaces沒有任何問題的情況下實現它,但是當用戶第一次加載頁面時,所有部分的內容都會下載到瀏覽器中。無論如何,這些部分(可能包含或不包含richfaces控件本身)可以使用ajax按需下載嗎?
謝謝。
我正在開發一個seam應用程序(2.1.1.GA下的JBoss AS 4.2.2),其中一個特定的部分(有時很大)部分不需要被渲染,直到用戶與該特定部分交互,請按照用戶點擊標題的文章標題的行,並將其展開以顯示包含文本的框。延遲加載接縫頁面的部分?
我可以在Seam和Richfaces沒有任何問題的情況下實現它,但是當用戶第一次加載頁面時,所有部分的內容都會下載到瀏覽器中。無論如何,這些部分(可能包含或不包含richfaces控件本身)可以使用ajax按需下載嗎?
謝謝。
很多方法。
只需在該框上設置呈現=「false」,然後在單擊標題時將其重新設置爲父容器。
例如。當你有你的支持bean稱爲showContent布爾值,由toggleContent()方法切換:
<a4j:commandLink
value="This is a title"
ajaxSingle="true"
reRender="contentDiv"
action="#{someBackingBean.toggleContent}"/>
<a4j:outputPanel id="contentDiv">
<a4j:outputPanel rendered="#{someBackingBean.showContent}">
This is some text that is not rendered when the page loads
</a4j:outputPanel>
</a4j:outputPanel>
編輯:在回答進行評論。另一種做法是使用a4j:jsFunction(非常方便)和一些javascript。
<h1 onclick="toggleContent(this);">This is a title</h1>
<a4j:outputPanel id="contentDiv">
<a4j:outputPanel rendered="#{someBackingBean.showContent}">
This is some text that is not rendered when the page loads
</a4j:outputPanel>
</a4j:outputPanel>
<script>
function toggleContent(element) {
//check if the contentDiv has any contents (maybe check if element has a child under contentDiv)
//if it doesn't then call a4j:jsFunction to load the contentDiv eg. loadContent();
//hide or show div depending on the current state of it
}
</script>
<a4j:jsFunction name="loadContent" action="#{someBackingBean.toggleContent}" reRender="contentDiv"/>
反正這樣的事情。
如果您使用可滾動表格,那麼怎麼辦?如何實現在塊中獲取數據?
Ragards 馬爾科
這並不工作,但並不意味着內容必須下載每撥動。對於較小的部分(這往往是我們控制的部分,無論如何都必須完全放棄),這是很好的,但對較大的部分可能會感到煩惱。理想的是尋找一種方法來下載這些更大的數據塊一次。 – 2009-05-01 09:35:05