Here are the code snippets for a better understanding,
//The form
Form form = new Form("form"){
/**
*
*/
private static final long serialVersionUID = 1L;
protected void validate(){
super.validate();
boolean isValid = false;
for(CheckModel cModel : checkModels){
if(cModel.getChecked()){
isValid = true;
break;
}
}
if(!isValid || checkModels.isEmpty()){
error("Atleast one checkbox is required!!");
}
}
};
//The uncheck all ajax submit link
form.add(new AjaxSubmitLink("uncheckall") {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form form) {
checks.clear();
for(CheckModel cModel : checkModels){
cModel .setChecked(Boolean.FALSE);
}
if(target != null){
target.addComponent(CheckModalPanel.this);
}
}
});
//The ajaxbutton that is used
form.add(new IndicatingAjaxButton("setCheck", form) {
/**
*/
private static final long serialVersionUID = 1L;
protected void onSubmit(AjaxRequestTarget target, Form form) {
checks.clear();
for(CheckModel cModel : checkModels){
if(cModel.getChecked()){
//copy the checked models to session
}
}
setRedirect(true);
setResponsePage(getApplication().getHomePage());
}
protected void onError(AjaxRequestTarget target, Form form) {
if (target != null) {
target.addComponent(feedback);
setRedirect(false);
}
}
});
On Tue, Jun 9, 2009 at 5:10 PM, Jade <[email protected]> wrote:
> Oh...Anyways as of now, I am not setting the setDefaultProcessing on the
> AjaxButton...
>
> Thanks again!
>
> On Tue, Jun 9, 2009 at 5:06 PM, Igor Vaynberg <[email protected]>wrote:
>
>> woops, i meant setdefaultformprocessing(FALSE)
>>
>> -igor
>>
>> On Tue, Jun 9, 2009 at 7:56 AM, Igor Vaynberg<[email protected]>
>> wrote:
>> > onsubmit() is only called if validation passes or you called
>> > setdefaultformprocessing(true) on the button/submitlink.
>> >
>> > -igor
>> >
>> > On Tue, Jun 9, 2009 at 7:52 AM, Jade<[email protected]> wrote:
>> >> Well - I did try using the AjaxSubmitLink, the validation happens
>> during the
>> >> link click and displays the error message..but even after the error
>> message
>> >> is shown, when I click the AjaxButton in the form, the form submit
>> happens
>> >> :-(
>> >>
>> >> Do I have to setDefaultFormProcessing(false) or something else I am
>> getting
>> >> wrong here?
>> >>
>> >> On Tue, Jun 9, 2009 at 4:42 PM, Igor Vaynberg <[email protected]
>> >wrote:
>> >>
>> >>> if you need to submit the form use ajaxsubmitlink, if you dont then
>> >>> use the normal ajaxlink.
>> >>>
>> >>> -igor
>> >>>
>> >>> On Tue, Jun 9, 2009 at 7:39 AM, Jade<[email protected]> wrote:
>> >>> > Hi Igor,
>> >>> >
>> >>> > Yes, I did understand that after a deeper look. But for my use
>> case,
>> >>> which
>> >>> > would a better one to use?
>> >>> >
>> >>> > I cannot use a normal link as it would reload the screen and the
>> >>> > modalwindow would vanish.
>> >>> >
>> >>> > Please advise. Thanks for your time.
>> >>> >
>> >>> > Thanks,
>> >>> > J
>> >>> >
>> >>> > On Tue, Jun 9, 2009 at 4:34 PM, Igor Vaynberg <
>> [email protected]
>> >>> >wrote:
>> >>> >
>> >>> >> ajaxlink does not submit the form so no validation will happen and
>> it
>> >>> >> doesnt have an onsubmit method. you are mixing up ajaxlink,
>> >>> >> ajaxsubmitlink, and ajaxbutton.
>> >>> >>
>> >>> >> -igor
>> >>> >>
>> >>> >> On Tue, Jun 9, 2009 at 2:30 AM, Jade<[email protected]> wrote:
>> >>> >> > Hi all,
>> >>> >> >
>> >>> >> > I am having a issue with AjaxLink and thought would get help
>> from
>> >>> you.
>> >>> >> >
>> >>> >> > I have a modal window which has a form with two ajax links, few
>> check
>> >>> >> boxes
>> >>> >> > and a AjaxButton.The check boxes are bound inside a list view.
>> >>> >> >
>> >>> >> > Now, out of the two ajax links - one ajax link is for checking
>> all
>> >>> the
>> >>> >> > check boxes and other is for unchecking all of them.
>> >>> >> >
>> >>> >> > I also have validation added to the form to check at least one
>> of the
>> >>> >> check
>> >>> >> > boxes is checked on submit. But the strange thing that happens is
>> -
>> >>> >> whenever
>> >>> >> > the ajaxlink for none is clicked, the ajaxbutton's onSubmit is
>> not at
>> >>> >> all
>> >>> >> > called. And the validation does not happen in the form, which I
>> came
>> >>> to
>> >>> >> know
>> >>> >> > by eclipse debug sequence.
>> >>> >> >
>> >>> >> > Am I doing something wrong here, I am still very much confused
>> why
>> >>> its
>> >>> >> not
>> >>> >> > called.
>> >>> >> >
>> >>> >> > Also, any advices for better implementation of the functionality
>> would
>> >>> be
>> >>> >> of
>> >>> >> > great help.
>> >>> >> >
>> >>> >> > Thanks,
>> >>> >> > Jade
>> >>> >> >
>> >>> >>
>> >>> >>
>> ---------------------------------------------------------------------
>> >>> >> 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]
>> >>>
>> >>>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>