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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:32:09+00:00 2026-05-27T15:32:09+00:00

When or where do entities get created? Do they get created when the XHTML

  • 0

When or where do entities get created?
Do they get created when the XHTML page loads and accesses the entities via the managed bean?
Or do they get automatically created in the managed bean?
Do we need to manually create it from the managed bean’s constructor?

Please see the code below (some necessary code might not have been copied.)

The entity would be:

public class PersonalInfo implements Serializable {
    @Size(max = 50)
    @Column(name = "FIRST_NAME", length = 50)
    private String firstName;

    // some getters and setters
}

the web page would be:

<h:form>
    <h:outputText value="first name"/> 
    <h:inputText value="#{personalInforController.personalInfo.firstName}" />

    <h:commandButton value="hit me" 
        action="#{personalInforController.create}" 
        immediate="true"/>
</h:form>

and the backing bean would be:

@Named(value = "personalInfoController")
@SessionScoped
public class PersonalInforController {
    @EJB
    PersonalInfoFacade ejbFacade;
    PersonalInfo personalInfo;
    String defaultPage = "index";

    public String create() {
        try {
            ejbFacade.create(personalInfo);
            return "prepareCreate";
        } catch (Exception e) {
            return "success";
        }
    }
}
  • 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-27T15:32:09+00:00Added an answer on May 27, 2026 at 3:32 pm

    In the example code given, the create action indeed doesn’t seem to be able to work. The entity must be created by the backing bean before that.

    If it’s a simple entity, either the constructor or an @PostConstruct method would work. For instance:

    @Named(value = "personalInfoController")
    @SessionScoped
    public class PersonalInforController {
    
        @EJB
        PersonalInfoFacade ejbFacade;
        PersonalInfo personalInfo;
        String defaultPage = "index";
    
        @PostConstruct
        public void init() {
            personalInfo = new PersonalInfo();
        }
    
        public String create() {
        try {
            ejbFacade.create(personalInfo);
            return "prepareCreate";
        } catch (Exception e) {
            return "success";
        }
    }
    

    Some notes about the code. It’s highly suspicious, and most likely plain wrong, to declare your bean to be @SessionScoped. If personalInfo is being edited in two tabs or windows you’ll be in a world of hurt. I suggest making your bean @ViewScoped (for CDI, there’s a separate extension made by the Seam3 that enables this, if you can’t/won’t use this extension consider using @ManagedBean instead of @Named).

    Also, you might want to declare your instance variables to be private and give ejbFacade a better name (e.g. personalInfoFacade). I also doubt whether immediate is necessary on the commandButton, and since the outputText is obviously a label for the given inputText, you might want to consider using outputLabel and the for attribute.

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

Sidebar

Related Questions

I sent a text via GET method to decode html entities ( &#119; =
I have a question concerning Core Data and how, if at all, Entities get
I have two entities: public class Parent() { public ICollection<Child> Children { get; set;
I've been wrecking my mind on how to get my tagging of entities to
I have two entities. User and Role. I am using Devise and CanCan. They
I'm using FreeTextBox editor to get some HTML created by users. The problem with
Names of entities have been altered to protect their identities... I've created a class
I created a generic repository that handles querying my entities. When I call this:
I'm using Prism so I can create a modular solution. I need to access
I have a scenario where I create Machine entities that are associated with the

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.