Reputation: 85
The field values of my HTML page are not sent to my managed bean. By invoking the action, the values are null
. My html code is:
<form jsf:id="form">
<fieldset>
<label> <span
class="block input-icon input-icon-right"> <input
type="text" class="span12" placeholder="Usuário"
jsf:id="usr" jsf:value="#{loginBean.user}" />
<i class="icon-user"></i>
</span>
</label> <label> <span
class="block input-icon input-icon-right"> <input
type="password" class="span12" placeholder="Senha"
jsf:id="pwd" jsf:value="#{loginBean.password}" />
<i class="icon-lock"></i>
</span>
</label>
<div class="space"></div>
<div class="clearfix">
<button jsf:action="#{loginBean.doLogin()}" jsf:id="btn"
class="width-35 pull-right btn btn-small btn-primary">
<i class="icon-key"></i> Login
</button>
</div>
<div class="space-4"></div>
</fieldset>
</form>
I was put and syout
on my LoginBean.doAction
method and it print null
for user
and password
attributes.
Am I doing something wrong?
Upvotes: 1
Views: 1000
Reputation: 1108557
As per the comments, you declared the XML namespace xmlns:jsf
on URI http://java.sun.com/jsf
, based on the old java.sun.com
host.
This has a bug in older Mojarra versions. New JSF 2.2 specific features such as <f:viewAction>
and "HTML5 friendly markup" weren't initially available on XML namespace with the old java.sun.com
host in the URI, but only on xmlns.jcp.org
host. This was fixed in Mojarra 2.2.1-2.2.2.
As you're on Java EE 7, you should really abandon java.sun.com
host in XML namespace URIs and use xmlns.jcp.org
instead.
<html ... xmlns:jsf="http://xmlns.jcp.org/jsf">
That said, that this bug occurs also indicates that you're using a rather old Mojarra version. It's wise to upgrade it. It's currently already at 2.2.9 (which in turn has the awkward bug that line numbers aren't included in class files, so you couldn't step through the source in IDE's debugger, you'd better pick 2.2.8 if this is mandatory; this will be fixed in 2.1.10).
Upvotes: 1