You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michal Prinke <bo...@icpnet.pl> on 2004/07/14 12:00:32 UTC

When property variables are filled with submitted values ?

Hello,

I have some page which displays a list of persons. By default, it shows
only 10 top persons, but user can check a checkbox labeled "show all",
click "submit" and all the persons will be visible on refreshed page.

The code looks more or less like that:

   public abstract boolean getShowAll();  // checkbox property

   private List persons = null;           // persons list

   public List getPersons()               // persons getter, read thru OGNL
   {
     // debug
     System.out.println("getShowAll=" + getShowAll());

     // lazy fetching
     if (persons == null)
     {
       // fetch all persons if checkbox is set, top ten if not set
       persons = getPersonsFromDatabase(getShowAll() ? -1 : 10);
     }

     return persons;
   }

My problem is that getShowAll() does not return proper (submitted)
values until some moment(?) is reached. Before then, it only returns "false"; 
and because of the lazy evaluation in getPersons(), the page will always show 10 
persons disregarding submitted checkbox.

The situation shows in debug log (System.out.println):
getShowAll=false
getShowAll=false
getShowAll=false
...
getShowAll=[true or false, submitted value]
getShowAll=[true or false, submitted value]
getShowAll=[true or false, submitted value]

My question:

When property variables are filled with values ? When getShowAll()
starts to return proper values? Is it when the component is rendered? I want to 
depend on submitted values to change the look of the page - is it possible?
How is it done?

Thanks!

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


So what should I do?

Posted by Michal Prinke <bo...@icpnet.pl>.
Howard Lewis Ship wrote:

> When the component is rendered.  As components are rendered during the
> rewind cycle, the have the opportunity to update the properties bound
> to their parameters.

So what should I do if I want to e.g. change a color of some form component
basing on submitted value of some other component?


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


Re: When property variables are filled with submitted values ?

Posted by Howard Lewis Ship <hl...@gmail.com>.
When the component is rendered.  As components are rendered during the
rewind cycle, the have the opportunity to update the properties bound
to their parameters.

On Wed, 14 Jul 2004 12:00:32 +0200, Michal Prinke <bo...@icpnet.pl> wrote:
> Hello,
> 
> I have some page which displays a list of persons. By default, it shows
> only 10 top persons, but user can check a checkbox labeled "show all",
> click "submit" and all the persons will be visible on refreshed page.
> 
> The code looks more or less like that:
> 
>    public abstract boolean getShowAll();  // checkbox property
> 
>    private List persons = null;           // persons list
> 
>    public List getPersons()               // persons getter, read thru OGNL
>    {
>      // debug
>      System.out.println("getShowAll=" + getShowAll());
> 
>      // lazy fetching
>      if (persons == null)
>      {
>        // fetch all persons if checkbox is set, top ten if not set
>        persons = getPersonsFromDatabase(getShowAll() ? -1 : 10);
>      }
> 
>      return persons;
>    }
> 
> My problem is that getShowAll() does not return proper (submitted)
> values until some moment(?) is reached. Before then, it only returns "false";
> and because of the lazy evaluation in getPersons(), the page will always show 10
> persons disregarding submitted checkbox.
> 
> The situation shows in debug log (System.out.println):
> getShowAll=false
> getShowAll=false
> getShowAll=false
> ...
> getShowAll=[true or false, submitted value]
> getShowAll=[true or false, submitted value]
> getShowAll=[true or false, submitted value]
> 
> My question:
> 
> When property variables are filled with values ? When getShowAll()
> starts to return proper values? Is it when the component is rendered? I want to
> depend on submitted values to change the look of the page - is it possible?
> How is it done?
> 
> Thanks!
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com

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