You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by kshitiz <k....@gmail.com> on 2012/05/14 20:10:26 UTC

Need help in implementing Ajax form

Hi,

I am trying to learn Ajax in Wicket and implement it in my project. I am
trying to use AjaxFallbackButton but there is something I am missing. Here
is my code:

StatelessForm<UserDomain> loginForm = new StatelessForm<UserDomain>(
				"loginForm", new CompoundPropertyModel<UserDomain>(userDomain));


AjaxFallbackButton ajaxSubmitButton = new AjaxFallbackButton(
				"ajaxSubmitButton", loginForm) {

			/**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			@Override
			protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

				if(target!=null){
				UserService userService = new UserService();
				try {
					userDomain = userService.login(emailIdTextField.getValue(),
							passwordTextField.getValue());
				} catch (Exception exception) {
					error(exception.getMessage());
					error = true;
				}

				if (!error) {
					setResponsePage(Home.class, pageParameters);
				}
				}
			}

			@Override
			protected void onError(AjaxRequestTarget target, Form<?> form) {
				// TODO Auto-generated method stub

			}
		};
		loginForm.add(ajaxSubmitButton);
}

Html is 
<input type="submit" value="Login" class="formbutton" name="Login"
wicket:id="ajaxSubmitButton"/>

But when I press Login button, nothing happens...Please help me out here as
I am new to this. Is there any good doc available for this? Also, why WICKET
AJAX DEBUG mark is coming in bottom right corner of my web page?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Need-help-in-implementing-Ajax-form-tp4632760.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: Need help in implementing Ajax form

Posted by Sebastien <se...@gmail.com>.
Damed! I just make me realizing I wrote "the anonymous method onSubmit"! I
cannot believe it...

On Mon, May 14, 2012 at 9:59 PM, W Mazur <wl...@gmail.com> wrote:

> Hi,
> -  Use Firefox with Firebug to track down client-server comunication
> (or lack of it) - Do you have javascript enebled? If terget == null
> then nothing happens in onSubmit() method.
> - Add some logging (log4j etc.), to your app
>
> Regards
> Wlodek
>
> 2012/5/14 Sebastien <se...@gmail.com>:
> > And the WICKET AJAX DEBUG mark appears as soon as you are dealing with
> > wicket ajax component. It is not displayed anymore when your
> configuration
> > changes from "development" to "deployment" (web.xml)
> >
> > On Mon, May 14, 2012 at 9:47 PM, Sebastien <se...@gmail.com> wrote:
> >
> >> Hi kshitiz,
> >>
> >> Well, looking at the code as-is does not make me understand what is
> going
> >> wrong. I mean, it should go until onSubmit(). For you implementation, I
> can
> >> just notice that you did not reattach any feedback panel to the target.
> >> Maybe you do not see the error (but if it happens, you can see it in the
> >> console as "Component feedback message was left unrendered..."); and you
> >> changed the reference to the userDomain object. the model is then not
> >> sync. You need to do something like
> loginForm.setModelObject(userDomain).
> >> Mark the form as final to be able to access it from the anonymous method
> >> onSubmit.
> >>
> >> But apart from that, I just would like to tell you that if you need an
> >> authentication mechanism, you'll probably better have to use the
> >> wicket-auth-roles.
> >> All you need to know is here:
> >> http://wicket.apache.org/learn/projects/authroles.html
> >>
> >> Regards,
> >> Sebastien
> >>
> >> On Mon, May 14, 2012 at 8:10 PM, kshitiz <k....@gmail.com> wrote:
> >>
> >>> Hi,
> >>>
> >>> I am trying to learn Ajax in Wicket and implement it in my project. I
> am
> >>> trying to use AjaxFallbackButton but there is something I am missing.
> Here
> >>> is my code:
> >>>
> >>> StatelessForm<UserDomain> loginForm = new StatelessForm<UserDomain>(
> >>>                                "loginForm", new
> >>> CompoundPropertyModel<UserDomain>(userDomain));
> >>>
> >>>
> >>> AjaxFallbackButton ajaxSubmitButton = new AjaxFallbackButton(
> >>>                                "ajaxSubmitButton", loginForm) {
> >>>
> >>>                        /**
> >>>                         *
> >>>                         */
> >>>                        private static final long serialVersionUID = 1L;
> >>>
> >>>                        @Override
> >>>                        protected void onSubmit(AjaxRequestTarget
> target,
> >>> Form<?> form) {
> >>>
> >>>                                if(target!=null){
> >>>                                UserService userService = new
> >>> UserService();
> >>>                                try {
> >>>                                        userDomain =
> >>> userService.login(emailIdTextField.getValue(),
> >>>
> >>>  passwordTextField.getValue());
> >>>                                } catch (Exception exception) {
> >>>                                        error(exception.getMessage());
> >>>                                        error = true;
> >>>                                }
> >>>
> >>>                                if (!error) {
> >>>                                        setResponsePage(Home.class,
> >>> pageParameters);
> >>>                                }
> >>>                                }
> >>>                        }
> >>>
> >>>                        @Override
> >>>                        protected void onError(AjaxRequestTarget target,
> >>> Form<?> form) {
> >>>                                // TODO Auto-generated method stub
> >>>
> >>>                        }
> >>>                };
> >>>                loginForm.add(ajaxSubmitButton);
> >>> }
> >>>
> >>> Html is
> >>> <input type="submit" value="Login" class="formbutton" name="Login"
> >>> wicket:id="ajaxSubmitButton"/>
> >>>
> >>> But when I press Login button, nothing happens...Please help me out
> here
> >>> as
> >>> I am new to this. Is there any good doc available for this? Also, why
> >>> WICKET
> >>> AJAX DEBUG mark is coming in bottom right corner of my web page?
> >>>
> >>> --
> >>> View this message in context:
> >>>
> http://apache-wicket.1842946.n4.nabble.com/Need-help-in-implementing-Ajax-form-tp4632760.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
>
>

Re: Need help in implementing Ajax form

Posted by W Mazur <wl...@gmail.com>.
Hi,
-  Use Firefox with Firebug to track down client-server comunication
(or lack of it) - Do you have javascript enebled? If terget == null
then nothing happens in onSubmit() method.
- Add some logging (log4j etc.), to your app

Regards
Wlodek

2012/5/14 Sebastien <se...@gmail.com>:
> And the WICKET AJAX DEBUG mark appears as soon as you are dealing with
> wicket ajax component. It is not displayed anymore when your configuration
> changes from "development" to "deployment" (web.xml)
>
> On Mon, May 14, 2012 at 9:47 PM, Sebastien <se...@gmail.com> wrote:
>
>> Hi kshitiz,
>>
>> Well, looking at the code as-is does not make me understand what is going
>> wrong. I mean, it should go until onSubmit(). For you implementation, I can
>> just notice that you did not reattach any feedback panel to the target.
>> Maybe you do not see the error (but if it happens, you can see it in the
>> console as "Component feedback message was left unrendered..."); and you
>> changed the reference to the userDomain object. the model is then not
>> sync. You need to do something like loginForm.setModelObject(userDomain).
>> Mark the form as final to be able to access it from the anonymous method
>> onSubmit.
>>
>> But apart from that, I just would like to tell you that if you need an
>> authentication mechanism, you'll probably better have to use the
>> wicket-auth-roles.
>> All you need to know is here:
>> http://wicket.apache.org/learn/projects/authroles.html
>>
>> Regards,
>> Sebastien
>>
>> On Mon, May 14, 2012 at 8:10 PM, kshitiz <k....@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I am trying to learn Ajax in Wicket and implement it in my project. I am
>>> trying to use AjaxFallbackButton but there is something I am missing. Here
>>> is my code:
>>>
>>> StatelessForm<UserDomain> loginForm = new StatelessForm<UserDomain>(
>>>                                "loginForm", new
>>> CompoundPropertyModel<UserDomain>(userDomain));
>>>
>>>
>>> AjaxFallbackButton ajaxSubmitButton = new AjaxFallbackButton(
>>>                                "ajaxSubmitButton", loginForm) {
>>>
>>>                        /**
>>>                         *
>>>                         */
>>>                        private static final long serialVersionUID = 1L;
>>>
>>>                        @Override
>>>                        protected void onSubmit(AjaxRequestTarget target,
>>> Form<?> form) {
>>>
>>>                                if(target!=null){
>>>                                UserService userService = new
>>> UserService();
>>>                                try {
>>>                                        userDomain =
>>> userService.login(emailIdTextField.getValue(),
>>>
>>>  passwordTextField.getValue());
>>>                                } catch (Exception exception) {
>>>                                        error(exception.getMessage());
>>>                                        error = true;
>>>                                }
>>>
>>>                                if (!error) {
>>>                                        setResponsePage(Home.class,
>>> pageParameters);
>>>                                }
>>>                                }
>>>                        }
>>>
>>>                        @Override
>>>                        protected void onError(AjaxRequestTarget target,
>>> Form<?> form) {
>>>                                // TODO Auto-generated method stub
>>>
>>>                        }
>>>                };
>>>                loginForm.add(ajaxSubmitButton);
>>> }
>>>
>>> Html is
>>> <input type="submit" value="Login" class="formbutton" name="Login"
>>> wicket:id="ajaxSubmitButton"/>
>>>
>>> But when I press Login button, nothing happens...Please help me out here
>>> as
>>> I am new to this. Is there any good doc available for this? Also, why
>>> WICKET
>>> AJAX DEBUG mark is coming in bottom right corner of my web page?
>>>
>>> --
>>> View this message in context:
>>> http://apache-wicket.1842946.n4.nabble.com/Need-help-in-implementing-Ajax-form-tp4632760.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


Re: Need help in implementing Ajax form

Posted by Sebastien <se...@gmail.com>.
And the WICKET AJAX DEBUG mark appears as soon as you are dealing with
wicket ajax component. It is not displayed anymore when your configuration
changes from "development" to "deployment" (web.xml)

On Mon, May 14, 2012 at 9:47 PM, Sebastien <se...@gmail.com> wrote:

> Hi kshitiz,
>
> Well, looking at the code as-is does not make me understand what is going
> wrong. I mean, it should go until onSubmit(). For you implementation, I can
> just notice that you did not reattach any feedback panel to the target.
> Maybe you do not see the error (but if it happens, you can see it in the
> console as "Component feedback message was left unrendered..."); and you
> changed the reference to the userDomain object. the model is then not
> sync. You need to do something like loginForm.setModelObject(userDomain).
> Mark the form as final to be able to access it from the anonymous method
> onSubmit.
>
> But apart from that, I just would like to tell you that if you need an
> authentication mechanism, you'll probably better have to use the
> wicket-auth-roles.
> All you need to know is here:
> http://wicket.apache.org/learn/projects/authroles.html
>
> Regards,
> Sebastien
>
> On Mon, May 14, 2012 at 8:10 PM, kshitiz <k....@gmail.com> wrote:
>
>> Hi,
>>
>> I am trying to learn Ajax in Wicket and implement it in my project. I am
>> trying to use AjaxFallbackButton but there is something I am missing. Here
>> is my code:
>>
>> StatelessForm<UserDomain> loginForm = new StatelessForm<UserDomain>(
>>                                "loginForm", new
>> CompoundPropertyModel<UserDomain>(userDomain));
>>
>>
>> AjaxFallbackButton ajaxSubmitButton = new AjaxFallbackButton(
>>                                "ajaxSubmitButton", loginForm) {
>>
>>                        /**
>>                         *
>>                         */
>>                        private static final long serialVersionUID = 1L;
>>
>>                        @Override
>>                        protected void onSubmit(AjaxRequestTarget target,
>> Form<?> form) {
>>
>>                                if(target!=null){
>>                                UserService userService = new
>> UserService();
>>                                try {
>>                                        userDomain =
>> userService.login(emailIdTextField.getValue(),
>>
>>  passwordTextField.getValue());
>>                                } catch (Exception exception) {
>>                                        error(exception.getMessage());
>>                                        error = true;
>>                                }
>>
>>                                if (!error) {
>>                                        setResponsePage(Home.class,
>> pageParameters);
>>                                }
>>                                }
>>                        }
>>
>>                        @Override
>>                        protected void onError(AjaxRequestTarget target,
>> Form<?> form) {
>>                                // TODO Auto-generated method stub
>>
>>                        }
>>                };
>>                loginForm.add(ajaxSubmitButton);
>> }
>>
>> Html is
>> <input type="submit" value="Login" class="formbutton" name="Login"
>> wicket:id="ajaxSubmitButton"/>
>>
>> But when I press Login button, nothing happens...Please help me out here
>> as
>> I am new to this. Is there any good doc available for this? Also, why
>> WICKET
>> AJAX DEBUG mark is coming in bottom right corner of my web page?
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Need-help-in-implementing-Ajax-form-tp4632760.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: Need help in implementing Ajax form

Posted by kshitiz <k....@gmail.com>.
Thank you very much for the reply...you have solved it...

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Need-help-in-implementing-Ajax-form-tp4632760p4642518.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: Need help in implementing Ajax form

Posted by Sebastien <se...@gmail.com>.
Hi kshitiz,

Well, looking at the code as-is does not make me understand what is going
wrong. I mean, it should go until onSubmit(). For you implementation, I can
just notice that you did not reattach any feedback panel to the target.
Maybe you do not see the error (but if it happens, you can see it in the
console as "Component feedback message was left unrendered..."); and you
changed the reference to the userDomain object. the model is then not sync.
You need to do something like loginForm.setModelObject(userDomain). Mark
the form as final to be able to access it from the anonymous method
onSubmit.

But apart from that, I just would like to tell you that if you need an
authentication mechanism, you'll probably better have to use the
wicket-auth-roles.
All you need to know is here:
http://wicket.apache.org/learn/projects/authroles.html

Regards,
Sebastien

On Mon, May 14, 2012 at 8:10 PM, kshitiz <k....@gmail.com> wrote:

> Hi,
>
> I am trying to learn Ajax in Wicket and implement it in my project. I am
> trying to use AjaxFallbackButton but there is something I am missing. Here
> is my code:
>
> StatelessForm<UserDomain> loginForm = new StatelessForm<UserDomain>(
>                                "loginForm", new
> CompoundPropertyModel<UserDomain>(userDomain));
>
>
> AjaxFallbackButton ajaxSubmitButton = new AjaxFallbackButton(
>                                "ajaxSubmitButton", loginForm) {
>
>                        /**
>                         *
>                         */
>                        private static final long serialVersionUID = 1L;
>
>                        @Override
>                        protected void onSubmit(AjaxRequestTarget target,
> Form<?> form) {
>
>                                if(target!=null){
>                                UserService userService = new UserService();
>                                try {
>                                        userDomain =
> userService.login(emailIdTextField.getValue(),
>
>  passwordTextField.getValue());
>                                } catch (Exception exception) {
>                                        error(exception.getMessage());
>                                        error = true;
>                                }
>
>                                if (!error) {
>                                        setResponsePage(Home.class,
> pageParameters);
>                                }
>                                }
>                        }
>
>                        @Override
>                        protected void onError(AjaxRequestTarget target,
> Form<?> form) {
>                                // TODO Auto-generated method stub
>
>                        }
>                };
>                loginForm.add(ajaxSubmitButton);
> }
>
> Html is
> <input type="submit" value="Login" class="formbutton" name="Login"
> wicket:id="ajaxSubmitButton"/>
>
> But when I press Login button, nothing happens...Please help me out here as
> I am new to this. Is there any good doc available for this? Also, why
> WICKET
> AJAX DEBUG mark is coming in bottom right corner of my web page?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Need-help-in-implementing-Ajax-form-tp4632760.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
>
>