works great for me.

@Override
protected void onInitialize() {
    super.onInitialize();

    Form<Void> form = new Form<Void>("form");
    add(form);

    FeedbackPanel feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);
    form.add(feedback);

    form.add(new AjaxButton("AjaxButton") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit(AjaxRequestTarget target) {
            if (activeSessionExist()) {
                target.add(feedback);
                log.debug("Does the form have error:" + getForm().hasError());
            }
        }

    });
}

private boolean activeSessionExist() {
    error("You have an active OCP");
    return true;
}



What is printed at the log.debug("Does the form have error:" + 
form.hasError());  at the first click ?


François



> Le 29 oct. 2018 à 16:57, SeldonCrisis <nmbara...@gmail.com> a écrit :
> 
> Oh strange, probably because I put the code in < raw > tags. Thanks for the
> heads up.
> 
> *OK, here's the button code:*
> radioWmc1Step2.add(new AjaxButton("btnNewBegin") { 
>       private static final long serialVersionUID = 1L;
>       @Override
>       public void onSubmit(AjaxRequestTarget target, Form<?> form) {
>               if (activeSessionExist()){
>                       target.add(feedback);
>                       log.debug("Does the form have error:" + 
> form.hasError());
>                       return;
>               }
>               logUserAction(ocpAuthorization.getEmailAddress(), "602", 
> "CP10", "OCP",
> ocpAuthorization.getSecretTrackingNumber());
>               onPageSubmit(target);
>       } 
>                       
>       @Override 
>       protected void onError(AjaxRequestTarget target, Form<?> form) {
>               onSaveFormBtnError(target);
>         target.add(radioWmc1Step2);
>         target.appendJavaScript("trackingNumberMask();");
>       };
> }
> 
> *And the code where I add to feedback panel*
> private boolean activeSessionExist(){
>       OCPSession session = (OCPSession)WebSession.get();
>       
>       if(session.getTrackingId() != null){
>               log.error("Active session found. Cannot have more than one OCP 
> tracking
> number open at a time.");
>               String error = "You have an active OCP Tracking Number open 
> already. "
>                               + "This application only allows one active OCP 
> Tracking Number. "
>                               + "Please use the \"Exit\" button to close that 
> Tracking Number before
> starting a new " + getTypeCode();
>                                                       
>               error(error);
>               return true;
>       }
>       return false;
> }
> 
> Thanks again
> 
> --
> Sent from: 
> http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 

Reply via email to