CommandLink renderer do not escape \ characters in generated javascript -----------------------------------------------------------------------
Key: MYFACES-2726 URL: https://issues.apache.org/jira/browse/MYFACES-2726 Project: MyFaces Core Issue Type: Bug Components: General Affects Versions: 1.1.7 Environment: Websphere 7 Reporter: Romain Seguy The link is declared by {code} <h:commandLink id="select" action="#{locationListManagedBean.associate}" styleClass="detailLink" title="#{messages['associate']}"> <t:div /> <f:param name="locationSelectedBean" value="#{location.bean}" /> </h:commandLink> {code} The associated generated HTML code is valid but the \ character is not escaped : {code} <a href="#" onclick="return oamSubmitForm('xnetForm','xnetForm:_idJsp30:tablelocation:2:select',null,[['locationSelectedBean','com.michelin.wrh.bo.LocationBean CAR/T1[]5%Car\m+es|']]);" id="xnetForm:_idJsp30:tablelocation:2:select" title="Associer" class="detailLink"> <div></div> </a> {code} The associated javascript method does not manage special characters ! The locationSelectedBean param retrieved from context.getExternalContext().getRequestParameterMap().get("locationSelectedBean"); has lost the "\" character We can fix the issue by overwritting the {{org.apache.myfaces.shared_impl.renderkit.html.HtmlLinkRendererBase}} class and modify the following method : {code} private StringBuffer addChildParameters(UIComponent component, UIComponent nestingForm) { StringBuffer params = new StringBuffer(); params.append("["); Iterator it = getChildren(component).iterator(); do { if(!it.hasNext()) break; UIComponent child = (UIComponent)it.next(); if(child instanceof UIParameter) { String name = ((UIParameter)child).getName(); if(name == null) throw new IllegalArgumentException("Unnamed parameter value not allowed within command link."); addHiddenCommandParameter(FacesContext.getCurrentInstance(), nestingForm, name); Object value = ((UIParameter)child).getValue(); //FIX // We need to escape \ characters in generated javascript code // String strParamValue = value == null ? "" : value.toString(); String strParamValue = value == null ? "" : value.toString().replace("\\", "\\\\"); //ENDFIX if(params.length() > 1) params.append(","); params.append("['"); params.append(name); params.append("','"); params.append(strParamValue); params.append("']"); } } while(true); params.append("]"); return params; } {code} -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.