Javax.faces.bean.ManagedBean vs. javax.annotation.ManagedBean

I understand that @ManagedBean is realized via javax.faces.bean.ManagedBean and javax.annotation.ManagedBean.
Which of both annotations should I use under which circumstances?

In re: this question I found the discussion in this blog somewhat helpful:
http://weblogs.java.net/blog/cayhorstmann/archive/2009/12/23/javaxfacesbeanmanagedbean-dead-arrival
See especially the section on JSR-316

Similar Messages

  • Javax.faces.model.ManagedBean not found

    Hi all,
    I am extremely new to JSF. Infact this is the first Hello World Application I am building that has Ajax Support. I have written following code from website :
    [http://weblogs.java.net/blog/driscoll/archive/2008/11/a_simple_ajax_j.html]
    import javax.faces.event.ActionEvent;
    import javax.faces.model.ManagedBean;
    import javax.faces.model.SessionScoped;
    @ManagedBean(name = "count")
    @SessionScoped
    public class Count {
         Integer count = 0;
        public Integer getCount() {
            return count++;
        public void reset(ActionEvent ae) {
            count = 0;
    }But Eclipse is not able to find classes for:
    javax.faces.model.ManagedBean
    javax.faces.model.SessionScoped
    Jars added currently:
    jsf-api.jar
    jsf-impl.jar
    jstl.jar
    standard.jar
    servlet-api.jar
    and some commons jar files.
    What jars should i include. I googled for it but could not get relevant information. Sadly, www.findjar.com is down.
    Thanks,
    Vikash Anand.

    Vikash.SunJava wrote:
    Hi icepax,
    Thanks for telling about jstl-1.2.jar for the application. I have added it to my application but same error continues.
    Between can you provide me some pointers for how to do Ajax + JSF? This sample is one sample I got from net that says that it is Ajax + JSF.
    If the tutorial is either some JBoss Seam Specific/wrong maybe I should be looking for some different things. Is Iceface good for Ajax + JSF?
    Thanks,
    Vikash Anand.Sorry, I can't help you with your latest reply as I haven't done Ajax...yet...nor do I have any experience with Icefaces. Anyway, there bound to be other JSF experts in this forum who can help you. If not, there are other JSF forums you can use to ask the same question as this thread - if you need to resolve this issue urgently.

  • Package javax.faces.bean does not exist

    I am new to JSF. I tried to build a jsf application that runs on glassfish 3. I did not use IDEs.
    When I compile it , I encountered the following 4 errors:
    Error 1: package javax.inject.bean does not exist
    Error 2: package javax.faces.bean does not exist
    Error 3: cannot find symbol : class Named
    @Named<name="user">
    Error 4: cannot find symbol: class SessionScoped
    @SessionScoped.
    Please help me fix these errors.
    Thank you in advance.

    You must also be new to Java if you don't know how to deal with these problems. Do you even know what the classpath is?
    I warn you right now: if you don't know the more advanced features of the Java platform (annotations, packages and the classpath, jar library usage, classloaders) you will basically get nowhere developing web applications - especially using a complex framework like JSF.

  • Javax.annotation.processing.Processor not recognized

    Hi,
    I'm currently experimenting with the javax.annotation.processing API. Thus I created a simple Annotation and a related simple processor.
    Another sample program uses the annotation. When compiling this program everything works fine as long as I specify the processor class
    on the command line. But when I try to simply use a javax.annotation.processing.Processor file, the compiler doesn't seem to find the processor.
    What am I doing wrong?
    Here come the details:
    I use Java6 and the sun java compiler javac.
    The annotation and processor class are packed into a JAR file together with the javax...Processor file. The JAR looks like this:
         hello/HelloProcessor.class
         hello/annotations/Hello.class
         META-INF/services/javax.annotation.processing.Processor
         META-INF/MANIFEST.MF     The javax.annotation.processing.Processor file is UTF-8 encoded and contains a single line:
         hello.HelloProcessorwithout the leading spaces.
    My processor looks like this:
         @SupportedAnnotationTypes (value = {"hello.annotations.Hello"})
         public class HelloProcessor extends AbstractProcessor {
             private int mCounter = 0;
             /* (non-Javadoc)
              * @see javax.annotation.processing.AbstractProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)
             @Override
             public boolean process(Set<? extends TypeElement> aAnnotations, RoundEnvironment aRoundEnv) {
              Messager vMessager = processingEnv.getMessager();
              vMessager.printMessage(Kind.NOTE, "Runde " + ++mCounter);
              vMessager.printMessage(Kind.NOTE, "Hello World!");
              return false;
         }The following call works...
         javac -processor hello.HelloProcessor -d bin -sourcepath src -cp lib/helloap.jar src/hello/examples/SimpleClass.javaand leads to the following output:
         warning: No SupportedSourceVersion annotation found on hello.HelloProcessor, returning RELEASE_6.
         Note: Runde 1
         Note: Hello World!
         Note: Runde 2
         Note: Hello World!          And this call does not seem to work:
         javac -d bin -sourcepath src -cp lib/helloap.jar src/hello/examples/SimpleClass.javaas it does not produce any output.
    And when I try to configure the processor in eclipse, the processor simply is not found, when I define the helloap.jar on the factory path.
    I'd be happy about every hint.
    Greetings
    yawah

    It sounds like your META-INF/services information is bad.
    Outside of javac, I suggest trying to find your processor from its jar file using java.util.ServiceLoader.
    I'd also try making sure your META-INF/services file ends with a newline character rather than just ends.

  • Where can I find WebLogic JAR including javax.annotation package?

    Hello.
    I'm writing and testing WebLogic EJB 3.0 sample through the edocs.bea.com
    Most samples in edocs use javax.annotation package, but I couldn't find any of javax.annotation package in jars of %WEBLOGIC_HOME%\server\lib folder.
    I want to use it such as javax.annotation.PreDestroy, javax.annotation.Resource etc.
    I'm using WebLogic 10.0 and Eclipse 3.3.
    Where can I find a jar include javax.annotation package?
    Thanks in advance.
    Edited by ienvyou at 12/11/2007 6:30 PM

    BEA_HOME\modules\javax.annotation...
    Edited by li_shen at 12/11/2007 10:26 PM

  • Message Driven Bean: problem with @RunAs annotation

    I am having a problem using the @RunAs annotation in a message driven bean.
    I would like the code in my onMessage() method to be executed with a specific role/user, so I want to use the @RunAs annotation to achieve this.
    I am running weblogic 10.0.
    I have created the following in weblogic console:
    - Group "TestGroup"
    - User "TestUser", member of "TestGroup"
    - Global Role "TestRole", role condition: "Group : TestGroup"
    The MDB:
    package be.cegeka.test.mdb;
    import javax.annotation.Resource;
    import javax.annotation.security.RunAs;
    import javax.ejb.ActivationConfigProperty;
    import javax.ejb.MessageDriven;
    import javax.ejb.MessageDrivenContext;
    import javax.jms.Message;
    import javax.jms.MessageListener;
    @MessageDriven(
              mappedName = "testQueue",
              name = "TestMDB",
              activationConfig = {
                        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
    @RunAs("TestRole")
    public class TestMDB implements MessageListener {
         @Resource
         private MessageDrivenContext mdContext;
          * {@inheritDoc}}
         public void onMessage(Message msg) {
              System.out.println("Handling message for user "
                        + mdContext.getCallerPrincipal().getName());
    }[u]The ejb-jar.xml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
    version="3.0">
         <assembly-descriptor>
              <security-role>
                   <description>
                        Test Role.
                   </description>
                   <role-name>TestRole</role-name>
              </security-role>
         </assembly-descriptor>
    </ejb-jar>
    The weblogic-ejb-jar.xml file:
    <weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/10.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.bea.com/ns/weblogic/10.0 http://www.bea.com/ns/weblogic/10.0/weblogic-ejb-jar.xsd">
         <security-role-assignment>
              <role-name>TestRole</role-name>
              <principal-name>TestUser</principal-name>
         </security-role-assignment>
    </weblogic-ejb-jar>I would have thought that the onMessage of the MDB would print "Handling message for user TestUser", but instead it prints "Handling message for user <anonymous>".
    It seems as though the @RunAs annotation has no effect. Although I specified the role TestRole (mapped to the user TestUser), the code still seems to be executed by user anonymous.
    Am I missing something?
    Any help would be much appreciated! I've been looking at this poblem for quite a while now.

    Both beans (the MDB on WLS 10 and the session bean on WLS 8.1) use container managed transactions.
    For the MDB I do not explicitly set the transaction attributes, so it should default to container managed transactions.
    For the stateless session bean I have specified the following in the ejb-jar.xml file:
    <ejb-jar>
      <display-name>Weblogic8Service</display-name>
      <enterprise-beans>
        <session>
          <ejb-name>Weblogic8Service</ejb-name>
          <home>be.cegeka.rszv.test.session.Weblogic8ServiceRemoteHome</home>
          <remote>be.cegeka.rszv.test.session.Weblogic8ServiceRemote</remote>
          <ejb-class>be.cegeka.rszv.test.session.Weblogic8ServiceBean</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Container</transaction-type>
        </session>
      </enterprise-beans>
      <assembly-descriptor>
        <container-transaction>
          <method>
            <ejb-name>Weblogic8Service</ejb-name>
            <method-name>*</method-name>
          </method>
          <trans-attribute>Required</trans-attribute>
        </container-transaction>
      </assembly-descriptor>
    </ejb-jar>So as far as I understand it the transaction starts at the MDB (upon receival of a message). The transaction for the remote call to the stateless session bean (in the onMessage() of the MDB) is included in the transaction of the MDB and gets committed when the onMessage() method finishes and the transaction of the MDB itself gets committed.
    Correct me if I'm wrong here.

  • How to avoid @PostConstruct on page Faces beans during postback?

    Hello, we're using GlassFishV2/JSAS9.1 with Mojarra 1.2_04-b22-p05 for a large project, and experiencing performance issues on form-less JSF commands when used in conjonction with @PostConstruct annotations. I feel this is an architectural issue I'm not able to resolve though, so I was wondering if anyone could shed some light on whether I'm missing something, there is some known workaround or it's a known JSF problem?
    The scenario is as follows:
    * Page my.jsp references Faces Beans MyFB.java
    * MyFB has @PostContruct method, which execute expensive logic to initialize the data model before rendering phase
    * my.jsp has a <commandLink action="#{anotherFB.myCommand}">
    * anotherFB.myCommand executes some logic and nav to another.jsp
    Now what seems to happen is that when we click on the commandLink, JSF does a postback to the same URL, instantiates MyFB, calls @PostConstruct on MyFB, and then instantiate anotherFB to call myCommand on it and nav to another.jsp
    In this situation, the expensive @PostConstruct logic to prepare data for rendering on my.jsp is executed although it is totally useless to the use case and hurts site performance a lot.
    I tried to use immediate="true" attribute, but it doesn't seem to prevent the @PostConstruct...
    In the case of a JSF form commandButton on the same bean, I can see how that would be necessary, but for a commandLink to another bean, why is JSF calling @PostConstruct on the previous page beans??
    I seem to be able to workaround this problem doing an if (getFacesContext().getRenderKit().getResponseStateManager().isPostback(getFacesContext()) in our @PostConstruct method and then make sure all the getters are NPE-safe, but if the commandLink is in a common include file, I'd then have to do this in every single beans within my app, which is not reasonable IMHO.
    Has anyone else experienced this problem? Or even maybe worked around it somehow?
    I'm curious if I'm missing something or if this is a major JSF architectural issue...
    Thanks!

    Thanks for the suggestion.
    We used to do this in the past, but this yields a host of other issues including:
    * no control over when getters get called and in what order
    * getters can get called multiple times, so you have to implement some caching to avoid init re-execution and it can get complicated in large object models
    * if a getter implements logic and blows up in the rendering phase, part of the page may have already been flushed out and you can't recover with an error page
    etc.
    @PostConstruct is a great standard-based option to get a bean initialized early in the JSF lifecycle, but there's just this one issue with commandLink that's problematic... :(
    We're sometimes using Shale's prerender callback, which is not invoked on a postback, but I was hoping there was maybe a standard-based solution?

  • Problem with ADF Faces; Bean (session scope) keeps Data after Session ends

    Hi,
    I have a project, which was transferred from an myFaces-project to an ADF Faces-project. Since i´am working with the ADF Faces the data in my beans (which are all in session-scope) won´t vanish after a logout.
    1) I have a method in one bean, which clears the user data (name and passwd), for example, but after a logout (redirecting to the login-page) I just have to push the loginbutton to get in the app. as the last user logged in. The bean is cleared, but where does the data come from. When the app was working with myFaces, this did not happen, the inputText and the inputHidden were empty.
    2) I have a af:table, which displays max ten lines. If the last user watched the elements 21 to 30 in that table, the next user who watches the table gets the same elements shown and not the elements 1 to 10. That shouldn´t happen in a different session.
    3) I have some listboxes in one page, where a user can make some decisions. If i logout and in again, i can see the decisions last made in these listboxes.
    All that happens with beans in session scope!
    Thanks for the replies (i hope) and excuse my bad english,
    Santiago

    Hi
    If this is the case , you can explicitly make all ur session data objects null.

  • SessionScoped managedbean not working

    Hi,
    I don't find the solution for my problem.
    I use spring security 3.1.2 and jsf 2.1
    Logging in my application with different users give me the same managed beans.
    I printed out the sessionid after login, this is always a new session id.
    Code LoginBean:
    import javax.faces.application.FacesMessage;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.SessionScoped;
    import javax.faces.context.ExternalContext;
    import javax.faces.context.FacesContext;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpSession;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import x.y.User;
    import x.y.AuthenticationService;
    import x.y.UserService;
    @ManagedBean(name="loginBean")
    @SessionScoped
    @Controller
    public class LoginBean {
    private String login;
    private String password;
    private String userName = null;
    @Autowired
    private AuthenticationService authenticationService;
    @Autowired
    private UserService userService;
    public String login() {
    boolean success = authenticationService.login(login, password);
    if (success) {
    User user = this.userService.findUser(login);
    this.userName = user.getName();
    FacesContext context = FacesContext.getCurrentInstance();
    HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
    HttpSession httpSession = request.getSession(false);
    System.out.println(httpSession.getId());
    return "/secure/index.xhtml?faces-redirect=true";
    } else {
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Login or password incorrect."));
    return "/login?faces-redirect=true";
    public String logout() {
    FacesContext context = FacesContext.getCurrentInstance();
    ExternalContext ec = context.getExternalContext();
    final HttpServletRequest request = (HttpServletRequest)ec.getRequest();
    request.getSession(false).invalidate();
    return "/login?faces-redirect=true";
    public String getLogin() {
    return login;
    public void setLogin(String login) {
    this.login = login;
    public String getPassword() {
    return password;
    public void setPassword(String password) {
    this.password = password;
    public String getUserName() {
    return userName;
    public void setUserName(String userName) {
    this.userName = userName;
    In my jsf page I printout the username like this:
    <h:outputText value="Logged in as: " /><h:outputText value="#{loginBean.userName} " />
    And it displays always the last userName logged in the application :-) So, it is always the same object of LoginBean and not an new per session?
    How is this possible?

    @Controller is the problem :-)
    Remove that and use
    @ManagedProperty(value="#{authenticationService}")
    private AuthenticationService authenticationService;
    @ManagedProperty(value="#{userService}")
    private UserService userService;
    @Controlles is spring and by default singleton!!!!

  • Javax.ejb.EJBException: Transaction aborted

    Hello everyone, I am new in javaEE6. When i try to develop and simple example i meet this error but i can't find which code line cause it. I use JSF EJB3.1 EclipseLink JPA 2.0 in Glassfish v3 and developed in Netbean6.8. Here is my Stack trace .
    Caused by: javax.ejb.EJBException: Transaction aborted
         at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:4997)
         at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4756)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1955)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1906)
         at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:198)
         at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:84)
         at $Proxy158.createUsers(Unknown Source)
         at home.tuan.bussiness.__EJB31_Generated__UsersEJB__Intf____Bean__.createUsers(Unknown Source)
         at home.tuan.controller.UsersController.doCreateUser(UsersController.java:40)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
         at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
         at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:98)
         at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
         ... 32 more
    Caused by: javax.transaction.RollbackException: Transaction marked for rollback.
         at com.sun.enterprise.transaction.JavaEETransactionImpl.commit(JavaEETransactionImpl.java:450)
         at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:837)
         at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:4991)
         ... 48 more
    Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "." at line 1, column 29.
    Error Code: -1
    Call: INSERT INTO ChatDatabase.dbo.Users (UserName, Pass) VALUES (?, ?)
         bind => [er, w]
    Query: InsertObjectQuery(home.tuan.model.Users@825299)My Entity is:
    package home.tuan.model;
    import java.io.Serializable;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import javax.persistence.NamedQueries;
    import javax.persistence.NamedQuery;
    import javax.persistence.Table;
    * @author minhtuan
    @Entity
    @Table(name = "Users", catalog = "ChatDatabase", schema = "dbo")
    public class Users implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id  
        @Column(name = "UserName")
        private String userName;
        @Column(name = "Pass")
        private String pass;
        public Users() {
        public Users(String userName, String pass) {
            this.userName = userName;
            this.pass = pass;
        public String getUserName() {
            return userName;
        public void setUserName(String userName) {
            this.userName = userName;
        public String getPass() {
            return pass;
        public void setPass(String pass) {
            this.pass = pass;
    }My session bean is:
    package home.tuan.bussiness;
    import home.tuan.model.Users;
    import java.util.ArrayList;
    import java.util.List;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
    * @author minhtuan
    @Stateless
    public class UsersEJB {
      @PersistenceContext(unitName="MavenTestPU")
      private EntityManager em ;
      public Users createUsers(Users newUser){
          em.persist(newUser);
          return newUser;
    }My controller class is:
    package home.tuan.controller;
    import home.tuan.bussiness.UsersEJB;
    import home.tuan.model.Users;
    import java.util.ArrayList;
    import java.util.List;
    import javax.ejb.EJB;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.RequestScoped;
    import javax.persistence.EntityTransaction;
    import javax.persistence.Persistence;
    import javax.transaction.UserTransaction;
    * @author minhtuan
    @ManagedBean(name="UsersController")
    @RequestScoped
    public class UsersController {
        /** Creates a new instance of UsersController */
        @EJB
        UsersEJB userEJB;
        Users newUser = new Users();
        List<Users> listUsers = new ArrayList<Users>();
        public String doNewUser(){
            return "index.jsp";
        public String doCreateUser(){
            System.out.println("Den day rui");
            System.out.println(newUser.getUserName());
            System.out.println(newUser.getPass());
            newUser = userEJB.createUsers(newUser);
            return "index.jsp";
        public List<Users> getListUsers() {
            return listUsers;
        public void setListUsers(List<Users> listUsers) {
            this.listUsers = listUsers;
        public Users getNewUser() {
            return newUser;
        public void setNewUser(Users newUser) {
            this.newUser = newUser;
    }And my persistence.xml is:
    <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
      <persistence-unit name="MavenTestPU" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>home.tuan.model.Users</class>
        <properties>
            <!--
          <property name="javax.persistence.jdbc.url" value="jdbc:sqlserver://localhost:1433;databaseName=ChatDatabase"/>
          <property name="javax.persistence.jdbc.password" value="12345"/>
          <property name="javax.persistence.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
          <property name="javax.persistence.jdbc.user" value="sa"/>
          -->
           <property name="eclipselink.target-database" value="SQLSERVER"/>
           <property name="eclipselink.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
           <property name="eclipselink.jdbc.url" value="jdbc:sqlserver://localhost:1433;databaseName=ChatDatabase"/>
                <!--<property name="eclipselink.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>-->
                <!--<property name="eclipselink.jdbc.url" value="jdbc:derby:chapter10DB;create=true"/>-->
           <property name="eclipselink.jdbc.user" value="sa"/>
           <property name="eclipselink.jdbc.password" value="12345"/>
                <!--property name="eclipselink.ddl-generation" value="update"/-->
                <!--property name="eclipselink.ddl-generation" value="drop-and-create-tables"/-->
           <property name="eclipselink.logging.level" value="INFO"/>
        </properties>
      </persistence-unit>
    </persistence>Thanks in advance
    Edited by: ActiveDean on Dec 24, 2009 4:38 PM

    You need to step through a debugger and find the source of your problem as something is clearly going wrong and causing the transaction to roll back. That is all that message tells us.
    m

  • @postconstruct doesn't work in managed bean

    Hi,
    I'm using JBOSS 6, JSF 2 and EJB 3.1, i have an ear with
    - EJB folder (@postconstruct is working)
    - JSF folder with manged bean where @postconstruct doesn't work
    This my manged bean :
    package com.galhauban.geriex;
    import java.util.ArrayList;
    import java.util.List;
    import javax.annotation.PostConstruct;
    import javax.ejb.EJB;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.ViewScoped;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.event.ValueChangeEvent;
    import javax.faces.model.SelectItem;
    import javax.servlet.ServletContext;
    import org.richfaces.event.ItemChangeEvent;
    @ManagedBean
    @ViewScoped
    public class AdministrationController {
    @EJB
    private VilleBean ville;
    private List<SelectItem> villes = new ArrayList<SelectItem>();
    private String commune;
    private String communeId;
    private String cp;
    private String labelListCommune;
    @EJB
    private BisBean bisBean;
    private String bis;
    private Integer bisId;
    private List<SelectItem> bisList = new ArrayList<SelectItem>();
    @EJB
    private RueBean rueBean;
    private String rue;
    private String rueId;
    private List<SelectItem> ruesList = new ArrayList<SelectItem>();
    //boolean desactives pour n'afficher que ce que l'on souhaite a partir du menu
    private boolean bCommune =false;
    private boolean bBis =false;
    private boolean bRue =false;
    private UIComponent selectedChild = null;
    //Pour connaitre l'item du menu actif
    private String selectedTab;
    private List<String> renderComponents = new ArrayList<String>();
    public AdministrationController(){
    ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
    System.out.println("============================================================================");
    System.out.println("==================================CONSTRUCTEUR==============================");
    System.out.println("Servlet : "+servletContext.getEffectiveMajorVersion()+"."+servletContext.getMinorVersion());
    System.out.println("============================================================================");
    @PostConstruct
    public void postConstruct(){
    setSelectedTab("rue");
    System.out.println("###################################################");
    System.out.println(" POST CONSTRUCT MANAGED BEAN ");
    System.out.println("###################################################");
    JanusController multi = new JanusController();
    * AFFICHAGE DES MODIFS/SUP/AJOUT EN FONCTION DU MENU SELECTIONNE
    public void updateCurrent(ItemChangeEvent event){
    setSelectedTab(event.getNewItem().getId());
    System.out.println("====> SELECTEDTAB " + selectedTab.toString());
    if (selectedTab.equals("commune")) {
    setbCommune(true);
    setbBis(false);
    setbRue(false);
    renderComponents.add("gCommune");
    else if (selectedTab.equals("bis")) {
    setbBis(true);
    setbCommune(false);
    setbRue(false);
    renderComponents.add("gBis");
    else if (selectedTab.equals("rue")) {
    setbRue(true);
    setbBis(false);
    setbCommune(false);
    renderComponents.add("gRue");
    else System.out.println("----> pas dans le if " + selectedTab.toString());
    public void ajouter(){
    System.out.println("====> AJOUTER SELECTEDTAB " + selectedTab.toString());
    if (selectedTab.equals("commune")) {
    System.out.println("ajouter commune ");
    ville.ajouter(commune, cp);
    else if (selectedTab.equals("bis")) {
    System.out.println("ajouter iBbis ");
    bisBean.ajouter(bis);
    else if (selectedTab.equals("rue")) {
    System.out.println("ajouter rue: "+commune);
    rueBean.ajouter(rue, Integer.parseInt(communeId));
    else System.out.println("----> pas dans le if de l'ajouter " + selectedTab.toString());
    public void modifier(){
    System.out.println("====> MODIFIER SELECTEDTAB " + selectedTab.toString());
    if (selectedTab.equals("commune")) {
    ville.modifier(Integer.parseInt(communeId), commune);
    else if (selectedTab.equals("bis")) {
    bisBean.modifier(bisId, bis);
    else if (selectedTab.equals("rue")) {
    rueBean.ajouter(rue, Integer.parseInt(communeId));
    else System.out.println("----> pas dans le if de modifier " + selectedTab.toString());
    public void supprimer(){
    System.out.println("====> SUPRIMER SELECTEDTAB " + selectedTab.toString());
    if (selectedTab.equals("commune")) {
    System.out.println("ajouter commune ");
    ville.ajouter(commune, cp);
    else if (selectedTab.equals("bis")) {
    System.out.println("supprimer iBbis ");
    bisBean.supprimer(bisId);
    else if (selectedTab.equals("rue")) {
    System.out.println("ajouter rue: "+commune);
    rueBean.ajouter(rue, villes.indexOf(ville));
    else System.out.println("----> pas dans le if de l'ajouter " + selectedTab.toString());
    * LISTENER
    public void selectListener(ValueChangeEvent vce){
    System.out.println("new value : "+vce.getNewValue());
    public void listAdminCommune(ValueChangeEvent vce){
    System.out.println("listener*************");
    ruesList.clear();
    ruesList = rueBean.listRue(Integer.parseInt(vce.getNewValue().toString()));
    * AUTRES FONCTIONS
    public boolean invbool(boolean vrai){
    if (vrai == true) return false;
    else return true;
    * GETTER AND SETTER
    Any help will be highly appreciated.
    Regards
    Couse1

    Hi,
    First of all thanks for your help.
    I've some problems to add a new mojarra version (2.1.2) to jboss 6
    1- I modified the file META-INF\jsf-integration-deployer-jboss-beans.xml
    <entry>
              <key>Mojarra-2.1.2</key>
              <value>${jboss.server.home.url}deployers/jsf.deployer/Mojarra-2.1.2</value>
    </entry>
    <bean name="JSFUrlIntegrationDeployer-212" class="org.jboss.jsf.deployer.JSFUrlIntegrationDeployer">
        <property name="JSFConfigName">
          <value>Mojarra-2.1.2</value>
        </property>
        <property name="JSFImplManagementDeployer">
          <inject bean="JSFImplManagementDeployer"/>
        </property>
      </bean>2- I added this code in my web.xml(war)
    <context-param> 
            <param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name> 
            <param-value>Mojarra-2.1.2</param-value> 
          </context-param>3- And in the folder ...\deployers\jsf.deployer\Mojarra-2.1.2, i've got :
    - jsf-libs with jars
    - META-INF with web.xml
    I took the web.xml from Mojarra-2.0 :
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
       version="2.5">
       <!-- ======================== Introduction ============================== -->
       <!-- This document defines default values for the Mojarra-2.0 JSF config  -->
       <!--                                                                      -->
       <!-- WARNING:  Do not configure application-specific resources here!      -->
       <!-- They should go in the "/WEB-INF/web.xml" file in your application.   -->
       <!-- =========== Common Context Params ================================== -->
       <!-- Regular expression to determine if two different URLs actually point -->
       <!-- to the same jar file.  This keeps faces-config files from being      -->
       <!-- read twice.                                                          -->
       <context-param>
         <param-name>com.sun.faces.duplicateJARPattern</param-name>
         <param-value>^tmp\d+(\S*\.jar)</param-value>
       </context-param>
       <!-- JBossInjectionProvider provides resource injection for managed beans. -->
       <!-- See JSF 1.2 spec section 5.4 for details.                             -->
       <context-param>
         <param-name>com.sun.faces.injectionProvider</param-name>
         <param-value>org.jboss.web.jsf.integration.injection.JBossDelegatingInjectionProvider</param-value>
       </context-param>
       <!-- ================== Common filter Configuration ==================== -->
       <!-- ================== Common Listener Configuration ==================== -->
       <!-- Configures JSF 2.0 -->
       <listener>
         <listener-class>org.jboss.web.jsf.integration.config.JBossMojarra20ConfigureListener</listener-class>
       </listener>
    </web-app>And of course i've got this error :
    org.jboss.web.jsf.integration.config.JBossMojarra20ConfigureListener: java.lang.ClassNotFoundException: org.jboss.web.jsf.integration.config.JBossMojarra20ConfigureListener
    I don't know where to find the listener-class, and in fact i don't know to configure this web.xml.
    Help or sugestion will be appreciated.
    Best regards
    couse1

  • UI Component (h:selectOneMenu) showing old value not matching backing bean

    Mojarra 2.1.7-jbossorg-1
    I'm out of my wits trying to figure out what is going on here.
    I have broken down the problem that I am seeing to something smaller test case that is easily reproducable.
    Two <h:selectOneRadio> ( Approved and Notified )
    One <h:selectOneMenu> wrapped in a <h:panelGroup>
    One <h:commandButton>
    The list of contents of the <h:selectOneMenu> is dependent on the value of the "Approved" <h:selectOneRadio>, and the list is obtained from the viewBean.
    Apart from the "required" attribute, the only other validation is a validator method in the bean that:
    If "Approved" radio button is Yes, and "Notified" radio button is No, then a ValidatorException is thrown and is shown on the <h:messages>
    Now the issue:
    1) Select Approved "Yes"
    2) Select Notified "No"
    3) Select dropdown to PEND
    4) Select Submit button
    5) <h:messages> show "Notified must be true when action is PEND". All good.
    6) Change Approved to "No" ... Note that there is a listener on change of Approved ... and the listener will always set the value of the dropdown to null.
    Because I changed the value of the Approved radio button, the dropdown selection is then changed to the "- Select- " item, which is what I am expecting as that is what the listener method does ... and the dropdown is re-rendered.
    7) Change Approved back to "Yes" ... dropdown changes back to PEND ... This is what I do not understand.
    Why was it being changed back to PEND when:
    A) The listener on the Approved radio button always sets the value of the dropdown to null in the backend.. and
    B) The Approved render attribute always re-render the dropdown
    <!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:head>
    <body>
    <h:form>
           <h:outputLabel value="Approved:"/>
           <h:selectOneRadio id="approved" value="#{viewBean.approved}"
                required="true"
                requiredMessage="Approved is required.">
                <f:selectItem itemValue="true" itemLabel="Yes"/>
                <f:selectItem itemValue="false" itemLabel="No"/>
                <f:ajax
                    event="valueChange"
                    execute="@this"
                    render="nextActionPanel"
                    listener="#{viewBean.triggerApprovedChange()}"/>
           </h:selectOneRadio>
           <h:outputLabel value="Notified:"/>
           <h:selectOneRadio id="notified" value="#{viewBean.notified}"
                required="true"
                requiredMessage="Notified is required."
                   validator="#{viewBean.validateNotified}">
                <f:selectItem itemValue="true" itemLabel="Yes"/>
                <f:selectItem itemValue="false" itemLabel="No"/>
                <f:ajax
                    event="valueChange"
                    execute="@this"
                    render="@none"/>
           </h:selectOneRadio>
            <h:panelGroup id="nextActionPanel">
           <h:selectOneMenu id="nextAction"
                 required="true"
                 requiredMessage="Next Action is required."
                 value="#{viewBean.nextAction}">
                 <f:selectItem itemValue="" itemLabel="- Select -" />
                 <f:selectItems
                     value="#{viewBean.availableNextActions}" var="target"
                     itemValue="#{target.value}"
                     itemLabel="#{target.label}"/>
                   <f:ajax
                    event="valueChange"
                    execute="@this"
                    render="@none"/>
           </h:selectOneMenu>
            </h:panelGroup>
           <h:commandButton id="submit" value="Submit"/><br/>
           <h:messages/>
    </h:form>
    </body>
    </html>
    package test;
    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.List;
    import javax.annotation.PostConstruct;
    import javax.faces.application.FacesMessage;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.ViewScoped;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.validator.ValidatorException;
    @ManagedBean
    @ViewScoped
    public class ViewBean implements Serializable {
         private static final long serialVersionUID = 1L;
         private Boolean approved;
         private Boolean notified;
         private String nextAction;
         private List<NextAction> availableNextActions;
         public Boolean getApproved() {
              return approved;
         public void setApproved(Boolean selection) {
              this.approved = selection;
         public Boolean getNotified() {
              return notified;
         public void setNotified(Boolean selection2) {
              this.notified = selection2;
         public String getNextAction() {
              return nextAction;
         public void setNextAction(String nextAction) {
              this.nextAction = nextAction;
         public void triggerApprovedChange() {
              changeAvailableNextActions();
              setNextAction(null);
         public List<NextAction> getAvailableNextActions() {
              return availableNextActions;
         private void setAvailableNextActions(List<NextAction> availableNextActions) {
              this.availableNextActions = availableNextActions;
         public void changeAvailableNextActions() {
              List<NextAction> nextActions = new ArrayList<NextAction>();
              if( Boolean.TRUE.equals( getApproved() )) {
                   nextActions.add( new NextAction("PEND", "Pend"));
              nextActions.add( new NextAction("REQADVICE", "Request Advice"));
              nextActions.add( new NextAction("FIN", "Finish"));
              setAvailableNextActions(nextActions);
         @PostConstruct
         public void init() {
              changeAvailableNextActions();
         public void validateNotified(
              FacesContext context,
            UIComponent toValidate,
            Object value)
              throws Exception
              List<FacesMessage> messages = new ArrayList<FacesMessage>();
              Boolean isNotified = (Boolean) value;
              if( Boolean.FALSE.equals( isNotified ) && "PEND".equals( nextAction )) {
                   FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
                        "Notified must be true when action is PEND", null);
                   messages.add( message );
              if( messages.size() > 0 ) {
                   throw new ValidatorException(messages);
         public class NextAction implements Serializable {
              private static final long serialVersionUID = 1L;
              private String label;
              private String value;
              public NextAction(String aValue, String aLabel) {
                   value = aValue;
                   label = aLabel;
              public String getLabel() {
                   return label;
              public String getValue() {
                   return value;
    }

    gimbal2 wrote:
    jmsjr wrote:
    Ok .. I am confused by what you just said .. as I did say that the same problem STILL exists in Mojarra 2.1.22.
    ergo .. It is not an issue with the usage of JSF but appears to be a bug in the implementation.I meant a bug in the old version that JBoss ships with. But I also mean in general; as you can see JSF 2.x is already on release 22 - the chance of you finding such an easy to trigger bug has become relatively slim. So no, I must assume it is actually a problem with not understanding how JSF ticks properly. Which is understandable since after using it for 5 years it still surprises me occasionally.
    The bug you link to is about values staying the same, not reverting back to a previous state.OK .. Maybe this will be more convincing (?). I change the xhtml so that it also displays ( via h:outputText ) .. the value of the backing bean that is the same value used for the h:selectOneMenu.
    <!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:head>
    <h:body>
    <h:form>
           <h:outputLabel value="Approved:"/>
           <h:selectOneRadio id="approved" value="#{viewBean.approved}"
                required="true"
                requiredMessage="Approved is required.">
                <f:selectItem itemValue="true" itemLabel="Yes"/>
                <f:selectItem itemValue="false" itemLabel="No"/>
                <f:ajax
                    event="valueChange"
                    execute="@this"
                    render="nextActionPanel"
                    listener="#{viewBean.triggerApprovedChange()}"/>
           </h:selectOneRadio>
           <h:outputLabel value="Notified:"/>
           <h:selectOneRadio id="notified" value="#{viewBean.notified}"
                required="true"
                requiredMessage="Notified is required."
                   validator="#{viewBean.validateNotified}">
                <f:selectItem itemValue="true" itemLabel="Yes"/>
                <f:selectItem itemValue="false" itemLabel="No"/>
                <f:ajax
                    event="valueChange"
                    execute="@this"
                    render="@none"/>
           </h:selectOneRadio>
            <h:panelGroup id="nextActionPanel">
            Backing Bean value for nextAction is '<h:outputText value="#{viewBean.nextAction}"/>'<br/>
           <h:selectOneMenu id="nextAction"
                 required="true"
                 requiredMessage="Next Action is required."
                 value="#{viewBean.nextAction}">
                 <f:selectItem itemValue="" itemLabel="- Select -" />
                 <f:selectItems
                     value="#{viewBean.availableNextActions}" var="target"
                     itemValue="#{target.value}"
                     itemLabel="#{target.label}"/>
                   <f:ajax
                    event="valueChange"
                    execute="@this"
                    render="nextActionPanel"/>
           </h:selectOneMenu>
            </h:panelGroup>
           <h:commandButton id="submit" value="Submit" render="@form"/><br/>
           <h:messages/>
            <ui:debug/>
    </h:form>
    </h:body>
    </html>All I changed was
    1) Added the following:
    Backing Bean value for nextAction is '<h:outputText value="#{viewBean.nextAction}"/>'<br/>.. which is in the same panel ( <h:panelGroup id="nextActionPanel"> ) as the <h:selectOneMenu>
    2) Changed the render attribute of the h:selectOneMenu so that instead of @none, it is now:
                   <f:ajax
                    event="valueChange"
                    execute="@this"
                    render="nextActionPanel"/>3) Repeated the same steps as before ... and after step [6]:
    3a) The h:outputText says:
    Backing Bean value for nextAction is ''3b) But the h:selectOneMenu still has the PEND option selected.

  • My CommandButton calls PostContructs from other Managed Beans. Why?

    Hi,
    i have a big problem that i can't understand.
    I use a command Button who should call only one Managed Bean. But however it calls other Managed Beans too.
    How is it possible?
    my properties:
    Primfaces 2.1
    Glassfish v3
    jsf 2.0
    Ejb 3.1
    JPA - Toplink
    Facelets
    Netbeans
    mainTemplate.xhtml
    <!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" xml:lang="de" lang="de"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:c="http://java.sun.com/jsp/jstl/core"
          xmlns:p="http://primefaces.prime.com.tr/ui">
        <ui:insert name="head">
            <h:head>
                <meta http-equiv="content-type" content="application/xhtml+xml;charset=utf-8" />
                <link rel="stylesheet" type="text/css" href="#{facesContext.externalContext.requestContextPath}/css/style.css" />
                <title></title>
            </h:head>
        </ui:insert>
        <h:body>
            <div class="main">
                <div class="main-bg">
                    <div class="main-width">
                        <div class="indent">
                            <h:form id="urlForm" prependId="false">
                                <div class="posturlbox">
                                    <h:inputText value="#{addUrlBean.userUrl}" styleClass="posturlinput" id="url" onclick="this.value = ''" />
                                </div>
                                <p:commandButton styleClass="button" action="#{addUrlBean.addVideo}" value="#{msg.send}" style="float: left;" update="urlForm" />
                                <div class="addUrlMessage">
                                    <p:message for="url" showSummary="true" showDetail="false" />
                                </div>
                            </h:form>
                            <div class="clear"></div>
                        </div>
                        <div class="content">
                            <div class="content-indent">
                                <ui:insert name="content">
                                </ui:insert>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </h:body>
    </html>
    test.xhtml
    <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"
          xmlns:c="http://java.sun.com/jsp/jstl/core"
          xmlns:p="http://primefaces.prime.com.tr/ui">
        <h:head>
            <meta http-equiv="content-type"
                  content="application/xhtml+xml;charset=utf-8" />
        </h:head>
        <h:body>
            <ui:composition template="/WEB-INF/template/mainTemplate.xhtml">
            </ui:composition>
        </h:body>
    </html>
    addUrlManagedBean.java
    package managedBeans;
    import entities.UserEntity;
    import infoBeans.VideoValidationInfo;
    import javax.ejb.EJB;
    import javax.faces.application.FacesMessage;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.ManagedProperty;
    import javax.faces.bean.ViewScoped;
    import sessionBeans.VideoSessionBean;
    @ManagedBean(name = "addUrlBean")
    @ViewScoped
    public class AddUrlManagedBean extends GeneralManagedBean {
        @EJB
        VideoSessionBean videoSessionBean;
        private String userUrl = "URL";
        @ManagedProperty("#{loginBean}")
        LoginManagedBean loginMB;
        /** Creates a new instance of AddUrlManagedBean */
        public AddUrlManagedBean() {
        public void addVideo() {
            UserEntity sessionUser = loginMB.getSessionUser();
            if (sessionUser == null) {
                informUser(FacesMessage.SEVERITY_WARN,
                        "log_in_or_crate_new_account",
                        "log_in_or_crate_new_account_detail", "url");
            } else {
                int validationId = videoSessionBean.validateVideo(userUrl);
                if (validationId == VideoValidationInfo.VIDEO_IS_OK) {
                    videoSessionBean.addVideo(sessionUser, userUrl);
                    informUser(FacesMessage.SEVERITY_INFO,
                            "video_create_success",
                            "video_create_success_detail", "url");
                } else if (validationId == VideoValidationInfo.URL_IS_EMPTY) {
                    informUser(FacesMessage.SEVERITY_ERROR,
                            "url_is_empty",
                            "url_is_empty_detail", "url");
                } else if (validationId == VideoValidationInfo.URL_SYNTAX_WRONG) {
                    informUser(FacesMessage.SEVERITY_ERROR,
                            "url_syntax_wrong",
                            "url_syntax_wrong_detail", "url");
                } else if (validationId == VideoValidationInfo.VIDEO_NOT_EXIST) {
                    informUser(FacesMessage.SEVERITY_ERROR,
                            "video_not_exist",
                            "video_not_exist_detail", "url");
                } else if (validationId == VideoValidationInfo.VIDEO_ALREADY_EXIST) {
                    informUser(FacesMessage.SEVERITY_ERROR,
                            "video_already_exist",
                            "video_already_exist_detail", "url");
                } else if (validationId == VideoValidationInfo.VIDEO_ID_LENGTH_WRONG) {
                    informUser(FacesMessage.SEVERITY_ERROR,
                            "video_id_length_wrong",
                            "video_id_length_wrongdetail", "url");
            userUrl = "";
        public String getUserUrl() {
            return userUrl;
        public void setUserUrl(String userUrl) {
            this.userUrl = userUrl;
        public LoginManagedBean getLoginMB() {
            return loginMB;
        public void setLoginMB(LoginManagedBean loginMB) {
            this.loginMB = loginMB;
    }Now. if i click the Button
    *<p:commandButton styleClass="button" action="#{addUrlBean.addVideo}" value="#{msg.send}" style="float: left;" update="urlForm" />*
    *<div class="addUrlMessage">*
    it should only use the AddUrlManagedBean right (i tried it with h:commandButton too.. same result)? But i make a System.out in my other ManagedBeans (PostConstructs) and i see this logfile.
    LogFile
    INFO: PostConstruct: VideoDetailMB - ViewScoped
    INFO: PostConstruct: VideoMB - RequestScoped
    INFO: PostConstruct: UserVideosMB - ViewScopedHow is that possible? Why it activate the Lifecycle of other ManagedBeans?

    it should only use the AddUrlManagedBean rightWrong. It should also use this bean:
    @EJB
        VideoSessionBean videoSessionBean;with whatever consequences that has.

  • JSF1063 Warning With Managed Bean

    With Glassfish V3 it outputs a JSF 1063 warning to do with not being able to serialise an object. Below is the Glassfish log:
    INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
    INFO: nullID: /home/nick/NetBeans Projects/EAA Website/build/web/ CLASSES: [class nz.co.eaa.FeedbackController, class nz.co.eaa.ServicesController, class nz.co.eaa.Feedback, class nz.co.eaa.ApplicationController]
    INFO: Initializing Mojarra 2.0.2 (FCS b10) for context '/eaa'
    INFO: Monitoring jndi:/server/eaa/WEB-INF/faces-config.xml for modifications
    INFO: Loading application EAA_Website at /eaa
    INFO: EAA_Website was successfully deployed in 746 milliseconds.
    WARNING: JSF1063: WARNING! Setting non-serializable attribute value into HttpSession (key: feedback, value class: nz.co.eaa.Feedback).What is really bizarre is that the managed bean (Feedback) is session scoped, therefore it should be serialised across a session (HTTP session). Also the managed bean has a null ID which may contribute to the problem. Here are the contents of Feedback.java:
    package nz.co.eaa;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.SessionScoped;
    @ManagedBean(name = "feedback")
    @SessionScoped
    public class Feedback
        private String firstName = "";
        private String lastName = "";
        private String email = "";
        private String phoneNum = "";
        private String address = "";
        private String subject = "";
        private String message = "";
        private String priority = "";
        /** Creates a new instance of Feedback */
        public Feedback()
            // Do nothing.
        public String getAddress()
            return address;
        public void setAddress(String address)
            this.address = address;
        public String getEmail()
            return email;
        public void setEmail(String email)
            this.email = email;
        public String getFirstName()
            return firstName;
        public void setFirstName(String firstName)
            this.firstName = firstName;
        public String getLastName()
            return lastName;
        public void setLastName(String lastName)
            this.lastName = lastName;
        public String getMessage()
            return message;
        public void setMessage(String message)
            this.message = message;
        public String getPhoneNum()
            return phoneNum;
        public void setPhoneNum(String phoneNum)
            this.phoneNum = phoneNum;
        public String getPriority()
            return priority;
        public void setPriority(String priority)
            this.priority = priority;
        public String getSubject()
            return subject;
        public void setSubject(String subject)
            this.subject = subject;
    }Here are the contents of feedback.xhtml:
    <?xml version='1.0' encoding='UTF-8' ?>
    <!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:ui="http://java.sun.com/jsf/facelets"
          xmlns:f="http://java.sun.com/jsf/core">
        <ui:composition template="layout.xhtml">
            <ui:define name="content">
                <h1 id="content-title">Feedback</h1>
                <f:view>
                    <h:form>
                        <h:outputLabel value="#{feedbackController.labelNames['firstName']}"
                                       for="firstName" />
                        <h:inputText id="firstName"
                                     value="#{feedback.firstName}" />
                        <h:outputLabel value="#{feedbackController.labelNames['lastName']}"
                                       for="lastName" />
                        <h:inputText id="lastName"
                                     value="#{feedback.lastName}" />
                        <h:outputLabel value="#{feedbackController.labelNames['email']}"
                                       for="email" />
                        <h:inputText id="email"
                                     value="#{feedback.email}" />
                        <h:outputLabel value="#{feedbackController.labelNames['phoneNum']}"
                                       for="phoneNum" />
                        <h:inputText id="phoneNum"
                                     value="#{feedback.phoneNum}" />
                        <h:outputLabel value="#{feedbackController.labelNames['addr']}"
                                       for="addr" />
                        <h:inputTextarea id="addr"
                                         value="#{feedback.address}" />
                        <h:outputLabel value="#{feedbackController.labelNames['subject']}"
                                       for="subject" />
                        <h:selectOneListbox value="#{feedback.subject}"
                                            id="subject">
                            <f:selectItems var="item" itemLabel="#{item}"
                                           itemValue="#{item}"
                                           value="#{feedbackController.subjects}"/>
                        </h:selectOneListbox>
                        <h:outputLabel value="#{feedbackController.labelNames['msg']}"
                                       for="msg" />
                        <h:inputTextarea id="msg"
                                         value="#{feedback.message}" />
                        <h:outputLabel value="#{feedbackController.labelNames['priority']}"
                                       for="subject" />
                        <h:selectOneListbox value="#{feedback.priority}">
                            <f:selectItems var="item" itemLabel="#{item}"
                                           itemValue="#{item}"
                                           value="#{feedbackController.priorities}"/>
                        </h:selectOneListbox>
                    </h:form>
                </f:view>
            </ui:define>
        </ui:composition>
    </html>Currently when feedback.xhtml is visited nothing is saved to the HTTP session even though feedback's properties are bound to the JSF controls in feedback.xhtml. Has anyone encountered a similar problem where a session scoped managed bean is not persisted in a HTTP session?

    Interesting that the container would attempt to persist a session to disk, or some other persistent storage if the session times out. This would explain why there was a warning message that appeared in the Glassfish log. Below is the contents of FeedbackController.java:
    package nz.co.eaa;
    import java.util.HashMap;
    import java.util.Map;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.NoneScoped;
    @ManagedBean(name = "feedbackController")
    @NoneScoped
    public class FeedbackController
        private Map<String, String> labelNames = new HashMap<String, String>();
        private String[] subjects = {"Inquiry", "Comment", "Quotes"};
        private String[] priorities = {"Low", "Medium", "High"};
        /** Creates a new instance of FeedbackController */
        public FeedbackController()
            labelNames.put("firstName", "First Name:");
            labelNames.put("lastName", "Last Name:");
            labelNames.put("email", "Email:");
            labelNames.put("phoneNum", "Phone Number:");
            labelNames.put("addr", "Address:");
            labelNames.put("subject", "Subject:");
            labelNames.put("msg", "Message:");
            labelNames.put("priority", "Priority:");
        public String[] getPriorities()
            return priorities;
        public String[] getSubjects()
            return subjects;
        public Map<String, String> getLabelNames()
            return labelNames;
    }As for FeedbackController it is set for None scope since some data is contained within the managed bean itself. All data bindings to the FeedbackController are receiving the correct values so this isn't the actual issue. The real issue is data not being retrieved from Feedback when it is filled with data (supposedly), hence all form data is lost when feedback.xhtml is refreshed.
    Although this may not be needed I have included the contents of web.xml below just in case:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
        <context-param>
            <param-name>javax.faces.PROJECT_STAGE</param-name>
            <param-value>Development</param-value>
        </context-param>
        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>/faces/*</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
            <welcome-file>faces/index.xhtml</welcome-file>
        </welcome-file-list>
    </web-app>

  • Passing values between views in View Scoped Bean

    I have a form page that uses a view scoped backing. This page forwards to a confirmation page that uses the same backing bean. I would like to redisplay the information to the user that they entered in the form and then process these values when they hit submit on the confirmation page. However, when on the confirmation page, all of the values from the bean are null. I understand that view scoped beans are destroyed when you go to a new view, but when this bean was request scoped I could see the values on this page and save them in hidden inputs to process in the backing bean. I can still see the form values in the request parameters. Also, I cannot use a request scoped bean due to multiple ajax requests that are on the form. How can I propagate the values from the first form page to the second confirmation page?
    I am using Mojarra JSF 2.0
    Edited by: edenbaptiste on Apr 22, 2010 4:25 PM

    Here is some Sample code.
    The Payment Page:
    <ui:composition>
        <form jsfc="h:form" id="form">
            <h:messages/>
            <select id="paymentMethod" jsfc="h:selectOneRadio" value="#{testPaymentBean.paymentMethod}" immediate="true">
                <option jsfc="f:selectItem" itemValue="first" itemLabel="Pay with First Type"/>
                <option jsfc="f:selectItem" itemValue="second" itemLabel="Pay with Second Type"/>
                <f:ajax render="paymentPanel"/>
            </select>
            <h:panelGroup id="paymentPanel">
                <ui:include src="#{testPaymentBean.paymentPanel}"/>
            </h:panelGroup>
            <h:commandButton action="#{testPaymentBean.handlePayment}" value="Submit"/>
        </form>
    </ui:composition>The First Payment Type Form Fragment:
    <ui:composition>
        <h:panelGroup layout="block">
            <h:outputLabel for="amount" value="Enter Payment Amount: " />
            <h:inputText value="#{testPaymentBean.amount}">
                <f:validateLongRange minimum="0" />
            </h:inputText>
            <h:message for="amount"/>
            <br />
            <h:outputLabel for="holderName" value="Enter Account Holder Name: " />
            <h:inputText value="#{testPaymentBean.name}" />
            <h:message for="holderName"/>
            <br />
            <h:outputLabel for="accountNumber" value="Enter Account Number" />
            <h:inputText value="#{testPaymentBean.accountNumber}">
                <f:validateLongRange minimum="0" />
            </h:inputText>
            <h:message for="accountNumber"/>
        </h:panelGroup>
    </ui:composition>The Second Payment Type Form Fragment:
    <ui:composition>
        <h:panelGroup layout="block">
            <h:outputLabel for="amount" value="Enter Payment Amount: " />
            <h:inputText value="#{testPaymentBean.amount}">
                <f:validateLongRange minimum="0" />
            </h:inputText>
            <h:message for="amount"/>
            <br />
            <h:outputLabel for="holderName" value="Enter Account Holder Name: " />
            <h:inputText value="#{testPaymentBean.name}" />
            <h:message for="holderName"/>
            <br />
            <h:outputLabel for="accountNumber" value="Enter Account Number" />
            <h:inputText value="#{testPaymentBean.accountNumber}">
                <f:validateLongRange minimum="0" />
            </h:inputText>
            <h:panelGroup id="physicalAddrPanel" layout="block"
                          style="display: #{testPaymentBean.physicalAddressDisplayStyle}">
                <h:outputLabel for="addrFirstLine" value="Address Line 1: " />
                <h:inputText value="#{testPaymentBean.streetLineOne}" />
                <h:commandLink value="Use PO Box" immediate="true">
                    <f:ajax render="poBoxPanel physicalAddrPanel" />
                    <f:setPropertyActionListener value="display" target="#{testPaymentBean.poBoxDisplayStyle}"/>
                    <f:setPropertyActionListener value="none" target="#{testPaymentBean.physicalAddressDisplayStyle}"/>
                </h:commandLink>
                <h:message for="addrFirstLine"/>
                <br />
                <h:outputLabel for="addrSecondLine" value="Address Line 2: " />
                <h:inputText value="#{testPaymentBean.streetLineTwo}" />
                <h:message for="addrSecondLine"/>
                <br />
                <h:outputLabel for="addrThirdLine" value="Address Line 3: " />
                <h:inputText value="#{testPaymentBean.streetLineThree}" />
                <h:message for="addrThirdLine"/>
            </h:panelGroup>
            <h:panelGroup id="poBoxPanel" layout="block"
                          style="display: #{testPaymentBean.poBoxDisplayStyle}">
                <h:outputLabel for="poBox" value="PO Box Number: " />
                <h:inputText value="#{testPaymentBean.poBoxNumber}">
                    <f:validateLongRange minimum="0" />
                </h:inputText>
                <h:commandLink value="Use Physical Address" immediate="true">
                    <f:ajax render="poBoxPanel physicalAddrPanel" />
                    <f:setPropertyActionListener value="none" target="#{testPaymentBean.poBoxDisplayStyle}"/>
                    <f:setPropertyActionListener value="display" target="#{testPaymentBean.physicalAddressDisplayStyle}"/>
                </h:commandLink>
                <h:message for="poBox"/>
                <br />
                <h:outputLabel for="zipCode" value="Zip Code: " />
                <h:inputText maxlength="5" size="5" value="#{testPaymentBean.zipCode}">
                    <f:validateLongRange minimum="0" />
                    <f:validateLength minimum="5" />
                </h:inputText>
                <h:message for="zipCode"/>
            </h:panelGroup>
        </h:panelGroup>
    </ui:composition>The Backing Bean:
    import java.io.Serializable;
    import javax.faces.bean.ManagedBean;
    @ManagedBean()
    public class TestPaymentBean implements Serializable{
        private String paymentMethod;
        private String name;
        private double amount;
        private String accountNumber;
        private int poBoxNumber;
        private String streetLineOne;
        private String streetLineTwo;
        private String streetLineThree;
        private String zipCode;
        private String poBoxDisplayStyle;
        private String physicalAddressDisplayStyle;
        private boolean poBoxUsed;
        public TestPaymentBean(){
            paymentMethod = "first";
            poBoxDisplayStyle = "none";
            physicalAddressDisplayStyle = "display";
        public String getPaymentPanel() {
            if(paymentMethod.equalsIgnoreCase("second")){
                return "/sections/formfragments/testSecondPaymentContentPanel.xhtml";
            } else if(paymentMethod.equalsIgnoreCase("first")){
                return "/sections/formfragments/testFirstPaymentContentPanel.xhtml";
            return null;
        public String handlePayment(){
            if(paymentMethod.equalsIgnoreCase("second")){
                return handleSecondPayment();
            } else if(paymentMethod.equalsIgnoreCase("first")){
                return handleFirstPayment();
            return null;
        private String handleSecondPayment() {
            poBoxUsed = poBoxDisplayStyle.equalsIgnoreCase("display");
            return "testpaymentconfirmation";
        private String handleFirstPayment() {
            return "testpaymentconfirmation";
        public String handleSecondConfirm() {
            return "testpaymentsuccess";
        public String handleFirstConfirm() {
            return "testpaymentsuccess";
        //Getters and Setters
    }The Confirmation Page:
    <ui:composition>
        <form jsfc="h:form" id="form">
            <c:choose>
                <c:when test="#{fn:containsIgnoreCase(testPaymentBean.paymentMethod, 'first')}">
                    <ui:include src="/sections/formfragments/testFirstPaymentConfirmationContentPanel.xhtml"/>
                </c:when>
                <c:when test="#{fn:containsIgnoreCase(testPaymentBean.paymentMethod, 'second')}">
                    <ui:include src="/sections/formfragments/testSecondPaymentConfirmationContentPanel.xhtml"/>
                </c:when>
            </c:choose>
        </form>
    </ui:composition>

Maybe you are looking for

  • Messages.app shows phone numbers instead of names

    Can anyone help me configure Messages.app to show names instead of phone numbers (for iMessage/SMS)?  I'm running OS 10.10 Yosemite and my contacts are synced from iCloud.  Both my phone and mac are set to the same region and language. Thanks! G

  • Java.lang.InternalError: Can't connect to X11 window server using ':0.0'

    Hi all, I am getting the following error while running the JSP program. Actually we are running our applications in REMOTE LINUX SERVER (Redhat 7.0). Installed Softwares : jdk1.3.1_02 & Resin-2.1.0 500 Servlet Exception java.lang.InternalError: Can't

  • 5D Mark III Not Recognising CF Card in Slot 1.

    I recently inserted a CF card into slot 1, but the camera cannot see it or format it. I've tried two known, good, error free CF cards, but the camera just tells me they cannot be accessed and to change them or format them in camera. I've checked for

  • ? about "Lock Audio Clip at Playhead"

    I've always thought that the purpose of this feature is to make sure that audio and video clips that need to stay synced together in fact do. Well, I just added a short video clip to my timeline--in the middle of the movie--and it moved all the video

  • Email I just sent is gone and did not send!!!

    Just spent a half-hour typing an email on my iphone and after hitting the send button I never here the usual swoosh sound of my email being sent. So I look in the sent folder and nothing is there. This same thing has happened to me a couple times ove