Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

stripping out quotes from backing bean in onClick event

843844Feb 8 2008 — edited Feb 8 2008
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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 7 2008
Added on Feb 8 2008
3 comments
119 views