1

I have my string variable I want to display

final String wrongPw = "Wrong Password";

My AJAX yes button:

AjaxButton yesButton = new AjaxButton("yesButton", yesNoForm) {
        private static final long serialVersionUID = -3827487963204274386L;
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            if (target != null && password.equals(getPw())) {
                answer.setAnswer(true);
                modalWindow.close(target);
            }else if(target != null && !password.equals(getPw())){
                answer.setAnswer(false);
                wrongPW.setVisible(true);
            }
        }
    };

Further down:

wrongPW.setVisible(false);
add(wrongPW);

When I hit the yes button I must refresh the page for the wrongPW to display.

How can this be done dynamically?

notAChance
  • 1,360
  • 4
  • 15
  • 47

1 Answers1

7

You have to add the component you want to update to the target like this:

target.add(wrongPW);

Be sure to set the markup placeholder tag on initialization of the component you want to dynamically change the visibility of, else Wicket won't find it.

wrongPW.setOutputMarkupPlaceholderTag(true);

The reasons for this are explained here: https://stackoverflow.com/a/9671796/2795423

Community
  • 1
  • 1
thg
  • 1,209
  • 1
  • 14
  • 26