I am aware of this post and I double checked all the possibilities there.
I'm using JSF 2.0 with Mojarra implementation on Glassfish 3.
I'm trying to use two simple <h:commandLink>
tags to change the application language.
This is the .xhtml
page:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>
<h:outputText value = "#{appMessage['page.welcome']}" />
</title>
<f:metadata>
<f:event type = "preRenderView" listener = "#{sessionController.changeLanguage}" />
</f:metadata>
</h:head>
<h:body>
<h1><h:outputText value = "#{appMessage['text.slide.welcome']}" /></h1>
<h:form id = "fm-language">
<h:commandLink action = "#{sessionController.changeLanguage('en')}" value = "#{appMessage['link.english']}" />
<h:commandLink action = "#{sessionController.changeLanguage('de')}" value = "#{appMessage['link.german']}" />
</h:form>
</h:body>
This is the HTML code:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>The Maze Project</title>
</head>
<body>
<h1>Welcome</h1>
<form id="fm-language" name="fm-language" method="post" action="/maze/welcome.xhtml" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="fm-language" value="fm-language" />
<script type="text/javascript" src="/maze/javax.faces.resource/jsf.js.xhtml?ln=javax.faces">
</script>
<a href="#" onclick="mojarra.jsfcljs(document.getElementById('fm-language'),{'fm-language:j_idt13':'fm-language:j_idt13'},'');return false">English</a>
<a href="#" onclick="mojarra.jsfcljs(document.getElementById('fm-language'),{'fm-language:j_idt15':'fm-language:j_idt15'},'');return false">Deutsch</a>
<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="8038443616162706480:-1387069664590476821" autocomplete="off" />
</form>
</body>
When pressing a commandLink nothing at all happens. There is no request sended to the server and this following Java Script error is thrown:
mojarra is not defined
The bean methods are correctly called and work fine in the rest of the appliction.
<h:form>
inside the very same<h:body>
? If not, please post a fullworthy SSCCE. – Simonasimonds#{languageController}
bean annotated/registered? – Simonasimondsaction="#{nonexistent}": Identity 'nonexistent' was null and was unable to invoke
if the method specified in the EL doesn't exist. Weirdly, this two links doesn't throw any kind of error if tested with a non existent action. – Coryimport javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
– CorycommandLink
works just fine – Coryonclick
function which must be fully functional and the JS debugger/console should not have shown any errors. Try if necessary in different browsers. – SimonasimondsMethodExpression
is a valid action. Even more, since EL 2.2 you can pass parameters (which will work for JSF 1.2 as well). Returningvoid
is treated as returningnull
. – Simonasimondsmojarra is not defined
. I'm using<h:head>
tags – Cory<div>
s so that you get the smallest possible Facelets source which still reproduces the problem and then edit your question to show it, along with the generated HTML output which you can see by rightclick and View Source after opening it in webbrowser. – Simonasimonds