2011-08-22 2 views
4
JSF facelet 페이지 (.xhtml)의

이 javascript 코드가 있습니다.JSF facelet 페이지가 '&'문자가있는 JavaScript 문자열이 아닙니다.

<script type="text/javascript"> 
     function navigateToDetail() { 
      var id = document.getElementById("idElemento").value; 
      alert(id); 
      var isPratica = document.getElementById("isPratica").value; 
      alert(isPratica); 
      var box = "#{boxCtrl.idBox}"; 
      alert(box);    
      if (isPratica==true) 
       window.location = "DettaglioRichiesta.xhtml?id=" + id + "&box=" + box; 
      else 
       window.location = "../Richieste/DettaglioRichiesta.xhtml?id=" + id + "&box=" + box; 

     } 
    </script> 

jfs 엔진이 "& box"가 bindign에 상대적이라고 생각하여 작동하지 않습니다.

Error Parsing /Box/ListaRichieste.xhtml: Error Traced[line: 20] The reference to entity "box" must end with the ';' delimiter 

이 동작을 피할 수 있습니까?

답변

12

Facelets는 XML 기반의 뷰 기술입니다. &XML special character입니다. &nbsp;, &#160; 등과 같은 XML 엔티티의 시작으로 해석됩니다. 따라서 끝 문자 ;을 찾고 있지만 아무 것도 찾지 못해이 오류가 발생합니다.

문자 그대로 &을 XML 문서 내에 나타내려면 & 대신 &amp;을 사용해야합니다.

window.location = "DettaglioRichiesta.xhtml?id=" + id + "&amp;box=" + box; 

당신은 또한 당신이 <script src>가 포함 자신의 .js 파일에 JS 코드는 그래서 당신이 JS 코드에서 XML 특수 문자 바이올린 할 필요가 없다는 것을 넣을 수 있습니다.

<script type="text/javascript" src="your.js"></script> 
+0

감사합니다. 외부 js 파일에 대해 알고 있었지만 "페이지에서"해결하는 것이 궁금했습니다. 솔루션을 주셔서 감사합니다 – themarcuz

+0

당신을 진심으로 환영합니다. – BalusC

관련 문제