You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by 時期 精霊 <ku...@goyman.com> on 2005/05/14 12:56:22 UTC

Persistent HashMap

Hello,

I'm new to tapestry and I try to use an HashMap as a persistent  
property.

I use   <property-specification name="userInfos" persistent="yes"  
type="java.util.HashMap" initial-value="new java.util.HashMap()"/>

But userInfos is cleared everytimes the page is reloaded.

I don't understand what is wrong, because I use exactly the same  
piece of code with String and it works well (type is String and no  
initial-value)

I use tapestry 3.0.3

Regards

Kuon

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


Re: Persistent HashMap

Posted by Nick Westgate <ni...@key-planning.co.jp>.
Hi Kuon.

Don't use initial-value.
Instead, initialize your properties in pageBeginRender. I do this:

public abstract class MyPage implements PageRenderListener
{
     // called before page rendering and also on form submit (rewind)
     public void pageBeginRender(PageEvent event)
     {
         // initialize properties etc
         if (!event.getRequestCycle().isRewinding())
         {
             if (getUserInfos() == null)
             {
                 setUserInfos(new java.util.HashMap());
             }

See the Wiki:
http://wiki.apache.org/jakarta-tapestry/MoreFrequentlyAskedQuestions
"How do I use the pageRenderListener to setup my page before it is used?"

Cheers,
Nick.


時期 精霊 wrote:
> Hello,
> 
> I'm new to tapestry and I try to use an HashMap as a persistent  property.
> 
> I use   <property-specification name="userInfos" persistent="yes"  
> type="java.util.HashMap" initial-value="new java.util.HashMap()"/>
> 
> But userInfos is cleared everytimes the page is reloaded.
> 
> I don't understand what is wrong, because I use exactly the same  piece 
> of code with String and it works well (type is String and no  
> initial-value)
> 
> I use tapestry 3.0.3
> 
> Regards
> 
> Kuon
> 
> ---------------------------------------------------------------------
> 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