You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by carloc <ca...@yahoo.com> on 2007/09/23 17:21:08 UTC
Button Command Design Pattern
Hi guys I was just wondering if this is an antipattern in wicket.
Instead of using anonymous Button classes, I created a Button Command Class
which I override.
I also created a class which indicates the button that I need.
I did this so I can be sure that I will be able to catch all the default
exceptions that exist.
Also any change in the button implementation I'll only change in one place.
Is this an anti pattern?>
I call it in my pages through this command
add(new CCTIButton("ajax-button", this, buttonCommand));
public abstract class ButtonCommand implements Serializable {
public abstract void onSubmit();
public abstract void onError();
}
public class CCTIButton extends IndicatingAjaxButton {
private ButtonCommand buttonCommand;
public CCTIButton(String id, Form form, ButtonCommand buttonCommand) {
super(id, form);
this.buttonCommand = buttonCommand;
}
@Override
protected void onSubmit(AjaxRequestTarget target, Form form) {
// TODO Auto-generated method stub
try {
buttonCommand.onSubmit();
} catch(Exception e) {
}
}
@Override
protected void onError(AjaxRequestTarget target, Form form) {
// TODO Auto-generated method stub
buttonCommand.onError();
}
--
View this message in context: http://www.nabble.com/Button-Command-Design-Pattern-tf4504772.html#a12847315
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Button Command Design Pattern
Posted by carloc <ca...@yahoo.com>.
great,
i'm able to catch most exceptions in one place.
thanks
igor.vaynberg wrote:
>
> i wouldnt say it is an antipattern.
>
> -igor
>
>
> On 9/23/07, carloc <ca...@yahoo.com> wrote:
>>
>>
>> Hi guys I was just wondering if this is an antipattern in wicket.
>> Instead of using anonymous Button classes, I created a Button Command
>> Class
>> which I override.
>> I also created a class which indicates the button that I need.
>> I did this so I can be sure that I will be able to catch all the default
>> exceptions that exist.
>> Also any change in the button implementation I'll only change in one
>> place.
>>
>> Is this an anti pattern?>
>> I call it in my pages through this command
>>
>> add(new CCTIButton("ajax-button", this, buttonCommand));
>>
>>
>> public abstract class ButtonCommand implements Serializable {
>> public abstract void onSubmit();
>> public abstract void onError();
>> }
>>
>>
>> public class CCTIButton extends IndicatingAjaxButton {
>>
>> private ButtonCommand buttonCommand;
>>
>> public CCTIButton(String id, Form form, ButtonCommand
>> buttonCommand) {
>> super(id, form);
>> this.buttonCommand = buttonCommand;
>> }
>>
>> @Override
>> protected void onSubmit(AjaxRequestTarget target, Form form) {
>> // TODO Auto-generated method stub
>> try {
>> buttonCommand.onSubmit();
>> } catch(Exception e) {
>>
>> }
>>
>> }
>>
>> @Override
>> protected void onError(AjaxRequestTarget target, Form form) {
>> // TODO Auto-generated method stub
>> buttonCommand.onError();
>> }
>> --
>> View this message in context:
>> http://www.nabble.com/Button-Command-Design-Pattern-tf4504772.html#a12847315
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Button-Command-Design-Pattern-tf4504772.html#a12847966
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Button Command Design Pattern
Posted by Igor Vaynberg <ig...@gmail.com>.
i wouldnt say it is an antipattern.
-igor
On 9/23/07, carloc <ca...@yahoo.com> wrote:
>
>
> Hi guys I was just wondering if this is an antipattern in wicket.
> Instead of using anonymous Button classes, I created a Button Command
> Class
> which I override.
> I also created a class which indicates the button that I need.
> I did this so I can be sure that I will be able to catch all the default
> exceptions that exist.
> Also any change in the button implementation I'll only change in one
> place.
>
> Is this an anti pattern?>
> I call it in my pages through this command
>
> add(new CCTIButton("ajax-button", this, buttonCommand));
>
>
> public abstract class ButtonCommand implements Serializable {
> public abstract void onSubmit();
> public abstract void onError();
> }
>
>
> public class CCTIButton extends IndicatingAjaxButton {
>
> private ButtonCommand buttonCommand;
>
> public CCTIButton(String id, Form form, ButtonCommand
> buttonCommand) {
> super(id, form);
> this.buttonCommand = buttonCommand;
> }
>
> @Override
> protected void onSubmit(AjaxRequestTarget target, Form form) {
> // TODO Auto-generated method stub
> try {
> buttonCommand.onSubmit();
> } catch(Exception e) {
>
> }
>
> }
>
> @Override
> protected void onError(AjaxRequestTarget target, Form form) {
> // TODO Auto-generated method stub
> buttonCommand.onError();
> }
> --
> View this message in context:
> http://www.nabble.com/Button-Command-Design-Pattern-tf4504772.html#a12847315
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>