Personally i use the Netbeans way of GUI code generation done in JFrame GUI builder
 
//constructor
public MyPage(){
 
printPageHeader();
createPageLinks();
createPagePanels();
createPageForms();
 
printPageFooters();
}
infact i have made it a template in NB and i seem to enjoy this approach. even if my page contains no forms, the method returns void and so its empty.
 

 
On 4/3/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
yeah, but how many times are your onclick handles that simple? usually they are more complex, they might have a few try/catch blocks, etc. this is just syntactic sugar.
 

-Igor



On 4/3/06, Timo Stamm <[EMAIL PROTECTED]> wrote:
Alex schrieb:
> Hi,
> we've been using wicket for about a month now, so far so good.
> The only complain is about code lisibility, sometimes our constructors
> are filled with a lot of code, particurally with all the :
>
> add(new Link("myLink")
>         {
>             public void onClick(RequestCycle cycle)
>             {
>                 // do something here...
>             }
>         );


If java had good support for "closures", not just anonymous classes, the
syntax could be much more compact. A closure is a function object that
has access to the lexical environment of when it was created.


A closure could be declared like this:

    String {Object t} manipulate;

"String" means that the Closure returns a String.
"Object t" is the only argument.


The definition of a Closure could look like this:

   manipulate = {t | return t.toString + "abc"};

The part before "|" is the closure argument "t". The part after "|" is
the body of the closure.



So instead of using anonymous classes and overriding methods like this:

    new TextInput("myTextInput") {
       @Override
       String manipulate(String input) {
          return input.toString() + "abc";
       }
    }


The TextInput could accept a closure:

    new TextInput("myTextInput", {t | return input.toString() + "abc"});


The constructor signature:

    TextInput(String id, String {Object t} manipulate)



For more information, see the entry on closures in the wiki of the
excellent Martin Fowler:

   http://www.martinfowler.com/bliki/Closure.html




> [...] So we thought a custom component subclassing Link could force this
> approach :
>
> in constructor :
>
> add(new ReflectionLink("myLink", "myMethod"))
>
> and elsewhere :
>
> public void myMethod() { // do something here ... }
>
> Basically the ReflectionLink would contain some reflection stuff in
> onClick(RequestCycle cycle) to invoke our method...
>
> What do you think ?


What about something like this:


html:

    <input type="submit" wicket:reflect="onMyAction" />


java:

    class X extends WebPage {
       @Expose
       public void onMyAction() {
           System.out.println("myButton klicked");
       }

    }



Timo



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user





Reply via email to