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 6360461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:39:08+00:00 2026-05-24T23:39:08+00:00

I have a bean with a field called ‘name’, and a JSF form that

  • 0

I have a bean with a field called ‘name’, and a JSF form that has an inputText mapped with this field. The initial value of the field is well displayed on the form.

The problem is when I submit the form, the value is not updated with the content of the inputText. In the savePlayer() method below, the value of name is always ‘name’, not what I typed inside the form input.

The bean :

@Named
@RequestScoped
public class PlayerForm {

    @Inject
    private PlayerRepository playerRepository;

    private String name = "name";


    public String savePlayer(){
        Player player = new Player();
        player.setName(name);
        playerRepository.savePlayer(player);
        return "saveUserOk";
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
}

The form :

   <h:form>
        <h:inputText value="#{playerForm.name}" />
        <h:commandButton value="Submit" action="#{playerForm.savePlayer}" />
    </h:form>

Thanks very much for any help!

  • 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-24T23:39:09+00:00Added an answer on May 24, 2026 at 11:39 pm

    This can happen if you imported @RequestScoped from the package javax.faces.bean (JSF) instead of from javax.enterprise.context (CDI). Every single EL expression #{} would then create a brand new and completely separate instance of the bean. The given form example would then end up in two instances of the bean, one where the name is set and another where the action is invoked.

    The javax.faces.bean.RequestScoped annotation can only be used in conjunction with JSF’s own @ManagedBean annotation not with CDI’s @Named annotation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to JSF, so this question might be strange. I have an inputText
I have a configuration bean that has a list of allowed values: @Component public
I have this bean @XmlRootElement class Test { boolean someValue; List<Field> fields; } I
I have a boolean field called showLabels in a Bean class, and I want
I have a bean of type string[] which has two or more values. I
I've experienced rather strange behavior of JSTL forEach tag. I have some bean called
I have a MDB (Message driven bean) that receives messages with String which represent
When we say we have declared our form bean in session scope, few questions
I have an EJB3 stateless session bean that uses some other ejbs to do
I have this function in my Javascript Code that updates html fields with their

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.