You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "richardl@ufp.com" <ri...@ufp.com> on 2009/02/04 03:05:00 UTC

[T4] Problem with multiple PropertySelectors and persistence

Im using Tapestry 4.1.5, Tomcat 6.0.13 and Java build diablo-1.5.0-b01. My
issue is that I have a page where I want to allow a user to configure a
default 'bar' for each 'foo' the user has. The user's 'foo's and 'bar's are
read from the DB using a service layer. I loop around the foo's with a @For
and create a @PropertySelector with all the bar's in it for each foo.
Everything works. The problem is that I want to limit the number of reads
from the database AND I want to clear the instance variables when the page
is done. 

I have tried many permutations including static lists (where I get my read
once from the DB, but the page doesn't ever refresh when its reloaded (for
instance adding new bar's and they never show up). I have tried declaring
everything abstract and letting Tapestry allocate everything but that causes
way too many DB reads. I have also tried the latest (represented in the
code) with pageAttached and pageDetached. The problem is the pageDetached
comes too often and too early, as soon as the page is rendered, the detached
gets called so I cant clean up the instance variables or they wont be
available when the 'submit' is hit. Also Im not sure detach ever gets called
if you click 'back.'

While Im waiting I will try cleaning things up in the 'submit' and 'cancel'
and then calling forgetPage() but I dont think that will have any effect if
I click 'back' or 'reset' back to the home page. 

ManageFoos.html
http://pastebin.com/m38cb7caf

ManageFoos.java
http://pastebin.com/me7dc317
-- 
View this message in context: http://www.nabble.com/-T4--Problem-with-multiple-PropertySelectors-and-persistence-tp21823085p21823085.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: [T4] Problem with multiple PropertySelectors and persistence

Posted by Norman Franke <no...@myasd.com>.
What I do is have some abstract variables (i.e. getters and setters)  
with @InitialValue("null"). In my pageBeginRender, I read the values  
and store them in these variables. This happens once per page load. If  
I want to lazy read, I read if the variable is null whenever I read it  
and cache. I believe I read somewhere that when the page is done and  
released back to the pool, the initial values are then set, thus  
releasing my cached objects.

Norman Franke
Answering Service for Directors, Inc.
www.myasd.com

On Feb 3, 2009, at 10:08 PM, Andreas Andreou wrote:

> Can you describe what you're seeing?
>
> When the page loads, you should be getting
> 1 select for all foos (let's say returning n records), and
> n selects for bars...
> And when the form is submitting, you're probably also seeing
> those n+1 selects (which is what's should happen during the rewind)
>
> So, is the above correct? And if it is, are you just saying that you  
> want to
> be able to remove the selects after the submit?
>
>
> On Wed, Feb 4, 2009 at 4:05 AM, richardl@ufp.com <ri...@ufp.com>  
> wrote:
>>
>> Im using Tapestry 4.1.5, Tomcat 6.0.13 and Java build diablo-1.5.0- 
>> b01. My
>> issue is that I have a page where I want to allow a user to  
>> configure a
>> default 'bar' for each 'foo' the user has. The user's 'foo's and  
>> 'bar's are
>> read from the DB using a service layer. I loop around the foo's  
>> with a @For
>> and create a @PropertySelector with all the bar's in it for each foo.
>> Everything works. The problem is that I want to limit the number of  
>> reads
>> from the database AND I want to clear the instance variables when  
>> the page
>> is done.
>>
>> I have tried many permutations including static lists (where I get  
>> my read
>> once from the DB, but the page doesn't ever refresh when its  
>> reloaded (for
>> instance adding new bar's and they never show up). I have tried  
>> declaring
>> everything abstract and letting Tapestry allocate everything but  
>> that causes
>> way too many DB reads. I have also tried the latest (represented in  
>> the
>> code) with pageAttached and pageDetached. The problem is the  
>> pageDetached
>> comes too often and too early, as soon as the page is rendered, the  
>> detached
>> gets called so I cant clean up the instance variables or they wont be
>> available when the 'submit' is hit. Also Im not sure detach ever  
>> gets called
>> if you click 'back.'
>>
>> While Im waiting I will try cleaning things up in the 'submit' and  
>> 'cancel'
>> and then calling forgetPage() but I dont think that will have any  
>> effect if
>> I click 'back' or 'reset' back to the home page.
>>
>> ManageFoos.html
>> http://pastebin.com/m38cb7caf
>>
>> ManageFoos.java
>> http://pastebin.com/me7dc317
>> --
>> View this message in context: http://www.nabble.com/-T4--Problem-with-multiple-PropertySelectors-and-persistence-tp21823085p21823085.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
>
> -- 
> Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
> Tapestry / Tacos developer
> Open Source / JEE Consulting
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>



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


Re: [T4] Problem with multiple PropertySelectors and persistence

Posted by Andreas Andreou <an...@di.uoa.gr>.
Can you describe what you're seeing?

When the page loads, you should be getting
1 select for all foos (let's say returning n records), and
n selects for bars...
And when the form is submitting, you're probably also seeing
those n+1 selects (which is what's should happen during the rewind)

So, is the above correct? And if it is, are you just saying that you want to
be able to remove the selects after the submit?


On Wed, Feb 4, 2009 at 4:05 AM, richardl@ufp.com <ri...@ufp.com> wrote:
>
> Im using Tapestry 4.1.5, Tomcat 6.0.13 and Java build diablo-1.5.0-b01. My
> issue is that I have a page where I want to allow a user to configure a
> default 'bar' for each 'foo' the user has. The user's 'foo's and 'bar's are
> read from the DB using a service layer. I loop around the foo's with a @For
> and create a @PropertySelector with all the bar's in it for each foo.
> Everything works. The problem is that I want to limit the number of reads
> from the database AND I want to clear the instance variables when the page
> is done.
>
> I have tried many permutations including static lists (where I get my read
> once from the DB, but the page doesn't ever refresh when its reloaded (for
> instance adding new bar's and they never show up). I have tried declaring
> everything abstract and letting Tapestry allocate everything but that causes
> way too many DB reads. I have also tried the latest (represented in the
> code) with pageAttached and pageDetached. The problem is the pageDetached
> comes too often and too early, as soon as the page is rendered, the detached
> gets called so I cant clean up the instance variables or they wont be
> available when the 'submit' is hit. Also Im not sure detach ever gets called
> if you click 'back.'
>
> While Im waiting I will try cleaning things up in the 'submit' and 'cancel'
> and then calling forgetPage() but I dont think that will have any effect if
> I click 'back' or 'reset' back to the home page.
>
> ManageFoos.html
> http://pastebin.com/m38cb7caf
>
> ManageFoos.java
> http://pastebin.com/me7dc317
> --
> View this message in context: http://www.nabble.com/-T4--Problem-with-multiple-PropertySelectors-and-persistence-tp21823085p21823085.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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