You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by chimaira <de...@hotmail.com> on 2011/12/23 14:50:54 UTC

Control focus on input after a form feedback

Hi All, 
I using wicket for my war application.
I use wickets validator and feedback to control form inputs and constraints.
so usefull . easy and amazing.

But:
I wish to set a focus on a wrong input field (or change color to red for ex) 
after getting feedback error from wickets 'feedback'. but when this last one
(feedback) is invoked, I can't do anything. I have to focus manually (with
my pointer ) on the wrng field. 

My question, how to control focus after feedback . or how to perfomr actions
afeter getting feedback.

Thanks a lot . 

MA

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Control-focus-on-input-after-a-form-feedback-tp4228658p4228658.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Control focus on input after a form feedback

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

On Mon, Dec 26, 2011 at 2:23 PM, chimaira <de...@hotmail.com> wrote:
> hI Sven Meier, Thanks for the trick ,  but that causes other issues.
>
> firts: I use wicket version 1.4.16 and for some raison I can t upgrade to
> 1.5, and the methode renderHead(IHeaderResponse) is missing. I got only this
> one renderHead(HtmlHeaderContainer container) . Note the given argument on
> the seconde one (HtmlHeaderContainer  and not   (IHeaderResponse).

It must be there. Check again.

>
> Seconde: my form has more than one input field. how to target to wrong
> field. Can I do that by passing variables in  PageParameters ?  because if
> feedback is invoked the onSubmit form methode will not be called, then I
> can't passe variable in page parameters.

In this case you need #onError().
Here just safe a transient reference to the first input field with an
error and use it in renderHead() to do what Sven suggested.

>
> Any idea?
>
> Thanks in advance
> MA
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Control-focus-on-input-after-a-form-feedback-tp4228658p4234482.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Control focus on input after a form feedback

Posted by chimaira <de...@hotmail.com>.
hI Sven Meier, Thanks for the trick ,  but that causes other issues.

firts: I use wicket version 1.4.16 and for some raison I can t upgrade to
1.5, and the methode renderHead(IHeaderResponse) is missing. I got only this
one renderHead(HtmlHeaderContainer container) . Note the given argument on
the seconde one (HtmlHeaderContainer  and not   (IHeaderResponse). 

Seconde: my form has more than one input field. how to target to wrong
field. Can I do that by passing variables in  PageParameters ?  because if
feedback is invoked the onSubmit form methode will not be called, then I
can't passe variable in page parameters.

Any idea? 

Thanks in advance
MA



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Control-focus-on-input-after-a-form-feedback-tp4228658p4234482.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Control focus on input after a form feedback

Posted by Sven Meier <sv...@meiers.net>.
Overwrite #renderHead(IHeaderResponse), check for the first component 
with error message and add a little javascript:

response.renderOnLoadJavascript(String.format("document.getElementById('%s').focus()", 
componentWithError.getMarkupId()));

Regards
Sven

On 12/23/2011 02:50 PM, chimaira wrote:
> Hi All,
> I using wicket for my war application.
> I use wickets validator and feedback to control form inputs and constraints.
> so usefull . easy and amazing.
>
> But:
> I wish to set a focus on a wrong input field (or change color to red for ex)
> after getting feedback error from wickets 'feedback'. but when this last one
> (feedback) is invoked, I can't do anything. I have to focus manually (with
> my pointer ) on the wrng field.
>
> My question, how to control focus after feedback . or how to perfomr actions
> afeter getting feedback.
>
> Thanks a lot .
>
> MA
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Control-focus-on-input-after-a-form-feedback-tp4228658p4228658.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org