1

ユーザーがその特定のセクションと対話するまでレンダリングする必要のないいくつかの (場合によっては大きい) セクションがある特定の Seam アプリケーション (JBoss AS 4.2.2 の 2.1.1.GA) に取り組んでいます。記事のタイトルの行に沿って、ユーザーがタイトルをクリックすると、テキストを含むボックスが展開して表示されます。

Seam と Richfaces を使用してこれを問題なく実装できますが、ユーザーが最初にページをロードしたときに、すべてのセクションのコンテンツがブラウザーにダウンロードされます。これらのセクション (richfaces コントロール自体を含む場合と含まない場合があります) を ajax を使用してオンデマンドでダウンロードする方法はありますか?

ありがとう。

4

2 に答える 2

2

たくさんの方法。

ボックスに render="false" を設定し、タイトルをクリックしたときに親コンテナーを再レンダリングするだけです。

例えば。toggleContent() メソッドによって切り替えられるバッキング Bean に showContent というブール値がある場合:

<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"/>

なんつーか、こういうの。

于 2009-04-30T17:31:20.843 に答える
0

スクロール可能なテーブルを使用している場合はどうでしょうか。データのフェッチをチャンクで実装する方法は?

ラガード・マルコ

于 2009-07-01T11:08:34.823 に答える