[ 
https://issues.apache.org/jira/browse/MYFACES-2726?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Leonardo Uribe resolved MYFACES-2726.
-------------------------------------

         Assignee: Leonardo Uribe
    Fix Version/s: 1.1.8-SNAPSHOT
                   1.2.9-SNAPSHOT
                   2.0.1-SNAPSHOT
       Resolution: Fixed

Thanks to Romain Seguy for provide this patch. I committed it on all branches.

> 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
>            Assignee: Leonardo Uribe
>             Fix For: 1.1.8-SNAPSHOT, 1.2.9-SNAPSHOT, 2.0.1-SNAPSHOT
>
>
> The link is declared by
> <h:commandLink id="select" action="#{locationListManagedBean.associate}" 
> styleClass="detailLink" title="#{messages['associate']}">
>               <t:div />
>               <f:param name="locationSelectedBean" value="#{location.bean}" />
> </h:commandLink>
> The associated generated HTML code is valid but the \ character is not 
> escaped :
> <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>
> 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 :
>  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;
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to