简体   繁体   中英

How to call ajax respond() method to server from Safari keychain autofill?

We have Java-EE application based on Wicket.

Problem is, that when you want to autofill username and password with keychain prompt from Safari, the server could not register the username because Safari with keychain doesn't send Ajax callback, which server needs to catch with ajax method:

/**
     * @param target
     *            The AJAX target
     */
    protected abstract void respond(AjaxRequestTarget target);  

What should the html code of the textfield or javascript of this component look like to send an ajax callback when filling out from the apple keychain?

Thanks for any answer.

I guess you have an HTML Form with text input field for the username, a password field for the password and a (ajax?!) button to submit the form.

You need to trigger the click listener of the button as soon as the username and password fields are filled by Safari autofill feature.

If Safari fires an event after filling those then the JS code will be something like:

$('#passwordId').on('change', function(evt) {
   if ($('#usernameId').value() && $('#passwordId').value()) {
       $('#buttonId').click();
   }
});

Above I assume that Safari fires change event after auto-filling the password field. Then if both the username and password fields are non-empty I click the button. This will lead to the normal behavior of this button, ie it will make an (Ajax) call to the server and Wicket will do the rest.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM