1

I am facing very strange issue using JSF2 (apache MyFaces 2 and Rich Faces 4.3) Below is the xhtml code.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"> 

    <h:head>
    </h:head>

    <h:body>
            <h:form id="form">      
                <a4j:commandButton immediate="true" value="Check" action="#{bean.someAction}"/>                 
            </h:form>
    </h:body>   


</html>

When xhtml code is debugged using firebug and any of the rich faces tag is used , i am getting below error in debugger as :

SyntaxError: syntax error @ http://localhost:8480/webAppName/javax.faces.resource/jsf.js.faces?ln=javax.faces&stage=Development:1 

When <a4j:commandButton> tag is removed and plain jsf tag <h:commandButton> is used error is not thrown. Also when <a4j:commandButton> is clicked , ReferenceError: RichFaces is not defined error is thrown.

Attaching the generated html code : 1)h:commandButton with f:ajax inside - (it gives ReferenceError: jsf is not defined error when button is clicked)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >

<html xmlns="http://www.w3.org/1999/xhtml">

<head><link rel="stylesheet" media="screen" type="text/css" href="/contextRoot/rfRes/skinning.ecss.faces" />

<script type="text/javascript" src="/contextRoot/javax.faces.resource/jsf.js.faces?ln=javax.faces&amp;stage=Development"><!--

//--></script>

</head>

<body>

<form id="testForm" name="testForm" method="post" action="/contextRoot/pages/testPage.faces" enctype="application/x-www-form-urlencoded">

<input id="testForm:j_id_6" name="testForm:j_id_6" type="submit" value="Test" onclick="jsf.util.chain(document.getElementById('testForm:j_id_6'), event,'jsf.ajax.request(\'testForm:j_id_6\',event,{execute:\'testForm \',render:\'testForm \',\'javax.faces.behavior.event\':\'action\'})'); return false;"/>
<input type="hidden" name="testForm_SUBMIT" value="1" />
<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="/6XulvXlIjDBkLb43C7I4+TCqUyuTMbk4Xz6pE7XonVsuqaL" />
</form>
<div id="javax_faces_developmentstage_messages"></div>

</body> 


</html>

2) a4j:commandButton - (it gives ReferenceError: RichFaces is not defined error when button is clicked)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >

<html xmlns="http://www.w3.org/1999/xhtml">

<head><link rel="stylesheet" media="screen" type="text/css" href="/contextRoot/rfRes/skinning.ecss.faces" />
<script type="text/javascript" src="/contextRoot/javax.faces.resource/jsf.js.faces?ln=javax.faces&amp;stage=Development"><!--

//--></script><script type="text/javascript" src="/contextRoot/javax.faces.resource/jquery.js.faces"><!--

//--></script><script type="text/javascript" src="/contextRoot/javax.faces.resource/richfaces.js.faces"><!--

//--></script><script type="text/javascript" src="/contextRoot/javax.faces.resource/richfaces-queue.js.faces"><!--

//--></script></head>

<body><form id="testForm" name="testForm" method="post" action="/contextRoot/pages/testPage.faces" enctype="application/x-www-form-urlencoded">
<input id="testForm:j_id_6" name="testForm:j_id_6" onclick="RichFaces.ajax(&quot;testForm:j_id_6&quot;,event,{&quot;incId&quot;:&quot;1&quot;} );return false;" value="Test" type="submit" />
<input type="hidden" name="testForm_SUBMIT" value="1" />
<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="DiY2dVKs1zXBkLb43C7I439MwZ/wfbTcBNpwPlLjsh6prC/c" />
</form>

<div id="javax_faces_developmentstage_messages"></div></body>   


</html>
Vasil Lukach
  • 3,658
  • 3
  • 31
  • 40
Atul
  • 1,560
  • 5
  • 30
  • 75
  • Have a look at this SO question: [http://stackoverflow.com/questions/5758434/richfaces4-dont-render-the-components][1] [1]: http://stackoverflow.com/questions/5758434/richfaces4-dont-render-the-components – geert3 Dec 24 '13 at 15:25
  • 1
    Does the button work when a4j:commandButton is replaced by h:commandButton with f:ajax inside? Please post also generated html code of the page (View Page Source in your browser). – Andrey Dec 26 '13 at 11:04
  • @Andrey:Thanks for your help.Added the generated html code for both cases - a4j:commandButton and h:commandButton with f:ajax inside – Atul Jan 02 '14 at 09:33
  • 1
    It looks like jsf.js fails to initialize. Open this file in browser and check what could cause that syntax error executing first line of the file: http://localhost:8480/webAppName/javax.faces.resource/jsf.js.faces?ln=javax.faces&stage=Development – Andrey Jan 02 '14 at 11:20
  • @Andrey:My web.xml contains a lot of filters. When I removed all the filters from the path , both ReferenceErrors are not observed.I am now debugging what is the thing that filters adds to cause this issue. – Atul Jan 02 '14 at 14:43
  • Did you ever get trough this? Im stuck in it :( – jmlv21104 Jan 11 '14 at 17:56

0 Answers0