Hi Jan.
Thanks for your answer... That helps a lot.

So, I would like to know where should be the better place to fill the model
object with entries...
Imagine something like this:
I have some entries per day.. So, my scheduele view will be show by day
(ScheduleModel.DAY). By default, I want to fill the schedule at the first
time with data from the current day...
So, I need to get entries (in this case, from database).

On my service layer: someService.findByDay(Date day) - this method return
all messages from my database.

So, where should I call it?
I'm little bit confuse...

Thanks in advance,
Daniel


2008/9/19 Jan-Kees van Andel <[EMAIL PROTECTED]>

> I don't see what the problem is. Components call getters all the time.
> Normally this is no problem since there should not be logic in the getter.
> But your solution is not uncommon.
>
> So, the model.isEmpty protects the loadData to be called multiple times.
> Two things:
> 1 Are you sure you update your model attribute within loadData()? If not,
> it's no surprise loadData gets called, since it remains empty. :)
> 2 When loadData loads an empty model, model.isEmpty() will always return
> true, even if called multiple times.
>
> I think the easiest thing to do (if what I'm describing is really your
> problem) is replacing the isEmpty check with a "model == null" check, which
> is more reliable, because it can deal with empty models. Also, it is more
> fail-fast, instead of lurking in your code until the stars line up.
>
> But a getter being called multiple times within a single request is not
> uncommon. If you want to do stuff inside the getter, just protect the code
> with a check like the null check I said before.
>
> Hope this helps.
>
> Regards,
>
> Jan-Kees
>
>
> 2008/9/19 Daniel S. Teixeira <[EMAIL PROTECTED]>
>
> Hi,
>> I'm trying to use Schedule component.
>> I need to load some values from database in order to fill the schedule.
>> On my backing bean I have 1 private atributte called model (with get/set
>> methods).
>> When the page is called, for some reason the getModel method is called a
>> lot of times... More than 100 times.
>> Is this a normal behavior?
>>
>> Cause I wanted to load data from getModel method like:
>>
>> public SimpleScheduleModel getModel() {
>>     if (model.isEmpty())
>>         loadData();
>>     return model;
>> }
>>
>> I don't really know if I'm doing something wrong...
>>
>> Baking bean scope: request
>>
>> Regards,
>>
>>
>> --
>> Daniel S. Teixeira
>> [EMAIL PROTECTED]
>>
>
>


-- 
Daniel S. Teixeira
[EMAIL PROTECTED]

Reply via email to