On 8/22/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
>
> Looks good to me Xavier. A danger about the example is that it would
> probably be easy to be focussed on determining the password strength
> rather than how to create a custom component,


That's why I provide only a very simple implementation. It could even be
delegated to another service, I think audience can understand that.

but then again, the
> example by itself is nice, and can't just be found in the examples
> projects.
>
> The kind of example I was thinking about for my presentation would
> probably try to show off the fact that Wicket components are stateful
> and that the component hierarchy is flexible (Al's talk points that
> out nicely for instance).


Are you referring to his talk on bean editor? Maybe you could give me an
example of component you were thinking about?

Xavier

Eelco
>
>
> On 8/21/07, Xavier Hanin <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I've just begin to work on my presentation on Wicket for JavaZone (I'm
> > replacing Eelco), and I'd like to get some feedback about the agenda I
> > plan to follow. The description of the talk is the following:
> > "In this session, I will show you how you can use Apache Wicket to
> > develop web applications with Just Java and Just HTML. I'll talk a bit
> > about Wicket's philosophy and why it's developers believe it is
> > important to take a novel approach. And then, because only code really
> > talks, we'll take a deep dive to look at how to develop some custom,
> > reusable components."
> >
> > Hence here's the agenda I'm considering:
> >  •Introduction 5 min
> >  •What is Wicket   10 min
> >  •Core concepts of Wicket 15 min
> >  •Developing a custom component 20 min
> >  •Q&A       10 min
> >
> > For the two first topic I'll take inspiration from Martjin's
> > presentation at TSSJS europe last year, but in a much more condensed
> > way to keep enough time to talk about developing custom components
> > with real world example and demo.
> >
> > About the custom components, I think I will only demonstrate one
> > example, since 20 minutes is very short. My idea is to demonstrate how
> > to create a password field with a password strength indicator, where
> > the password strength is computed on the server by an Ajax call when
> > the user stop typing (the event will be triggered by a behavior
> > inspired by Nathan work in databinder, I don't plan to explain it).
> >
> > Here's the Java code for the component:
> > --------------8<---------------------
> > public class PasswordField extends Panel {
> >     public final static String WEAK = "weak";
> >     public final static String MEDIUM = "medium";
> >     public final static String STRONG = "strong";
> >
> >     public PasswordField(String id, IModel/*<String>*/ model) {
> >         super(id, model);
> >         PasswordTextField passwordTextField = new
> > PasswordTextField("password", model);
> >         add(passwordTextField);
> >
> >         final Label strength = new Label("strength", "");
> >         add(strength);
> >         strength.add(new AttributeModifier("class", true, new Model() {
> >             public Object getObject() {
> >                 return
> > getPasswordStrength((String)PasswordField.this.getModelObject());
> >             }
> >         }));
> >
> >         strength.setOutputMarkupId(true);
> >         passwordTextField.add(new OnKeyPausedAjaxBehavior() {
> >             protected void onUpdate(AjaxRequestTarget target) {
> >                 target.addComponent(strength);
> >             }
> >         });
> >     }
> >
> >     /**
> >      * Returns a String representing the strength of a password.
> >      * <p>
> >      * The String returned is one of:
> >      * <ul>
> >      * <li>[EMAIL PROTECTED] #WEAK}</li>
> >      * <li>[EMAIL PROTECTED] #MEDIUM}</li>
> >      * <li>[EMAIL PROTECTED] #STRONG}</li>
> >      * </ul>
> >      *
> >      * @param password the password to evaluate
> >      * @return a String representing the evaluated password strength
> >      */
> >     protected String getPasswordStrength(String password) {
> >         // this could involve some complex calculation based on a
> > dictionary for instance
> >         // here for simplicity reason we only use the password length
> >         if (password == null || password.length() <= 3) {
> >             return WEAK;
> >         }
> >         if (password.length() <= 5) {
> >             return MEDIUM;
> >         }
> >         return STRONG;
> >     }
> >
> > }
> > --------------8<---------------------
> >
> > And here is the html:
> > --------------8<---------------------
> > <html>
> >         <head>
> >                 <wicket:head>
> >                 <wicket:link>
> >                         <link rel="stylesheet" type="text/css" href="
> PasswordField.css"/>
> >                 </wicket:link>
> >                 </wicket:head>
> >         </head>
> >         <body>
> >                 <wicket:panel>
> >                         <input wicket:id="password" type="password" />
> <span
> > wicket:id="strength"></span>
> >                 </wicket:panel>
> >                 <hr/>
> >                 Examples:<br/>
> >                 <input type="password" /> <span class="weak"></span>
> (weak)<br/>
> >                 <input type="password" /> <span class="medium"></span>
> (medium)<br/>
> >                 <input type="password" /> <span class="strong"></span>
> (strong)<br/>
> >         </body>
> > </html>
> > --------------8<---------------------
> >
> > A css is used to change the background image of the password strength
> > meter depending on the span class set by the attribute modifier.
> >
> > So, what do you think about the agenda? Do you think the time planned
> > for each item is well thought? And about the custom component, do you
> > think it's a good example? Do you have some suggestions to make for
> > the code? Any feedback is appreciated!
> >
> > Xavier
> > --
> > Xavier Hanin - Independent Java Consultant
> > http://xhab.blogspot.com/
> > http://incubator.apache.org/ivy/
> > http://www.xoocode.org/
> >
>



-- 
Xavier Hanin - Independent Java Consultant
http://xhab.blogspot.com/
http://incubator.apache.org/ivy/
http://www.xoocode.org/

Reply via email to