Hi Angelo,

   I guess the session.get(User.class, id) should happen in 
onActivate or onSuccess (where I use it).

Just threat the onSuccess method as an atomic event handler 
but onActivate should work also (not that sure).

Just print all the hits of the event methods to console and
see yourself. The order of the event should be:

1. onActivate
2. onSelectedXXX
3. onSuccess

I just use a schema like this in conjunction with a form 
context:

onSuccess(int userId) {
   User user = getUserById(id);
   alterTheUserAccordingToForm(user);
   storeUser(user);
}

Works very well.


Cheers,

Martin (Kersten)

-----Ursprüngliche Nachricht-----
Von: Angelo Chen [mailto:[EMAIL PROTECTED] 
Gesendet: Mittwoch, 5. März 2008 11:32
An: users@tapestry.apache.org
Betreff: Re: AW: AW: T5: determine button clicked in a beaneditor


hi martin,

yes, only to return a link:

 void onSelectedFromUpdate() {
     
            object = (Usr) session.get(Usr.class, id); // this is too late as a 
object has been created this time
    }

    void onSelectedFromBack() {
        System.out.println("from back");

    }

    Link onSuccess() {
        return backLink;
    }




Martin Kersten-2 wrote:
> 
> Hi Angelo,
> 
>    Are you using the onSuccess event?
> 
> Cheers,
> 
> Martin (Kersten)
> 
> -----Ursprüngliche Nachricht-----
> Von: Angelo Chen [mailto:[EMAIL PROTECTED]
> Gesendet: Mittwoch, 5. März 2008 10:48
> An: users@tapestry.apache.org
> Betreff: Re: AW: T5: determine button clicked in a beaneditor
> 
> 
> Hi Martin,
> 
> The onSelected even happens after the form fields have been submitted, 
> my need is to edit a Hibernate bean, what I'm doing now is: I 
> persisted the bean's id, in the onActivate even I re-read the bean, so 
> that form will update an existing bean, however, even the cancel 
> button triggers onActivate event as well. so moving the re-reading of 
> bean to onSelectedFromUpdate seems a solution, but it's too late at 
> that time as form has been submitted, any idea ? Thanks,
> 
> A.C.
> p.s. will be better if we can have an event before the form is 
> submitted, that is onActivate, but we have no way to determine which 
> button triggers the event there.
> 
> 
> Martin Kersten-2 wrote:
>> 
>> Hi A.C.
>> 
>>    I asked the very same question before but in conjunction with 
>> normal t:form component. Since the bean-editor is based on that 
>> t:form component it should apply to this scenario as well:
>> 
>> Rule of Thumb: If you have a button you have an onSelected event!
>> 
>> So in your case:
>> 
>> <t:form>
>>  <input t:type="submit" t:id="done" value="Done"/>  <input 
>> t:type="submit" t:id="failed" value="Failed"/> </t:form>
>> 
>> class MyPage {
>>    final int DONE = 0;
>>    final int FAILED = 1;
>> 
>>    int submitType = DONE;
>> 
>>    boolean onSelectedFromDone() {
>>       submitType = DONE;
>>       return true;
>>    }
>> 
>> 
>> 
> 
> --
> View this message in context:
> http://www.nabble.com/T5%3A-determine-button-clicked-in-a-beaneditor-t
> p15841944p15846642.html 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-determine-button-clicked-in-a-beaneditor-tp15841944p15847228.html
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]

Reply via email to