Hi Geoff,
Thanks for your reply to a very basic approach, I use it now in the absence
of a better solution.
some replies below:
Geoff Callender-2 wrote:
>
> Hi Angelo,
>
> A few concerns - none of them to do with Tapestry.
>
> - The page is combining business logic with presentation logic rather
> than calling a service or a DAO.
> - It allows creation of a cat in an incomplete state ie. no gender or
> name.
> - It uses neither optimistic nor pessimistic locking.
> <ac> the locking will be an issue during save, I have not yet looked into
> this, maybe Hibernate will take care of that ?
>
> None of these is an issue if it's for a simple single-user filing
> system, but they could all be issues in a multi-user business system.
>
> <ac> I believe that's a problem, however considering the 'detached' nature
> of web application, the window for that conflict is relatively low, maybe
> user can live with occasional exceptions until a better solution is found?
>
> Actually, one Tapestry concern:
>
> - whenever there's an error, cat is being loaded twice, because
> onActivate() is called before and after onValidate().
> <ac> yes, that will be loaded twice, but the second time is not being
> used, it's simply a useless loading, it does not affect the operation, I
> think.
>
> T5's request/render mechanism works very well when there is no form
> involved, when the form is there, confusion starts, i believe, it's a
> matter of finding a way to use it properly, thanks.
>
> A.C.
>
> HTH,
>
> Geoff
>
> On 28/11/2007, at 1:36 PM, Angelo Chen wrote:
>
>>
>> Hi,
>> I have been trying to find a best practice for tapestry-hibernate,
>> looks
>> like there is none yet, here is an approach that I would do if the
>> tools
>> were still dbase/Clipper at this time, very old fashion, but seems
>> working,
>> no issue at all with @Persist, detached objects, any comments?
>>
>> public class TestCat {
>>
>> private Cat cat;
>> public String getName() { return cat.getName();}
>> public void setName(String name) { cat.setName(name);}
>> public String getGender() { return cat.getGender(); }
>> public void setGender(String gender) {cat.setGender(gender);}
>>
>> String onSuccess(String id2) {
>> if (catid == -1)
>> _session.persist(cat);
>> else {
>> Cat oldCat = (Cat) _session.load(Cat.class, catid);
>> oldCat.setGender(cat.getGender());
>> oldCat.setName(cat.getName());
>> }
>> return null;
>> }
>>
>> @Component
>> private Form myForm;
>>
>> public void onValidate(String id) throws EncoderException {
>> if (!cat.getGender().equals("m"))
>> myForm.recordError("we are looking for male cat only");
>> }
>>
>> @Inject private Session _session;
>>
>> private Long catid;
>>
>> public void onActivate(Long id) {
>> catid = id;
>> cat = new Cat(); // set up a buffer for editing
>> if (id > 0) { // copy contents, this might be a waste of cpu
>> resources, but life is easier
>> Cat oldCat = (Cat) _session.load(Cat.class, id);
>> cat.setGender(oldCat.getGender());
>> cat.setName(oldCat.getName());
>> }
>> }
>>
>> public Long onPassivate() { return catid; }
>> }
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/T5%3A-CRUD-basic-practice--tf4885903.html#a13984740
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/T5%3A-CRUD-basic-practice--tf4885903.html#a13993908
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]