wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Barnum <...@360works.com>
Subject Using detachable models in edit pages
Date Fri, 01 Feb 2008 16:24:09 GMT
Good explanation, I wasn't aware that was how it worked.  Time to  
switch all my edit pages to use detachable models!

One more question on this topic (changing the subject of the thread)

Consider the scenario:

* Your edit page uses a detachable model to hold your business object.
* The user edits an object succesfully.
* On a later page, the user deletes the object.
* Then uses the back button to navigate back to the edit page, and  
hits reload, or tries saving the object again.

The detachable model will fire, and will fail to load the object from  
the DB.  Depending on how your DAO is implemented, this will either  
return null or throw an exception.  Do you have a recommendation on  
how to handle this scenario?  Would you just check for null/catch the  
exception and do a redirect to an error message page?

Thanks!

On Jan 31, 2008, at 7:23 PM, Nick Heudecker wrote:

> Answer inline.
>
> On Jan 31, 2008 8:42 PM, Sam Barnum <sam@360works.com> wrote:
>
>> Question on detachable models:
>>
>> You use detachable models in the contact edit page.  It seems like
>> this would cause your changes to be lost if the edit process takes
>> more than one request to complete.
>>
>> If you use the no-arg constructor, the loadableDetachableModel
>> creates a new contact at the beginning of every request.  If you
>> enter a name that's too long, a validation message is displayed. Then
>> the detach() is called on the model, and a new Contact is loaded on
>> the next request, erasing your temporary changes.
>
>
> If validation fails, the input isn't copied to the Contact object.   
> The form
> input is only copied to the Contact object when the form successfully
> submits.
>
>
>>
>>
>> I may well be misunderstanding something, I'm fairly new to this
>> stuff.  It seems that for edit pages you want a non-detachable model,
>> which gets serialized to the session.
>
>
> I had the same misconception when I started using  Wicket.
>
>
>>
>>
>> Thanks for taking the time to write this article, and thanks in
>> advance for any clarification on this topic.
>>
>> --
>> Sam Barnum
>> 360 Works
>> http://www.360works.com
>> 415.865.0952
>>
>>
>>
>> On Jan 28, 2008, at 11:02 AM, Nick Heudecker wrote:
>>
>>> It's finally up:
>>> http://www.theserverside.com/news/thread.tss?thread_id=48234
>>>
>>> Thanks to the various reviewers that helped improve both the
>>> content and
>>> quality of the article, including Martijn, Eelco, Igor, Gerolf and
>>> Talios.
>>>
>>> --
>>> Nick Heudecker
>>> Professional Wicket Training & Consulting
>>> http://www.systemmobile.com
>>>
>>> Eventful - Intelligent Event Management
>>> http://www.eventfulhq.com
>>
>>
>
>
> -- 
> Nick Heudecker
> Professional Wicket Training & Consulting
> http://www.systemmobile.com
>
> Eventful - Intelligent Event Management
> http://www.eventfulhq.com


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


Mime
View raw message