Hi,

On Thu, Jan 26, 2017 at 6:56 PM, SeldonCrisis <[email protected]> wrote:

> I just wanted to update this in case anyone else references it in the
> future.
> While the *Check* fix was a solution to the *"precondition check"* error, I
> was still unable to execute the ajax instructions inside the overridden
> *"protected void onUpdate(AjaxRequestTarget target){}"* method.
>

When you use a CheckGroup you have to
use org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior to
receive Ajax notifications when the checkboxes are toggled.


>
> For this reason, I decided to instead use *AjaxCheckBox*, alternatively
> implementing all the logic in both overridden *"onUpdate"* methods. I used
> an array of Boolean values to represent the values of the Model Objects
> since I wouldn't be able to refer to the Model Object of the second
> AjaxCheckBox in the onUpdate of the first as it has yet to be instantiated.
>
> *Here's my Java code:*
> final Button fileClaimButton;
> final CheckBox cb1, cb2;
> final boolean[] bArray = {false, false};
>
> fileClaimButton = new AjaxButton("fileClaimButton"){
>         private static final long serialVersionUID = 1L;
>         @Override
>         protected void onSubmit(AjaxRequestTarget target, Form<?> form){
>                 System.out.print("File Claim Executed");
>         }
> };
> fileClaimButton.setEnabled(false);
> fileClaimButton.setOutputMarkupId(true);
> fileClaimButton.setOutputMarkupPlaceholderTag(true);
>
> cb1 = new AjaxCheckBox("cg1-cb1", new Model<Boolean>(false)){
>         @Override
>         protected void onUpdate(AjaxRequestTarget target) {
>                 bArray[0] = getModelObject();
>                 if (bArray[0] == true && bArray[1] == true)
>                         fileClaimButton.setEnabled(true);
>                 else
>                         fileClaimButton.setEnabled(false);
>
>                 target.add(fileClaimButton);
>         }};
>
> cb2 = new AjaxCheckBox("cg1-cb2", new Model<Boolean>(false)){
>         @Override
>         protected void onUpdate(AjaxRequestTarget target) {
>                 bArray[1] = getModelObject();
>                 if (bArray[0] == true &&  bArray[1] == true)
>                         fileClaimButton.setEnabled(true);
>                 else
>                         fileClaimButton.setEnabled(false);
>
>                 target.add(fileClaimButton);
>         }};
>
> --
> View this message in context: http://apache-wicket.1842946.
> n4.nabble.com/Ajax-request-stopped-because-of-precondition-check-on-
> CheckGroup-tp4676865p4676880.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to