Return-Path: Delivered-To: apmail-myfaces-users-archive@www.apache.org Received: (qmail 71696 invoked from network); 5 Mar 2008 20:21:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Mar 2008 20:21:28 -0000 Received: (qmail 13262 invoked by uid 500); 5 Mar 2008 20:21:21 -0000 Delivered-To: apmail-myfaces-users-archive@myfaces.apache.org Received: (qmail 13224 invoked by uid 500); 5 Mar 2008 20:21:20 -0000 Mailing-List: contact users-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Discussion" Delivered-To: mailing list users@myfaces.apache.org Received: (qmail 13213 invoked by uid 99); 5 Mar 2008 20:21:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Mar 2008 12:21:20 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of hbmailinglist@gmail.com designates 64.233.184.225 as permitted sender) Received: from [64.233.184.225] (HELO wr-out-0506.google.com) (64.233.184.225) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Mar 2008 20:20:45 +0000 Received: by wr-out-0506.google.com with SMTP id 57so2807634wri.12 for ; Wed, 05 Mar 2008 12:20:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=rUSvkS84whC7lD+PIZxRYewruneXEOhI18BsL7YaBqM=; b=Uucnv5+PNGkDZOCFryP0n2dmoaA5bfblFjwFDfJkkISnPz4WujZ4DSq9OXBiaKqWeSGHSm81OPtDXrlZ8cosaLrdVUovCnvUh/3Lx1i1N9siqFV2ESG0VAmMmgvisVvYHpeEYq3ivqA1NQdeKpgmg5PgmwE48TworlAXTluoY7k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=YGECO8yXqu/XZLiDQ+cD+PxWYGNzXSZBENWWQ0ltSjHPP1+VB3lV9TW1Vj4BoO4qyYBl7FtbViGUBiguGmKPWd+gv/LnngNuu+QPRDpDErvB6RWzOPO2VbrJyxIVlLbG5x5yJ2VfolwOFkumSxu3+1HQXvuQiYd+JcLh+1XAFEs= Received: by 10.140.201.1 with SMTP id y1mr1728142rvf.200.1204748452400; Wed, 05 Mar 2008 12:20:52 -0800 (PST) Received: by 10.141.97.10 with HTTP; Wed, 5 Mar 2008 12:20:52 -0800 (PST) Message-ID: Date: Wed, 5 Mar 2008 12:20:52 -0800 From: "h b" To: users@myfaces.apache.org Subject: help me decide when to populate my datatable? MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_22656_31463632.1204748452400" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_22656_31463632.1204748452400 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello, I'm new to jsf. Background: I have a page that shows a table of items using the datatable component. The datatable is bound to my backing beans items field. . myBean has a request scope. myBean.getItems() is implemented as follows: if (items == null) items = createItems(); return items; I put in a few log statements to see how everything is working. What I'm observing: * The first time the page is rendered myBean.getItems is invoked during the RENDER_RESPONSE phase. That's great, it make sense. * On post back getItems is called during the: APPLY_REQUEST_VALUES & RENDER_RESPONSE phase. Questions & Concerns: 1. On postback why is getItems getting invoked during APPLY_REQUEST_VALUES phase? 2. On postback since myBean has request scope, it is constructed again, which means items is null until getItems gets called. This means that (on postback) during the APPLY_REQUEST_VALUES phase, I'm doing a db fetch to build my items. This is not good for me, specially since, I want to respond to an event (such as new filter criteria) and fetch items based on that event. So I'll end up doing 2 fetches. IOne way to resolve this issue is by changing myBean scope to session scope. But I want to stay stateless...and I'm hoping jsf can support a stateless model. I'm sure I'm missing something since this is a very simple use-case. Thanks in advance. ------=_Part_22656_31463632.1204748452400 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello, I'm new to jsf. 

Background:
I have a page that shows a table of items using the datatable component.  The datatable is bound to my backing beans items field. <h:datatable values="#{myBean.items}"...></h:datatable>.

myBean has a request scope.

myBean.getItems() is implemented as follows:
if (items == null) items = createItems();
return items;

I put in a few log statements to see how everything is working.

What I'm observing:
* The first time the page is rendered myBean.getItems is invoked during the RENDER_RESPONSE phase.  That's great, it make sense.
* On post back getItems is called during the: APPLY_REQUEST_VALUES & RENDER_RESPONSE phase.

Questions & Concerns:
1. On postback why is getItems getting invoked during APPLY_REQUEST_VALUES phase?
2. On postback since myBean has request scope, it is constructed again, which means items is null until getItems gets called.  This means that (on postback) during the APPLY_REQUEST_VALUES phase, I'm doing a db fetch to build my items.  This is not good for me, specially since, I want to respond to an event (such as new filter criteria) and fetch items based on that event.  So I'll end up doing 2 fetches.

IOne way to resolve this issue is by changing myBean scope to session scope.  But I want to stay stateless...and I'm hoping jsf can support a stateless model.

I'm sure I'm missing something since this is a very simple use-case.

Thanks in advance.

------=_Part_22656_31463632.1204748452400--