You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ken in Nashua <kc...@live.com> on 2013/05/29 01:33:33 UTC

query a collection for a page

Hi Folks,

I have a page that renders a collection in a grid.

A hibernate collection... 

    @Persist
    @Property
    private Collection collection;

    @SetupRender
    public void setupRender() {
        beanType = PlayerStats.class;
        
        collection = playerStats = new ArrayList(
                      TynamoUTIL.loadCollectionByYearAndLeagueAndSeason(
                           hibernatePersistenceService, 
                           year, league, season, PlayerStats.class));    // I know its hoakey for now
        
        grid.reset();
    }

but my getSource is giving me an NPE

    public GridDataSource getSource() {
        return new CollectionGridDataSource(collection);
    }

I thought my properties would be binded by now

    @Property
    @Persist(PersistenceConstants.FLASH)
    private Year year;    
    private ArrayList years;
    
    @Property
    @Persist(PersistenceConstants.FLASH)
    private ELeague league;    
    
    @Property
    @Persist(PersistenceConstants.FLASH)
    private ESeason season;    

Am I doing something wrong ?

Where/How do I query a collection for any given page ?
I thought this was the right way to do this.
Thanks for any tips.
 		 	   		  

Re: query a collection for a page

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Tue, 28 May 2013 20:33:33 -0300, Ken in Nashua <kc...@live.com>  
wrote:

> Hi Folks,

Hi!

> I have a page that renders a collection in a grid.
>
> A hibernate collection...
>
>     @Persist
>     @Property
>     private Collection collection;
>
>     @SetupRender
>     public void setupRender() {
>         beanType = PlayerStats.class;
>        collection = playerStats = new ArrayList(
>                       TynamoUTIL.loadCollectionByYearAndLeagueAndSeason(
>                            hibernatePersistenceService,
>                            year, league, season, PlayerStats.class));     
> // I know its hoakey for now
>        grid.reset();
>     }

I see no reason for @Persist'ing a filed that is set in a setupRender()  
method.

> but my getSource is giving me an NPE
>
>     public GridDataSource getSource() {
>         return new CollectionGridDataSource(collection);
>     }

Weird. Could you post the full stack trace? Have you checked whether your  
setupRender() method is really being called? If the page with these fields  
and methods isn't the one being requested, the setupRender() method won't  
be called. In addition, if the only place you use the collection field is  
in getSource(), you could get the collection from inside getSource()  
directly, without using setupRender() for that.

> I thought my properties would be binded by now

These other fields are completely unrelated to your problem.

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: query a collection for a page

Posted by Ken in Nashua <kc...@live.com>.
oops... I meant to say

year, league, season

are all null at the time of the query in getSource()
 		 	   		  

RE: query a collection for a page

Posted by Ken in Nashua <kc...@live.com>.
Well my code is based on the hope that my properties 

year, league, season 

will bind in time 
in order to perform a successful query.

Am I performing the query in the wrong place?