I think that forms and tables seem awfully verbose when you first
start Wicket.  A wiki page or two taking an example of such through a
reasonable evolution to some short, tight code would be nice.  I have
an old e-mail thread where Igor does exactly that, helping me.  I'll
put it together into such a page.  Where would y'all like it?

On a second point, Wicket's behaviors are insanely useful but
under-advertised.  We let customers buy a variety of products and then
we generate a form where the customer fills in the name of the person
picking up the show tickets, the club passes, checking into the hotel,
etc.  The first & last names are often the same and I was _easily_
able to create a behavior that I add to all of the first name fields
that propagates the model from one first name to all of the other
first names (and of course another for the last name).  I can't
imagine creating new, reusable functionality that easily in any other
framework.

(Don't confuse the enum method name() with the name property of the behavior...)


package com.vegas.ui.wicket.behaviors;

import wicket.Component;
import wicket.Component.IVisitor;
import wicket.ajax.AjaxRequestTarget;
import wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import wicket.markup.html.form.FormComponent;

public class ModelPropagationBehavior extends AjaxFormComponentUpdatingBehavior
{
        private static final long serialVersionUID = -451063727688504933L;

        public enum PREBUILT
        {
                FIRST_NAME, LAST_NAME;

                public ModelPropagationBehavior getBehavior()
                {
                        return new ModelPropagationBehavior(name());
                }
        }

        private final String name;

        public ModelPropagationBehavior(String n)
        {
                super("onblur");
                this.name = n;
        }

        private String getName()
        {
                return name;
        }

        private boolean hasMatchingBehavior(Component component)
        {
                for (Object behavior : component.getBehaviors())
                {
                        if (behavior instanceof ModelPropagationBehavior
                                        && ((ModelPropagationBehavior) 
behavior).getName().equals(this.name))
                                return true;
                }

                return false;
        }

        @Override
        protected void onUpdate(final AjaxRequestTarget target)
        {
                final FormComponent thisComponent = getFormComponent();

                thisComponent.getForm().visitChildren(new IVisitor()
                {
                        public Object component(Component otherComponent)
                        {
                                if (otherComponent.equals(thisComponent))
                                        return 
CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;

                                if (hasMatchingBehavior(otherComponent)
                                                && 
otherComponent.getModelObjectAsString().isEmpty())
                                {
                                        
otherComponent.setModelObject(thisComponent.getModelObject());
                                        target.addComponent(otherComponent);
                                        return 
CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;

                                }
                                return CONTINUE_TRAVERSAL;
                        }
                });
        }
}


On 6/6/07, Peter Thomas <[EMAIL PROTECTED]> wrote:
> I think I will echo Eelco in wishing you all the best with Struts2.
>
> Only thing I could summarize from this mail chain is that, maybe Wicket
> needs that one extra out-of-the-box extension of ListView that you can do
> say addColumn(String) and will use a Label by default?
>
> Otherwise as I said earlier, it is a waste of time trying to reverse
> pre-conceived notions about which is *THE* UI framework to use.  Or if you
> can point out anything obvious that the docs or examples are missing, I
> guess that can be looked into as well.
>
> Thanks,
>
> Peter.
>
>
>
> On 6/6/07, Florian Hehlen < [EMAIL PROTECTED]> wrote:
> > Hi John,
> >
> > John Krasnay wrote:
> > > Amongst Wicket's many advantages, the following stand out for me:
> > >
> > > - The ability to encapsulate UI components, including all required
> > >   markup, CSS, Javascript, and localization files, into shared JARs on
> > >   the classpath. Having a shared component library is key to our team,
> > >   since we tend to develop many small Web apps.
> > >
> > > - The ability to aggregate smaller components into larger and more
> > >   complex ones. This allows us to create much richer pages, since we can
> > >   think at an appropriate level of abstraction: I can just throw our
> > >   standard page banner component on a page without thinking about the
> > >   fact that it contains a logo, the app title, and a list of global
> > >   navigation links. (In fact, it's even simpler than that. The banner is
> > >   added by the base page that each app page extends.)
> > >
> > > - The fact that the same principles of a component tree and markup
> > >   inheritance work from the smallest components right up to the entire
> > >   page. This is very different from most Model2 frameworks, where you
> > >   need something like SiteMesh or Tiles to add common banners and
> > >   navbars to pages, and from JSF, where the internal structure of
> > >   components is very different that the way they are composed into
> > >   pages.
> > >
> >
> > I agree with you that these are some of the strongest benefits of
> > Wicket. In my experience these facts were seen as a disadvantage... and
> > I am still trying to figure out why? My group is a very strong OOP group
> > yet the fully contained component advantage of Wicket was not appealing.
> > The only reason I can find for these irrational conclusion is that the
> > Model 2 frameworks out there have defined themselves as THE proper web
> > implementation of MVC.
> >
> > Furthermore, our need for web-apps are peripheral to our main business.
> > We typically need to put together many small support web-applications.
> > so, Having a re-usabble set of components which require zero-config
> > would have been a great advantage.
> >
> > florian
> >
> >
> >
> -------------------------------------------------------------------------
> > This SF.net email is sponsored by DB2 Express
> > Download DB2 Express C - the FREE version of DB2 express and take
> > control of your XML. No limits. Just data. Click to get it now.
> > http://sourceforge.net/powerbar/db2/
> > _______________________________________________
> > Wicket-user mailing list
> > Wicket-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>


-- 
Scott Swank
reformed mathematician

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to