You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mikaël Cluseau <nw...@nwrk.dyndns.org> on 2005/02/02 21:12:30 UTC

Re: empty list

My usual approach is to use lazy initialization for these properties.
Easy process (even if I did a Cache class now) :

private List<Element> _list;

public void cleanupAfterRender(IRequestCycle cycle) {
    super.cleanupAfterRender(cycle);
    _list = null;
}

public List getList() {
    if (_list == null) {
        _list = ElementDAO.queryXXX(parameters);
    }
    return _list;
}

Le lundi 31 janvier 2005 à 18:31 +0100, Koen Segers a écrit :
> Hi,
> 
> I have used a foreach that creates <li> inside a <ul> for a menu.
> It looks like this:
> 
> <ul class="navbar">
> <li jwcid='generateLesson'><a href="#" jwcid='lessonLink'><span 
> jwcid='lessonName'>Lesson1</span></a></li>
> </ul>
> 
> The problem is if the list is empty...Then I get <ul></ul>.
> I know you can disable this by using a conditional for the ul-component.
> But the problem is that the list is requested from a Database. I believe it is 
> to much overkill to request the database for the same list twice.
> First time for checking if the list is empty, second time for which elements 
> are in the list...
> 
> Now my question to you is: "Can I have the same functionality without checking 
> my Database twice?"
> 
> Greetz
> 

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