You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by bryan0101 <bt...@gmail.com> on 2007/12/19 22:22:05 UTC

In appfuse example, UserForm instantiate static abstract inner class ?

I have googled this question in many forms without much success. The problem
is I'm trying to understand the appfuse wicket example. And the only thing
I'm not getting is the use of private static abstract class inner member
class.

<code>
public class UserForm extends BasePage {
    @SpringBean
    private UserManager userManager;
    private final Page backPage;

    public UserForm(Page backPage) {
        this(backPage, new User());
    }

    public UserForm(final Page backPage, User user) {
        this.backPage = backPage;

        // Create and add the form
        EditForm form = new EditForm("user-form", user) {
            protected void onSave(User user) {
                onSaveUser(user);
            }

            protected void onCancel() {
                onCancelEditing();
            }

            protected void onDelete(User user) {
                onDeleteUser(user);
            }
        };
        add(form);
    }
   ...
   ...
   private void onCancelEditing() {
        setResponsePage(backPage);
    }
    private static abstract class EditForm extends Form {
                 private void add(FormComponent fc, IModel label) {
             .....
</code>

Now I understand inner class, static etc etc... But what is the use of
abstract in this instant, (all the while instantiating it in enclosing
class's constructor. Would it work with just private static class? 
-- 
View this message in context: http://www.nabble.com/In-appfuse-example%2C-UserForm-instantiate-static-abstract-inner-class---tp14425471p14425471.html
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: In appfuse example, UserForm instantiate static abstract inner class ?

Posted by bryan0101 <bt...@gmail.com>.
Absolutely... thank you.



Gwyn wrote:
> 
> The point is that in the constructor, you're actually instantiating an
> anonymous class that *extends* EditForm.  It won't work without the
> abstract, because the onXXX methods are abstract and need
> implementing.
> 
> /Gwyn
> 
> On 19/12/2007, bryan0101 <bt...@gmail.com> wrote:
>>
>> I have googled this question in many forms without much success. The
>> problem
>> is I'm trying to understand the appfuse wicket example. And the only
>> thing
>> I'm not getting is the use of private static abstract class inner member
>> class.
>>
>> <code>
>> public class UserForm extends BasePage {
>>     @SpringBean
>>     private UserManager userManager;
>>     private final Page backPage;
>>
>>     public UserForm(Page backPage) {
>>         this(backPage, new User());
>>     }
>>
>>     public UserForm(final Page backPage, User user) {
>>         this.backPage = backPage;
>>
>>         // Create and add the form
>>         EditForm form = new EditForm("user-form", user) {
>>             protected void onSave(User user) {
>>                 onSaveUser(user);
>>             }
>>
>>             protected void onCancel() {
>>                 onCancelEditing();
>>             }
>>
>>             protected void onDelete(User user) {
>>                 onDeleteUser(user);
>>             }
>>         };
>>         add(form);
>>     }
>>    ...
>>    ...
>>    private void onCancelEditing() {
>>         setResponsePage(backPage);
>>     }
>>     private static abstract class EditForm extends Form {
>>                  private void add(FormComponent fc, IModel label) {
>>              .....
>> </code>
>>
>> Now I understand inner class, static etc etc... But what is the use of
>> abstract in this instant, (all the while instantiating it in enclosing
>> class's constructor. Would it work with just private static class?
>> --
>> View this message in context:
>> http://www.nabble.com/In-appfuse-example%2C-UserForm-instantiate-static-abstract-inner-class---tp14425471p14425471.html
>> 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/In-appfuse-example%2C-UserForm-instantiate-static-abstract-inner-class---tp14425471p14428257.html
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: In appfuse example, UserForm instantiate static abstract inner class ?

Posted by Gwyn Evans <gw...@gmail.com>.
The point is that in the constructor, you're actually instantiating an
anonymous class that *extends* EditForm.  It won't work without the
abstract, because the onXXX methods are abstract and need
implementing.

/Gwyn

On 19/12/2007, bryan0101 <bt...@gmail.com> wrote:
>
> I have googled this question in many forms without much success. The problem
> is I'm trying to understand the appfuse wicket example. And the only thing
> I'm not getting is the use of private static abstract class inner member
> class.
>
> <code>
> public class UserForm extends BasePage {
>     @SpringBean
>     private UserManager userManager;
>     private final Page backPage;
>
>     public UserForm(Page backPage) {
>         this(backPage, new User());
>     }
>
>     public UserForm(final Page backPage, User user) {
>         this.backPage = backPage;
>
>         // Create and add the form
>         EditForm form = new EditForm("user-form", user) {
>             protected void onSave(User user) {
>                 onSaveUser(user);
>             }
>
>             protected void onCancel() {
>                 onCancelEditing();
>             }
>
>             protected void onDelete(User user) {
>                 onDeleteUser(user);
>             }
>         };
>         add(form);
>     }
>    ...
>    ...
>    private void onCancelEditing() {
>         setResponsePage(backPage);
>     }
>     private static abstract class EditForm extends Form {
>                  private void add(FormComponent fc, IModel label) {
>              .....
> </code>
>
> Now I understand inner class, static etc etc... But what is the use of
> abstract in this instant, (all the while instantiating it in enclosing
> class's constructor. Would it work with just private static class?
> --
> View this message in context: http://www.nabble.com/In-appfuse-example%2C-UserForm-instantiate-static-abstract-inner-class---tp14425471p14425471.html
> 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