I know this isn't really a jsf problem but maybe someone else has hit this problem and can help?
We have a system where I need to use javascript to do some validation and then possible prompt the user for some information in an onClick event. This can include the name or some random string that the user entered. The name can contain a single quote (ex. O'Brian) or the strings can contain a single/double quote (ex. Don't contact me)
The issue I am running into is that I cannot strip out the single or double quotes at the database level and have to do it in the front end.
Here is the call, followed by the problem:
<a4j:commandLink action="#{pagingSearchBean.addRecipient}"
id="addRecipientLink"
reRender="_showError,rightColumn,failedRap,rapDialog,commonPageTypeBox, maxCharsBox"
eventsQueue="recipientListQueue" requestDelay="10"
onclick=" if( !checkExceptionOnAdd('#{results.activeException.activeFlag}', '#{results.name}', '#{results.activeException.exceptionType}', '#{results.activeException.exceptionInfo}', '#{results.finalCoverage.name}', '#{results.finalCoverage.activeException.exceptionType}', '#{results.finalCoverage.activeException.exceptionInfo}')) {
return false;
}
{code}
The issue is that when I pass these to the javascript function checkExceptionOnAdd and there is a quote in one of the fields, it breaks. I've tried doing Prototype gsub() and javascript replace() and because there is a quote in the string it breaks. Has anyone run into this problem in your JSF app?
The actual call to the function at runtime is something to the effect of checkExceptionOnAdd('F','O'Brian <-- the extra quote in O'Brian breaks the call.