Re: Adding common logic to all of onSuccess method / successful form submit

2012-02-02 Thread Yohan Yudanara
wow... thanks a lot.. :)
Your blog is awesome. It covers topic for intermediate/advanced Tapestry users.

At first, it's rather hard to understand..., but finally I can
understand about the topic and it's awesome...  :)

I've successfully implement common logic to all onSuccess method using
this code:

public class SubmitWorker implements ComponentClassTransformWorker2 {
@Override
public void transform(PlasticClass plasticClass,
TransformationSupport support, MutableComponentModel 
model) {
if 
(!plasticClass.getClassName().startsWith("com.blabla.pages."))
return;

for (PlasticMethod method : plasticClass.getMethods()) {
if 
(method.getMethodIdentifier().endsWith("onSuccess()")) {
method.addAdvice(new CommonOnSuccessAdvice());
}
}
}

private class CommonOnSuccessAdvice implements MethodAdvice {
@Override
public void advise(MethodInvocation invocation) {
//put common logic here
//bla bla bla

invocation.proceed();
}
}
}

and put this on AppModule.java:
@Contribute(ComponentClassTransformWorker2.class)
public static void
  provideWorkers(OrderedConfiguration
workers) {
  workers.addInstance("SubmitWorker", SubmitWorker.class);
}

Thanks a lot...

On Fri, Feb 3, 2012 at 10:39 AM, Taha Hafeez Siddiqi
 wrote:
> Hi Yohan
>
> It must be your lucky day. I just added a blog post related to this
>
> http://tawus.wordpress.com/2012/02/03/some-reporting-tricks-with-class-transformations/
>
> regards
> Taha
>
> On Feb 3, 2012, at 8:48 AM, Lenny Primak wrote:
>
>> I think method advice is your ticket here. Search tapestry docs for it.
>>
>>
>>
>> On Feb 2, 2012, at 10:14 PM, Yohan Yudanara  wrote:
>>
>>> Hi,
>>>
>>> I need to add some common logic (persist data into session) to all
>>> onSuccess method on all pages.
>>>
>>> Does anyone have a clue how to implement this?
>>> Is there any better way to do this instead of copy-pasting to all of
>>> onSuccess method?
>>> I've tried to subclass submit / form component, but I can't find a way
>>> to insert common logic when the form submitted successfully.
>>>
>>> Thanks in advance.
>>>
>>> Best regards,
>>> Yohan Yudanara
>>>
>>> -
>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Adding common logic to all of onSuccess method / successful form submit

2012-02-02 Thread Taha Hafeez Siddiqi
Hi Yohan

It must be your lucky day. I just added a blog post related to this

http://tawus.wordpress.com/2012/02/03/some-reporting-tricks-with-class-transformations/

regards
Taha

On Feb 3, 2012, at 8:48 AM, Lenny Primak wrote:

> I think method advice is your ticket here. Search tapestry docs for it. 
> 
> 
> 
> On Feb 2, 2012, at 10:14 PM, Yohan Yudanara  wrote:
> 
>> Hi,
>> 
>> I need to add some common logic (persist data into session) to all
>> onSuccess method on all pages.
>> 
>> Does anyone have a clue how to implement this?
>> Is there any better way to do this instead of copy-pasting to all of
>> onSuccess method?
>> I've tried to subclass submit / form component, but I can't find a way
>> to insert common logic when the form submitted successfully.
>> 
>> Thanks in advance.
>> 
>> Best regards,
>> Yohan Yudanara
>> 
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 



Re: Adding common logic to all of onSuccess method / successful form submit

2012-02-02 Thread Lenny Primak
I think method advice is your ticket here. Search tapestry docs for it. 



On Feb 2, 2012, at 10:14 PM, Yohan Yudanara  wrote:

> Hi,
> 
> I need to add some common logic (persist data into session) to all
> onSuccess method on all pages.
> 
> Does anyone have a clue how to implement this?
> Is there any better way to do this instead of copy-pasting to all of
> onSuccess method?
> I've tried to subclass submit / form component, but I can't find a way
> to insert common logic when the form submitted successfully.
> 
> Thanks in advance.
> 
> Best regards,
> Yohan Yudanara
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Adding common logic to all of onSuccess method / successful form submit

2012-02-02 Thread Yohan Yudanara
Hi,

I need to add some common logic (persist data into session) to all
onSuccess method on all pages.

Does anyone have a clue how to implement this?
Is there any better way to do this instead of copy-pasting to all of
onSuccess method?
I've tried to subclass submit / form component, but I can't find a way
to insert common logic when the form submitted successfully.

Thanks in advance.

Best regards,
Yohan Yudanara

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org