Return-Path: Delivered-To: apmail-myfaces-users-archive@www.apache.org Received: (qmail 91754 invoked from network); 26 Mar 2008 07:02:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Mar 2008 07:02:03 -0000 Received: (qmail 5786 invoked by uid 500); 26 Mar 2008 07:01:58 -0000 Delivered-To: apmail-myfaces-users-archive@myfaces.apache.org Received: (qmail 5750 invoked by uid 500); 26 Mar 2008 07:01:58 -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 5739 invoked by uid 99); 26 Mar 2008 07:01:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 00:01:58 -0700 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 anshuman.roy.blr@gmail.com designates 64.233.184.234 as permitted sender) Received: from [64.233.184.234] (HELO wr-out-0506.google.com) (64.233.184.234) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 07:01:19 +0000 Received: by wr-out-0506.google.com with SMTP id c57so2582025wra.9 for ; Wed, 26 Mar 2008 00:01:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=8KW96B+B+8WoEaHwlWxhIV1fP5eO+jE+5Mw07xA7ifA=; b=T/7H89tB5vKKpUHGP40O+oG+i18cCOMPR2D2Y8LflLArYMAeBe2GorywWk66eGJIs0GqS+raZ7yUqU4HslQNON+j5QiHbLdVqLbmRZmi/R1zTRkeqq2nBNk/7iM2l+P1X6f/8CLVY1/hBQGsHezt2PjWlH3qBUncEpuRNBlpwQw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=jaBJEJ/cqDXZY7ShQ2Pg7BoS46B3c3eMCyaBiG/iO9mOdYkMt/g12nLIMpn5GmO1WNlwGQwQGTO/z7AITevTfMDBTOH70esso8wpbzF4T3hfxxA7FNUBwweB6k7SFOI3w3O+2B4VvLGpdvVlyFyWN2WPt0b5htdUFdn7y+lioHc= Received: by 10.150.57.5 with SMTP id f5mr4603268yba.140.1206514889859; Wed, 26 Mar 2008 00:01:29 -0700 (PDT) Received: by 10.150.95.6 with HTTP; Wed, 26 Mar 2008 00:01:29 -0700 (PDT) Message-ID: <838cc1a00803260001x384ccc41h25cee1b0233edb1c@mail.gmail.com> Date: Wed, 26 Mar 2008 12:31:29 +0530 From: "anshuman roy" To: "MyFaces Discussion" Subject: Re: [Trinidad] using custom model with tr:table In-Reply-To: <2336c7b80803200422k5186260i1bbc70c0b48dd436@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_7597_14593893.1206514889881" References: <2336c7b80803200422k5186260i1bbc70c0b48dd436@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_7597_14593893.1206514889881 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Why have you put this model = new Model() inside the constructor? If you do eager loading then for each phase in the jsf lifecycle it will get invoked so you would get too many unwanted issues. Try using lazy loading instead and this would work. regards, Anshuman On Thu, Mar 20, 2008 at 4:52 PM, Ravindra Adireddy < adireddyravindra@gmail.com> wrote: > Hi all, > > I am using my custom model with trinidad table as shown below. > I want to instantiate my custom model only once regardless of backing bean. > Is it possible? > > *Model Class:* > > public MyModel extends CollectionModel { > > // logic > } > > > *Backing Bean:* > > public MyBackingBean { > > private MyModel model; > > public MyBackingBean() { > model = new Model(/*some collection */); > } > > public MyModel getModel() { > return model; > } > > } > * > JSP page:* > > > > > *The backing bean is in request scope.* > > * > Problem:* > > Since the backing bean is in request scope, for every request new instance > of model is created. I don't want to create new instance of my custom model > since i am storing some state in it. Is there any way to create only one > instance of custom model regardless of backing bean scope, like trinidad > creates only one instance of SortableModel. > > > > -- > Thanks and Regards > Ravindra Adireddy -- regards, Anshuman Roy ------=_Part_7597_14593893.1206514889881 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Why have you put this

model = new Model()

inside the constructor? If you do eager loading then for each phase in the jsf lifecycle it will get invoked so you would get too many unwanted issues.
Try using lazy loading instead and this would work.

regards,
Anshuman


On Thu, Mar 20, 2008 at 4:52 PM, Ravindra Adireddy <adireddyravindra@gmail.com> wrote:
Hi all,

           I am using my custom model with trinidad table as shown below. I want to instantiate my custom model only once regardless of backing bean. Is it possible?

Model Class:
          
public MyModel extends CollectionModel {

    // logic
}


Backing Bean:

public MyBackingBean {

        private MyModel  model;

         public MyBackingBean() {
             model = new Model(/*some collection */);
         }

          public MyModel  getModel() {
                return model;
           }
           
}

JSP page:


<tr:table value="#{myBean.model}" .....>


The backing bean is in request scope.


Problem:


Since the backing bean is in request scope, for every request new instance of model is created. I don't want to create new instance of my custom model since i am storing some state in it. Is there any way to create only one instance of  custom model regardless of backing bean scope, like trinidad creates only one instance of SortableModel.

         

--
Thanks and Regards
Ravindra Adireddy



--
regards,
Anshuman Roy ------=_Part_7597_14593893.1206514889881--