0
我在websphere 7上遇到了JSF 1.2的問題。 我試圖用JSF實現導航。 我也在使用RichFaces。JSF 1.2 h:commandLink不工作,mojarra沒有定義
在瀏覽器的控制檯,我得到這個錯誤:Uncaught ReferenceError: mojarra is not defined
我看到其他解決這個問題,他們與加入<h:head>
解決了這個問題,但這並沒有爲我工作。
謝謝你幫
我navigation.xhtml
<?xml version="1.0" ?>
<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:ui="http://java.sun.com/jsf/facelets">
<body>
<ui:composition>
<h:form>
<!-- Navigation -->
<div id="navigation" class="navigation">
<div class="level0">
<h:commandLink action="#{navigation.toHome}" value="#{messages.elsi_dg_navigation_home}" />
</div>
<div class="level0">
<h:commandLink action="#{navigation.toHistory}" value="#{messages.elsi_dg_navigation_history}" />
</div>
</div>
</h:form>
</ui:composition></body></html>
的NavigationBean.java
@Controller("navigation")
@Scope("session")
@ManagedBean
public class NavigationBean {
private String lastSite = "home";
public String toHome() {
return this.processOutcome("home");
}
public String toHistory() {
return this.processOutcome("history");
}
public String toCurrentPage() {
return this.lastSite;
}
private String processOutcome(String outcome) {
this.lastSite = outcome;
return outcome;
}
}
HTML輸出:
<div id="navigation" class="navigation">
<form id="j_id19" name="j_id19" method="post" action="/elsi-dg/xhtml/home.xhtml" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_id19" value="j_id19">
<!-- Navigation -->
<div id="navigation" class="navigation">
<div class="level0"><a href="#" onclick="mojarra.jsfcljs(document.getElementById('j_id19'),{'j_id19:j_id21':'j_id19:j_id21'},'');return false">Home</a></div>
<div class="level0"><a href="#" onclick="mojarra.jsfcljs(document.getElementById('j_id19'),{'j_id19:j_id23':'j_id19:j_id23'},'');return false">History</a></div>
</div><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="3428583661652779493:-8865896015881316410" autocomplete="off">
</form>
</div>
UPDATE
<a4j:commandLink>
作品沒有問題..
感謝您的回答。是的,我正在使用一個模板文件,我忘了在我的問題中進行指導。我目前使用a4j作爲解決方法,這工作沒有問題 – 0riginal 2014-11-04 21:10:18