简体   繁体   中英

How can I reenable autocomplete support for just 1 site in my whole struts project?

since I'm trying to solve this problem for some days, I thought about giving you guys a chance. The situation:

We're running a SAP Shop with Java Server Pages and Struts in background. We had to disable the HTML Header setable Cache with:

response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");

Now what I want to do seemed to us as a simple task but turned out to be more scientific than we expected.

We want to turn auto-complete for IE back on just for the login page. What I and my colleague tried were simple approaches like resetting the header values to various "should be caching" values like 'public' with expirens tomorrow or sth. Neither did anything give us that auto-complete boxes in IE6 and up.

So does anyone know a method for JUST ONE PAGE in a Struts system to turn the caching & as we think the autocomplete back on?

I don't think autocomplete has anything to do with the caching response headers. autocomplete is on by default, and can be disabled on a specific form field using autocomplete="off" . If you have such an attribute in your login form fields, then just remove it.

See How do you disable browser Autocomplete on web form field / input tag?

Okay by now I found the answer myself. It seems easier when you talk about it, does it?

So the problem was, that we used a javascript function to submit our login form site. But that's not how you should do it (say's microsoft). I heard a techcast some minutes ago about the internet explorer relying on suspicious buttons for implemented browser functionality.

Having heard that the answer was kind of clear in my head. I head to submit over a button. Since we (HAVE TO!) use Javascript to submit, cause the button is only a styled div, I had to call a button click to show IE that we do a 'official' postback.

That's the code:

function submitLoginForm()
{
    var hiddenSubmitBtn = document.getElementById("hiddenSubmitButton");
    if(hiddenSubmitBtn.click) {
        hiddenSubmitBtn.click();
    } else {
        document.loginform.submit();
    }
    return false;
}

It now works fine.

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