2012-02-22 120 views
1

我最近將Eclipse Indigo項目從JSF 1.2切換到JSF 2.1(使用MyFaces)。使用Tomcat 7將MyFaces 1.2遷移到2.1後,鏈接突然停止響應

奇怪的事情發生了:我成立了一個項目,它對於一些短期 時間工作正常,然後突然(也許以後我做「清潔」)停止工作在某種意義上 單擊命令鏈接不會產生任何動作,支持bean的方法不是調用 ,只是沒有任何反應。我試圖做的項目「乾淨」和Eclipse重新啓動,甚至系統重新啓動,但它沒有幫助。唯一幫助的是我創建了一個全新的工作區和新項目的 - 但是同樣的事情發生了: 這也只能在短時間內工作,並突然停止工作在相同的方式 - 命令鏈接只是不響應點擊,並且我無法調試Java代碼至少可以本地化問題。

什麼可能是這種奇怪的行爲的原因?

在此先感謝。


更新:這是JavaScript錯誤報告:

myfaces is not defined 
onclick()onclick (line 2) 
event = click clientX=840, clientY=252 

return myfaces.oam.submitForm("j_id_6", "j_id_6:LOGIN"); 

function onclick(event) { 
return myfaces.oam.submitForm("j_id_6", "j_id_6:LOGIN"); 
} 

原來這裏是XHTML文件:

<?xml version="1.0" encoding="ISO-8859-1" ?> 
<!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:f="http://java.sun.com/jsf/core" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:t="http://myfaces.apache.org/tomahawk"> 
<h:head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> 
<title>Login</title>  
</h:head> 
<body style="background-color:#3d3d3d;" text="#000000" link="#cc0000" alink="#666666" vlink="#cc0000" onload="document.forms[0].USERNAME.focus();"> 
<f:view> 

<h:form target="_top"> 

    <table border="0" align="center" width="810" style="border: 2px black solid; background-image:url(images/header.jpg); margin:auto;" cellspacing="0" cellpadding="0"> 
     <tr> 

     </tr> 
    </table> 
    <table align="center" width="810" style="border: 2px black solid; background-color:#ffffff;" cellspacing="0" cellpadding="0"> 
     <tr> 
      <td width="100%" height="10" colspan="3" align="center" valign="middle"> 

      </td> 
     </tr> 
     <tr> 
      <td colspan="3"> 
      <table width="778" align="center" border="0" cellspacing="0" cellpadding="0"> 
       <tr> 
        <td valign="top" width="778"><h1>Login</h1> 
         <table cellpadding="0" cellspacing="0" border="0"> 
           <tr>         
           <td height="20"><font class="text">User Name: </font></td> 
           <td height="20"><font class="text"><t:inputText forceId="true" id="USERNAME" maxlength="50" value="#{LoginBean.username}" size="26" /></font></td> 
          </tr> 
          <tr> 
           <td height="20"><font class="text">Password: </font></td> 
           <td height="20"><font class="text"><h:inputSecret maxlength="30" value="#{LoginBean.password}" size="26" /></font></td> 
          </tr> 
          <tr> 
           <td height="20" colspan="2" align="right"><h:commandLink id="LOGIN" action="#{LoginBean.doLogin}"><h:graphicImage style="border: none" value="images/login.png" /></h:commandLink></td> 
          </tr> 
         </table> 
        </td> 
       </tr> 
      </table> 
      </td> 
     </tr> 
    </table> 

</h:form>  

</f:view> 
</body> 
</html> 

這裏是生成的HTML:

<?xml version="1.0" encoding="ISO-8859-1" ?> 
<!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> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> 
<title>Login</title></head> 
<body style="background-color:#3d3d3d;" text="#000000" link="#cc0000" alink="#666666" vlink="#cc0000" onload="document.forms[0].USERNAME.focus();"><form id="j_id2030916047_790d5181" name="j_id2030916047_790d5181" method="post" action="/EWC/login.faces" enctype="application/x-www-form-urlencoded" target="_top"> 

    <table border="0" align="center" width="810" style="border: 2px black solid; background-image:url(images/header.jpg); margin:auto;" cellspacing="0" cellpadding="0"> 
     <tr> 

     </tr> 
    </table> 

    <table align="center" width="810" style="border: 2px black solid; background-color:#ffffff;" cellspacing="0" cellpadding="0"> 
     <tr> 
      <td width="100%" height="10" colspan="3" align="center" valign="middle"> 

      </td> 
     </tr> 
     <tr> 
      <td colspan="3"> 
      <table width="778" align="center" border="0" cellspacing="0" cellpadding="0"> 
       <tr> 

        <td valign="top" width="778"><h1>Login</h1> 
         <table cellpadding="0" cellspacing="0" border="0"> 
          <tr>          
           <td height="20"><font class="text">User Name: </font></td> 
           <td height="20"><font class="text"><input id="USERNAME" name="USERNAME" type="text" value="" maxlength="50" size="26" /></font></td> 
          </tr> 
          <tr> 
           <td height="20"><font class="text">Password: </font></td> 

           <td height="20"><font class="text"><input type="password" name="j_id2030916047_790d5181:j_id2030916047_790d51ba" maxlength="30" size="26" /></font></td> 
          </tr> 
          <tr> 
           <td height="20" colspan="2" align="right"><script type="text/javascript" src="/EWC/javax.faces.resource/oamSubmit.js.faces?ln=org.apache.myfaces"></script><a href="#" onclick="return myfaces.oam.submitForm('j_id2030916047_790d5181','j_id2030916047_790d5181:LOGIN');" id="j_id2030916047_790d5181:LOGIN"><img src="images/login.png" style="border: none" /></a></td> 
          </tr> 
         </table> 
        </td> 
       </tr> 

      </table> 
      </td> 
     </tr> 
    </table><input type="hidden" name="j_id2030916047_790d5181_SUBMIT" value="1" /><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="5s3ZqoVcUIwarcQb6pVzFIPhMJIzbVHnjMrXdtgA1Nten7grU/y0hMGbHtFvIExuKQOwB3IGzcSDeuPfijYMcnK23q/2N1mduMdr6RskySGELSaI2w93nL9b8NE=" /></form> 
</body> 
</html> 
+0

難道你沒有任何日誌? – roel 2012-02-22 14:55:44

+0

你喜歡哪個日誌?我會盡力提供。 – Danijel 2012-02-22 15:01:04

+0

你沒有看到在eclipse或tomcat日誌中的控制檯窗口中的任何日誌?什麼是你的bean請求範圍(session,view,...)。也許你可以發佈一些代碼? – roel 2012-02-22 15:12:45

回答

0
<context-param> 
    <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>  
    <param-value>true</param-value> 
</context-param> 

將它添加到您的Web.xml 一切都將開始。