also when you call error(), you call it on your component, not on the form.
you should call it like this :
private boolean activeSessionExist(Form<Void> form){
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();
form.error(error);
return true;
}
return false;
}
François
> Le 29 oct. 2018 à 16:57, SeldonCrisis <[email protected]> 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: [email protected]
> For additional commands, e-mail: [email protected]
>