You may already know the quick un-generic way to do this - but for example
this is what I have on a login page where I set focus to the password field
in case the user-id field is already filled in.

getBodyContainer().addOnLoadModifier(new AbstractReadOnlyModel() {
   public Object getObject() {
       String markupId;
       if(loginName.getConvertedInput() == null) {
           markupId = loginName.getMarkupId();
       } else {
           markupId = password.getMarkupId();
       }
       return "document.getElementById('" + markupId + "').focus()";
   }
}, password);


On 4/3/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote:

you can set some metadata into these components. have your page/form
subclass implement iheaderresponse, traverse the hierararchy in renderhead
and set focus to the first component with the right metadata through the
header response that is passed in.

sounds like a mouthful, but should be pretty simple to implement.

-igor


On 4/2/07, John Krasnay < [EMAIL PROTECTED]> wrote:
>
> Hi folks,
>
> I'm new to Wicket and I'm wondering if there's a "Wicket way" to have
> input focus set to the first form component on the page. I could always
> code up some
> Javascript to do this but it would be nice if I could flag certain form
> components as "wanting focus", then have the page set the focus to the
> first of these. Ideally, if any form components had failed validation,
> the
> page would ignore the "wanting focus" flag and give focus to the first
> invalid field.
>
> Any ideas?
>
> jk
>
>
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys-and earn cash
>
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to