tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Zeigler <rdzei...@u.arizona.edu>
Subject Re: PropertySelection question
Date Wed, 07 Jul 2004 01:29:55 GMT
It won't necessarily work in all cases, but, what about lazy initialization?

getSomeModel() {
    if (someModel == null) {
  	//do the database lookup
    }
    return someModel;
}

?

If it's a drop-down list that's going to be used in a lot of different 
pages, you could put it in the global object and lazy init it there?

Robert

Erik Dreyer wrote:
> That looks promising.  However, it is a protected method.  So I assume 
> your implementation looks something like this:
> 
>    protected void prepareForRender(IRequestCycle cycle)
>    {
>        super.prepareForRender(cycle);
>        // Your code goes here to perform all kinds of application
>        // specific page initialization (db reads, etc).
>    }
> 
> Can anyone else (Howard?) chime in and verify this is the accepted 
> strategy for page initialization?  To save time, the general question is 
> this.  What is the best way to initialize a page when, for example, a 
> database must be accessed in order to retrieve data used in form input 
> fields such as a dropdown list?
> 
> Thanks,
> Erik
> 
> Philippe Paravicini wrote:
> 
>> I do most of the page/model initialization in the 'prepareForRender' 
>> method of pages based on the API documentation, although, like 
>> yourself Erik, I am not 100% sure that this is the orthodox way of 
>> doing things.
>>
>> I would certainly not do it in the PropertySelectionModel, as John 
>> suggests below, as doing such would tightly couple the UI 
>> implementation to Hibernate. Although I am quite happy with Hibernate, 
>> I prefer to have the choice to use another persistence framework 
>> without having to touch View components.
>>
>> Philippe Paravicini
>>
>> ----- Original Message ----- Sent: Monday 05 July 2004 10:15 pm
>> From: John Studarus <John Studarus <studarus@jhlconsulting.com>>
>> To: tapestry-user@jakarta.apache.org
>> Subject: Re: PropertySelection question
>>
>>  I use the following an AbstractSelectionModel to
>> base my SelectionModels.  The code is at:
>>
>> http://www.jhlconsulting.com/botany/src/jhl/tapestry/misc/AbstractSelectionMo 
>>
>> del.java
>>
>>  And a concrete class that is derived from that class is at:
>>
>> http://www.jhlconsulting.com/botany/src/botany/tapestry/misc/FamilySelectionM 
>>
>> odel.java
>>
>>  The full code and a running example is at:
>>
>> http://www.jhlconsulting.com/botany/
>>
>>  The example uses Hibernate and Tapestry together
>> along with some base classes for pages and Tapestry
>> objects to simply things.
>>
>>        John
>>
>>  
>>
>>> Hi,
>>>
>>> I'm trying to use the PropertySelection component and need a little
>>> help.  I'm going to read some information from the database (I'm using
>>> hibernate) in order to initialize a StringPropertySelectionModel
>>> instance for use in the PropertySelection component.
>>>
>>> My question is, when and where is it most appropriate to perform this
>>> database activity?
>>>
>>> I've considered having my page class implement PageRenderListener so I
>>> can perform the database operation and initialize the selection model
>>> instance in the pageBeginRender() method, but that doesn't smell right
>>> to me.  Is there a better place and time to do this?
>>>
>>> Thanks,
>>> Erik
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>   
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>  
>>
> 


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


Mime
View raw message