You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by mickgiu <mi...@libero.it> on 2006/07/25 08:57:50 UTC

datatable in request

Hi, 
i've a simple question. I don't understand anything in datatable. 
I'm working with spring and hibernate, i'm trying to show a list of all
users inside my mysql table. To do this i use t:datatable like example
SimpleCar of Myfaces. 
My managedbean is in request scope and not in Sessionscope like myfaces, and
uses this method to get value from db: 

public List getCars() 
   { 
       
      cars = mgr.getUtenti(); 
      sort(getSort(), isAscending()); 
      return cars; 
   } 

Problem is when i sort data or change page: because execute again query
calling getCars method again. 
I tryed to use also <t:saveState value="#{pagedSort}" /> 
not to loose value but i get error from spring and hibernate. 
My idea is to load data from database once, populate datatable and than sort
or change page without reload data. All this should be in request scope. 

Can anyone help me ? Or can give me an url of sample? 
Thanks 
mickgiu
-- 
View this message in context: http://www.nabble.com/datatable-in-request-tf1996681.html#a5480769
Sent from the MyFaces - Users forum at Nabble.com.


Re: datatable in request

Posted by Andrew Robinson <an...@gmail.com>.
You don't want to put logic in a property getter. JSF will call it
several times usually. What you want to do is load the cars and sort
once if anything in the getter (use a if null check on your cars). A
better solution, is to use JBoss Seam, jsf-comp on-load or Shale's
view controller to write a page on load method in your bean. In that
method you can load any data that a page needs.

This question has been brought up several times so there should be
adequate resources in the archives on getting this to work as well as
links to the tools above.

-Andrew

On 7/25/06, mickgiu <mi...@libero.it> wrote:
>
> Hi,
> i've a simple question. I don't understand anything in datatable.
> I'm working with spring and hibernate, i'm trying to show a list of all
> users inside my mysql table. To do this i use t:datatable like example
> SimpleCar of Myfaces.
> My managedbean is in request scope and not in Sessionscope like myfaces, and
> uses this method to get value from db:
>
> public List getCars()
>    {
>
>       cars = mgr.getUtenti();
>       sort(getSort(), isAscending());
>       return cars;
>    }
>
> Problem is when i sort data or change page: because execute again query
> calling getCars method again.
> I tryed to use also <t:saveState value="#{pagedSort}" />
> not to loose value but i get error from spring and hibernate.
> My idea is to load data from database once, populate datatable and than sort
> or change page without reload data. All this should be in request scope.
>
> Can anyone help me ? Or can give me an url of sample?
> Thanks
> mickgiu
> --
> View this message in context: http://www.nabble.com/datatable-in-request-tf1996681.html#a5480769
> Sent from the MyFaces - Users forum at Nabble.com.
>
>