You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by jeff emminger <ma...@jeffemminger.com> on 2005/11/05 17:48:06 UTC

best practices?

looking for some tips from the experienced...

i've developed a simple wiki as a learning project.  for my wiki crud 
pages, i've given them a WikiPage property so i can retrieve a WikiPage 
object from the database, and set it on the page along the lines of

WikiPageUpdate:
  @Persist
  public abstract void setWikiPage(WikiPage page);

then other pages can send to WikiPageUpdate e.g.

  @InjectPage("WikiPageUpdate")
  public abstract WikiPageUpdate getWikiPageUpdate();

  getWikiPageUpdate.setWikiPage(pageFromDatabase);

two questions currently:
1. is it better to have my crud pages define a property representing the 
whole domain object WikiPage so that i can just pass objects around, or 
should they only store the WikiPage id and be responsible for pulling 
this object from storage by the id?

2. i've had to define the WikiPage property as persistent to get it to 
"stick" between form posts... is this the best/proper way to do it? i'm 
worried about concurrent users sharing the WikiPage objects.

thanks in advance


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


Re: best practices?

Posted by Norbert Sándor <de...@erinors.com>.
It persists per session, so each user have a separate value.
It is because if you write only @Persist then it is the same as 
@Persist(value="session"), so the default persistence strategy is 
"session-scoped".

BR,
Norbi

----- Original Message ----- 
From: "jeff emminger" <ma...@jeffemminger.com>
To: <ta...@jakarta.apache.org>
Sent: Saturday, November 05, 2005 10:38 PM
Subject: Re: best practices?


> ok, so maybe i misunderstand how @Persist works - does it persist that 
> object per-session, so only that current user has that specific object 
> persisted, or does it persist the object on application-scope, so if 
> someone else were to type in the edit url they would also get that 
> persisted object?  if it's the former i think i'm ok.
>
> Ron Piterman wrote:
>> ציטוט jeff emminger:
>>
>>> looking for some tips from the experienced...
>>
>> Not sure I match but give it a try...
>>
>>>
>>> i've developed a simple wiki as a learning project.  for my wiki crud 
>>> pages, i've given them a WikiPage property so i can retrieve a WikiPage 
>>> object from the database, and set it on the page along the lines of
>>>
>>> WikiPageUpdate:
>>>  @Persist
>>>  public abstract void setWikiPage(WikiPage page);
>>>
>>> then other pages can send to WikiPageUpdate e.g.
>>>
>>>  @InjectPage("WikiPageUpdate")
>>>  public abstract WikiPageUpdate getWikiPageUpdate();
>>>
>>>  getWikiPageUpdate.setWikiPage(pageFromDatabase);
>>>
>>> two questions currently:
>>> 1. is it better to have my crud pages define a property representing the 
>>> whole domain object WikiPage so that i can just pass objects around, or 
>>> should they only store the WikiPage id and be responsible for pulling 
>>> this object from storage by the id?
>>
>> since editing should in fact cross more than one request (its - 
>> "preview" -> "edit" -> "preview" -> "save", always with the same object) 
>> it looks resonable to pass the object itself and the synchronize it.
>>
>>>
>>> 2. i've had to define the WikiPage property as persistent to get it to 
>>> "stick" between form posts... is this the best/proper way to do it? i'm 
>>> worried about concurrent users sharing the WikiPage objects.
>>
>> the tapestry wiki flags a page as locked on each request when someone 
>> edits it. I guess one has to implement such a locking...
>>
>> AFAIK, if you persist the wikiPage and the user opens another 
>> browser-tab/window, he gets to edit the same wikiPage -
>> you have one persistent page per session.
>>
>> I preffer persisting such objects using hidden form fields.
>>
>> Cheers,
>> ROn
>>
>>>
>>> thanks in advance
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>
>
> ---------------------------------------------------------------------
> 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


Re: best practices?

Posted by jeff emminger <ma...@jeffemminger.com>.
ok, so maybe i misunderstand how @Persist works - does it persist that 
object per-session, so only that current user has that specific object 
persisted, or does it persist the object on application-scope, so if 
someone else were to type in the edit url they would also get that 
persisted object?  if it's the former i think i'm ok.

Ron Piterman wrote:
> ציטוט jeff emminger:
> 
>> looking for some tips from the experienced...
> 
> Not sure I match but give it a try...
> 
>>
>> i've developed a simple wiki as a learning project.  for my wiki crud 
>> pages, i've given them a WikiPage property so i can retrieve a 
>> WikiPage object from the database, and set it on the page along the 
>> lines of
>>
>> WikiPageUpdate:
>>  @Persist
>>  public abstract void setWikiPage(WikiPage page);
>>
>> then other pages can send to WikiPageUpdate e.g.
>>
>>  @InjectPage("WikiPageUpdate")
>>  public abstract WikiPageUpdate getWikiPageUpdate();
>>
>>  getWikiPageUpdate.setWikiPage(pageFromDatabase);
>>
>> two questions currently:
>> 1. is it better to have my crud pages define a property representing 
>> the whole domain object WikiPage so that i can just pass objects 
>> around, or should they only store the WikiPage id and be responsible 
>> for pulling this object from storage by the id?
> 
> since editing should in fact cross more than one request (its - 
> "preview" -> "edit" -> "preview" -> "save", always with the same object) 
> it looks resonable to pass the object itself and the synchronize it.
> 
>>
>> 2. i've had to define the WikiPage property as persistent to get it to 
>> "stick" between form posts... is this the best/proper way to do it? 
>> i'm worried about concurrent users sharing the WikiPage objects.
> 
> the tapestry wiki flags a page as locked on each request when someone 
> edits it. I guess one has to implement such a locking...
> 
> AFAIK, if you persist the wikiPage and the user opens another 
> browser-tab/window, he gets to edit the same wikiPage -
> you have one persistent page per session.
> 
> I preffer persisting such objects using hidden form fields.
> 
> Cheers,
> ROn
> 
>>
>> thanks in advance
>>
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 


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


Re: best practices?

Posted by Ron Piterman <rp...@gmx.net>.
ציטוט jeff emminger:
> looking for some tips from the experienced...
Not sure I match but give it a try...

> 
> i've developed a simple wiki as a learning project.  for my wiki crud 
> pages, i've given them a WikiPage property so i can retrieve a WikiPage 
> object from the database, and set it on the page along the lines of
> 
> WikiPageUpdate:
>  @Persist
>  public abstract void setWikiPage(WikiPage page);
> 
> then other pages can send to WikiPageUpdate e.g.
> 
>  @InjectPage("WikiPageUpdate")
>  public abstract WikiPageUpdate getWikiPageUpdate();
> 
>  getWikiPageUpdate.setWikiPage(pageFromDatabase);
> 
> two questions currently:
> 1. is it better to have my crud pages define a property representing the 
> whole domain object WikiPage so that i can just pass objects around, or 
> should they only store the WikiPage id and be responsible for pulling 
> this object from storage by the id?
since editing should in fact cross more than one request (its - 
"preview" -> "edit" -> "preview" -> "save", always with the same object) 
it looks resonable to pass the object itself and the synchronize it.

> 
> 2. i've had to define the WikiPage property as persistent to get it to 
> "stick" between form posts... is this the best/proper way to do it? i'm 
> worried about concurrent users sharing the WikiPage objects.
the tapestry wiki flags a page as locked on each request when someone 
edits it. I guess one has to implement such a locking...

AFAIK, if you persist the wikiPage and the user opens another 
browser-tab/window, he gets to edit the same wikiPage -
you have one persistent page per session.

I preffer persisting such objects using hidden form fields.

Cheers,
ROn

> 
> thanks in advance
> 
> 
> ---------------------------------------------------------------------
> 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