Liberino Covelli [
https://community.jboss.org/people/rino.covelli] created the discussion
"@Named not working ??"
To view the discussion, visit:
https://community.jboss.org/message/756545#756545
--------------------------------------------------------------
Dear Friend , I'm trying to save my first object but not working
This is my Bean
package manageUser;
import javax.ejb.EJB;
import javax.enterprise.inject.Alternative;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.NotSupportedException;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import exampleInterface.ManagedPrivato;
import exampleQualifiers.Informal;
@SessionScoped
@Named
public class UserBean {
private String name;
private String surname;
@Inject @Alternative
ManagedPrivato managedPrivato;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public void saveUser(){
managedPrivato.savePrivato(name,surname);
System.out.println("I am saving a user "+name+" "+surname);
//return "sayHello";
}
}
This is my JSF page
<!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:ui="http://java.sun.com/jsf/facelets">
<h:head>
<h:outputStylesheet library="css" name="default.css"/>
<title>Guess Number Facelets Application</title>
</h:head>
<h:body>
<h:form id="registrazione">
<h2>
Registrazione Privato prova db
</h2>
<p>
<h:inputText id="name" title="Insert a Name"
value="#{userBean.name}"></h:inputText><br/><br/>
<h:inputText id="surname" title="Insert a Surname"
value="#{userBean.surname}"></h:inputText><br/><br/>
<h:commandButton id="submit"
action="#{userBean.saveUser}" value="Submit" />
</p>
</h:form>
</h:body>
</html>
but on standard output i printed : I am saving a user null null
I can not bind the JSF page with the properties of User Bean
where am I wrong?
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/756545#756545]
Start a new discussion in Beginner's Corner at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]