You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jesse Kuhnert <jk...@gmail.com> on 2007/11/07 19:48:52 UTC

Re: persists session "set"

public void setCheckboxSelected(boolean bSelected)
   {
      Set locales = getSelectedLocales();

      TheLocale objLocale = getCurrentLocale();
       if (bSelected)
           locales.add(objLocale);
       else locales.remove(objLocale);

       setSelectedLocales(locales);  <-------------------------------
   }

Tapestry and the session manager won't recognize that you've made
changes to your locales Set unless you explicitly call
setSelectedLocales again.

I tried once to add a proxy mechanism to common classes like
collections and such so that Tapestry could automatically detect these
changes as well but it proved to be too error prone and cause problems
with hibernate / other persistence libraries.

On Nov 7, 2007 11:07 AM, cometta <se...@yahoo.com> wrote:
> is this the correct way to persists session?
>
> .page
>
> <property name="selectedLocales" persist="session" initial-value="new
> java.util.HashSet()"/>
>
>
> .java
>
> public abstract Set getSelectedLocales();
> public abstract void setSelectedLocales(Set set);
>
> public void setCheckboxSelected(boolean bSelected)
>     {
>        TheLocale objLocale = getCurrentLocale();
>         if (bSelected)
>             getSelectedLocales().add(objLocale);
>         else getSelectedLocales().remove(objLocale);
>
>
>
>     }
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

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


Re: persists session "set"

Posted by cometta <se...@yahoo.com>.
my mistake. hashset dont add object if it's null. it's working now. thanks


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


Re: persists session "set"

Posted by cometta <se...@yahoo.com>.
i used the method that you provided and like the workbeach example. my hashset
is always have size of only 1 ? i dont understand, since the
selectcheckboxmethod is call so many times, why the size is only 1 all the time.

//this method is called many times ....,but the persists on sysem.out.print(last
line) is //always only 1
public void setCheckboxSelected(boolean bSelected)
    {
        System.out.println(bSelected+"size="+ getSelectedLocales().size());
        
        Set locales = getSelectedLocales();
        
        TheObject objLocale = getCurrentLocale();
        Set setSelectedLocalesx = getSelectedLocales();

        if (bSelected)
        {    locales.add(objLocale);
            System.out.println("adding to hashset");
        }
        else {locales.remove(objLocale);
        
            System.out.println("remove to hashset");
                
        }
        // persist value
       setSelectedLocales(locales);
    
       System.out.println("persist="+getSelectedLocales().size());
        
    
    }


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