If you can find JSF components that do exactly what you want then JSF
is more compact.  If, however, you find JSF components that do nearly
what you want, but you have to add a bit of functionality, well then
you're into the lovely world of phase listeners and the
request/response life cycle.  Dante located JSF phase listeners within
the 4th circle of hell if I remember correctly.

One of the first "ah ha" moments I had with Wicket was when I needed
to copy customer names from one field to another.  If a customer
purchases several items (tickets to shows, books a tour, reserves a
hotel room) then the guest name associated with one item is typically,
but not always, the guest name for all of the items.  With a nominal
amount of reasonably clear code I was able to create a behavior that I
simply attach to all of the first names and last names.  It copies the
value of one field to all of the matching fields that are empty and
updates all of these fields via ajax.  It's 22 lines if you don't
count whitespace & braces and it is completely reusable.  It can be
attached to any two or more form components and it just works.

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 Wed, Aug 6, 2008 at 11:44 PM, nlif <[EMAIL PROTECTED]> wrote:
>
> Thanks Timm. This is valuable feedback. Nevertheless - can you point to any
> advantage JSF has over Wicket? Anything at all?
>
> Thanks
>
>
>
>
>
> Timm Helbig wrote:
>>
>> Hi,
>>
>> I did one Project with JSF and two with Wicket.
>>
>> By far Wicket is much easier to handle, (nearly) everything works as
>> supposed,
>> which is not true for JSF, especially when it comes to external Libraries
>> like Trinidad or other UI Extension Libraries.
>>
>> One other thing which is important for me is the Productivity.  And this
>> is
>> much higher with Wicket than with JSF.
>>
>> The Community support is suberb with Wicket, and somewhat difficult when
>> you
>> check the JSF Forums, but this depends on the Manufactor of the Library
>> you
>> use.
>>
>> I don't want to slash JSF here, but I find it is miles away from a usable
>> Product. For me it looks more like a prototype of what could be possible.
>> Just check what happened from 1.1  to 1.2, and you see, that even Sun
>> seemed
>> to face this.
>>
>> Regards,
>> Timm
>>
>> Am Mittwoch, 6. August 2008 11:13:53 schrieb nlif:
>>> Hi all,
>>>
>>> We are in the process of selecting a web-framework, and although I am in
>>> favor of Wicket, I was asked to provide an objective comparison of Wicket
>>> with JSF. I have developed a few small apps in Wicket, but I admit I am
>>> not
>>> very familiar with JSF. Prior to posting here, I googled a bit, and found
>>> a
>>> few forum-threads and blog posts on this topic, but most are from 1-2
>>> years
>>> ago and in framework years, this may be considered obsolete.
>>>
>>> Although this is the Wicket forum, I expect there are people here who
>>> also
>>> used (or at least evaluated) JSF at some point, so I'd be happy if folks
>>> here could share their experience. If anyone can point me to useful links
>>> that would be great too.
>>>
>>> I really am not trying to provoke a flame war, just to gather
>>> information.
>>>
>>> In your opinion, what are Wicket strengths? What are JSF's ? (even if
>>> you're a Wicket fan, surely there's something ;)
>>>
>>> I would be interested to hear people thoughts regarding the fact the JSF
>>> is
>>> a standard, while Wicket is not. How important is that to you? In what
>>> ways
>>> do you think this matters (if at all)?
>>>
>>> Also, supposedly JSF has a larger selection of 3rd party components
>>> compared to Wicket. Is this true? how often do you find yourself rolling
>>> your own components and how hard is it to do so in Wicket (and I mean
>>> non-trivial-good-looking-Ajax-enabled stuff).
>>>
>>> Many thanks in advance.
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>
> --
> View this message in context: 
> http://www.nabble.com/Comparing-JSF-and-Wicket-tp18847208p18864975.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to