Good morning everyone,
It's early Monday morning and I'm having trouble understanding why this particular line works in Internet Explorer but not in Firefox.
<a class="button" href="#" onclick="setMaintenanceMode(false);">disable</a>
When you hover over the button in both IE and FF, the URL displayed is...
http://localhost:8080/mainapp/secure/gotoDevice.action?hardwareId=1&storeCode=2571#
Upon clicking the button, the following method is invoked...
function setMaintenanceMode(enabled) {
var url = '<s:url action="secure/setMaintenanceMode"/>' + '&ModeEnabled=' + enabled;
document.location.href = url;
}
The URL that the document is directed to is the same in both browsers...
/mainapp/secure/gotoDevice.action?hardwareId=1&storeCode=2571&ModeEnabled=false
The issue here is that in IE, the 'setSetCode()' method in the struts action is executed, but not in FF! Removing the hash mark in the 'ahref' tag makes FF work, but it breaks IE (href="#").
I've attempted to change '&ModeEnabled=' to '&ModeEnabled=', but to no avail. I've searched on Google and the struts forum, but haven't found a solution.
I'm considering replacing all 'ahref' with Dojo buttons to see if that resolves the issue, but before I do, I'd like to understand why.
My suspicion is that 'ahref' might not be the correct element to use, but I'm unsure why.
If anyone can shed some light on this issue, I would greatly appreciate it.
Thank you, Jeff Porter
EDIT: Adding 'return false' seems to be part of the solution. The problem appears to be the URL...
/mainApp/secure/setMaintenanceMode.action?hardwareId=5&storeCode=2571&ModeEnabled=true
contains '&' internally. If I visit this URL as is, it works in IE but not in FF.
If I change both instances to '&', it works in both IE and FF.
If I change both instances to '&', it still works in IE but not in FF.
Any thoughts?
Note:
It seems that struts 2.0.9 does not support the 'escapeAmp' property on the '<s:url' tag:
By default, request parameters are separated using escaped ampersands (i.e., '&'). This is necessary for XHTML compliance. However, when using the URL generated by this tag with the '<s:property>' tag, the 'escapeAmp' attribute should be used to disable ampersand escaping.
Solution: Add 'return false' to the 'onclick' and upgrade to a newer version of struts + set the 'escapeAmp' parameter. Alternatively, use 'url = url.replace("&", "&");'.