Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3237802
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:46:51+00:00 2026-05-17T17:46:51+00:00

I don’t really understand why this simple stuff won’t work. I can see that

  • 0

I don’t really understand why this simple stuff won’t work. I can see that I set the constructor is called everytime one property is set. The problem is that when I reach the sendInvitation method then all inviteEmails is null.

@Named(value = "adminBean")
@RequestScoped
public class AdminBean implements Serializable {

    private String inviteEmail1;
    private String inviteEmail2;
    private String inviteEmail3;
    private BasicUser administrator;
    @EJB
    private MessageBeanRemote messageBean3;

    /** Creates a new instance of AdminBean */
    public AdminBean() {
        HttpSession session = (HttpSession) FacesContext.getCurrentInstance().
                getExternalContext().getSession(true);
        LoginBean loginBean = (LoginBean) session.getAttribute("loginBean");
        administrator = loginBean.getUser();
    }

    public String getInviteEmail1() {
        return inviteEmail1;
    }

    public void setInviteEmail1(String inviteEmail) {
        this.inviteEmail1 = inviteEmail;
    }

    public String getInviteEmail2() {
        return inviteEmail2;
    }

    public void setInviteEmail2(String inviteEmail) {
        this.inviteEmail2 = inviteEmail;
    }

    public String getInviteEmail3() {
        return inviteEmail3;
    }

    public void setInviteEmail3(String inviteEmail) {
        this.inviteEmail3 = inviteEmail;
    }

    public void sendInvitations() { 
    ...
    }
}

The page which is using this bean is a component that is is part of another page:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <ui:component id="adminComp">
        <h3>Adminstration page</h3>
        <h:form id="inviteForm">
            <h:panelGrid columns="1">
                Invite new members to your group. Type in their emails in the fields below.
                <h:inputText id="email1" value="#{adminBean.inviteEmail1}" size="40"/>
                <h:inputText id="email2" value="#{adminBean.inviteEmail2}" size="40"/>
                <h:inputText id="email3" value="#{adminBean.inviteEmail3}" size="40"/>
                <h:commandButton value="invite" action="#{adminBean.sendInvitations}"/>
            </h:panelGrid>
        </h:form>
    </ui:component>


</html>

The adminBean is actually initialized many times and it looks kind of weird. “Constructor” is the adminBean constructor, “Get 1” is getInviteEmail1 and so on.

INFO: START PHASE RESTORE_VIEW 1
INFO: END PHASE RESTORE_VIEW 1
INFO: START PHASE APPLY_REQUEST_VALUES 2
INFO: END PHASE APPLY_REQUEST_VALUES 2
INFO: START PHASE PROCESS_VALIDATIONS 3
INFO: Constructor
INFO: Constructor
INFO: Constructor
INFO: Constructor
INFO: Constructor
INFO: Constructor
INFO: Get 2
INFO: Constructor
INFO: Constructor
INFO: Constructor
INFO: Get 3
INFO: END PHASE PROCESS_VALIDATIONS 3
INFO: START PHASE UPDATE_MODEL_VALUES 4
INFO: Constructor
INFO: Set 1
INFO: Constructor
INFO: Set 2
INFO: Constructor
INFO: Set 3
INFO: END PHASE UPDATE_MODEL_VALUES 4
INFO: START PHASE INVOKE_APPLICATION 5
INFO: Constructor
SEVERE: NullPointerException....
INFO: END PHASE INVOKE_APPLICATION 5
INFO: START PHASE RENDER_RESPONSE 6
INFO: Constructor
INFO: Constructor
INFO: Get 2
INFO: Constructor
INFO: Get 3
INFO: END PHASE RENDER_RESPONSE 6

Any help is appriciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:46:52+00:00Added an answer on May 17, 2026 at 5:46 pm

    I don’t know what that @Named thing is doing there, but it is not normal that the bean is constructed everytime it is been accessed by a value expression. It should be constructed only once in beginning of the HTTP request. Probably the configuration behind @Named is been wrong.

    Try just declaring the bean the JSF way using @ManagedBean and ensure that @RequestScoped is also from the javax.faces.bean package.

    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.RequestScoped;
    
    @ManagedBean
    @RequestScoped
    public class AdminBean implements Serializable {
        // ...
    }
    

    Apart from the problem, your way of obtaining the session scoped bean is not recommended. The normal JSF way would be the following:

    @ManagedProperty(value="#{loginBean}")
    private LoginBean loginBean;
    

    if necessary with the following getter

    public BasicUser getAdministrator() {
        return loginBean.getUser();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't know why this doesn't work. I can't do implicit animation for a newly
Don't quite understand why this copy constructor is not invoked when I build with
(Don't know if this is strictly on-topic, but I don't see any better Stack
Don't think that I'm mad, I understand how php works! That being said. I
Don't know if anyone can help me with this or if it's even possible.
Don't understand, if Data.Map is and [] is. I found this out while wondering
I don't get to see the source code but the .class file. Can I
Don't ask me why but i can't use this method because I need to
Don't know why but I can't find a solution to this. I have 3
Don't know if there is a better way to do this, so that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.