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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:05:13+00:00 2026-05-28T15:05:13+00:00

The question I am asking is probably a very simple one. I want to

  • 0

The question I am asking is probably a very simple one.
I want to display user details once the login is successfull.

My loginController

  public LoginController() {
}

public String getPassword() {
    return password;
}

public String getUsername() {
    return username;
}

public void setPassword(String password) {
    this.password = password;
}

public void setUsername(String username) {
    this.username = username;
}

public String isValidUser() {
    String isValid="Invalid user";
    EntityManager em = null;
    try {
        em = getEntityManager();
        Query query = em.createNamedQuery("ClientDetails.findByClientId");
        query.setParameter("clientId", username);
        //hashPassword(password);
        ClientDetails record = (ClientDetails) query.getSingleResult();
        System.out.print(record);
        String passwordHash=hashPassword(password);
        if (record.getPassword().equals(passwordHash)) {
             System.out.print("Valid user");
            isValid = "valid";
        } else {
            System.out.print("InValid user");
            isValid="invalid";
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        em.close();
    }
    System.out.println("Login status = " + isValid);
    return isValid;
}

private EntityManager getEntityManager() {
    return emf.createEntityManager();
}

public String hashPassword(String password) {
    String protectedPassword = null;
    try {
        System.out.println("password entered....." + password);
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        md5.update(password.getBytes());
        BigInteger hash = new BigInteger(1, md5.digest());
        protectedPassword = hash.toString(16);
        System.out.println("password hashed....." + protectedPassword);
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
    return protectedPassword;
}

I have EditController managed bean class

  @Resource
private UserTransaction utx = null;
@PersistenceUnit(unitName = "AdminPU")
private EntityManagerFactory emf = null;
private ClientDetails clientDetails;
private ClientWebsiteDetails clientWebsiteDetails;

@ManagedProperty(value="#{loginController}")
private LoginController login;

   private Boolean booleanFacebook;
    private Boolean booleanTwitter;
    private Boolean booleanClientSocial;

public EditAccountController() {
}

public Boolean getBooleanClientSocial() {
    return booleanClientSocial;
}

public Boolean getBooleanFacebook() {
    return booleanFacebook;
}

public Boolean getBooleanTwitter() {
    return booleanTwitter;
}

public void setBooleanClientSocial(Boolean booleanClientSocial) {
    this.booleanClientSocial = booleanClientSocial;
}

public void setBooleanFacebook(Boolean booleanFacebook) {
    this.booleanFacebook = booleanFacebook;
}

public void setBooleanTwitter(Boolean booleanTwitter) {
    this.booleanTwitter = booleanTwitter;
}

public ClientDetails getClientDetails() {
    if (clientDetails == null) {
        clientDetails = new ClientDetails();
    }
    return clientDetails;
}

public ClientWebsiteDetails getClientWebsiteDetails() {
    if (clientWebsiteDetails == null) {
        clientWebsiteDetails = new ClientWebsiteDetails();
    }
    return clientWebsiteDetails;
}

public LoginController getLogin() {
    return login;
}

public void setLogin(LoginController login) {
    this.login = login;
}

  public String getAccountDetails() {
    String result = "Details not saved";
    EntityManager em = null;
    try {
        System.out.println("Retreiving client details");
        utx.begin();
        em = getEntityManager();
        clientDetails.setClientId(login.getUsername());
        Query customerDetails = em.createQuery("ClientDetails.findByClientId");
        Query websiteDetails = em.createQuery("ClientWebsiteDetails.findByClientAccountId");
        List customerList = customerDetails.getResultList();
        List websiteList = websiteDetails.getResultList();
        Iterator clientIt = customerList.iterator();
        Iterator websiteIt = websiteList.iterator();
        while (clientIt.hasNext()) {
            clientDetails = (ClientDetails) clientIt.next();
            clientDetails.setPrimaryContactName(clientDetails.getPrimaryContactName());
            clientDetails.setCompany(clientDetails.getCompany());
            clientDetails.setPrimaryEmailId(clientDetails.getPrimaryEmailId());
            clientDetails.setPrimaryContactNo(clientDetails.getPrimaryContactNo());
            clientDetails.setPrimaryDesignation(clientDetails.getPrimaryDesignation());
        }
        while (websiteIt.hasNext()) {
            clientWebsiteDetails = (ClientWebsiteDetails) websiteIt.next();
            clientWebsiteDetails.setProductionUrl(clientWebsiteDetails.getProductionUrl());
            clientWebsiteDetails.setSiteName(clientWebsiteDetails.getSiteName());
            clientWebsiteDetails.setDescription(clientWebsiteDetails.getDescription());
            clientWebsiteDetails.setFacebook(clientWebsiteDetails.getFacebook());
            clientWebsiteDetails.setTwitter(clientWebsiteDetails.getTwitter());
            clientWebsiteDetails.setClientSocial(clientWebsiteDetails.getClientSocial());
        }

        if ((clientWebsiteDetails.getFacebook().equals("y")) && (clientWebsiteDetails.getTwitter().equals("y"))) {
            booleanFacebook = true;
            booleanTwitter = true;
        booleanClientSocial = false;
    } else if ((clientWebsiteDetails.getFacebook().equals("n")) && (clientWebsiteDetails.getTwitter().equals("n") && (clientWebsiteDetails.getClientSocial().equals("n")))) {
        booleanFacebook = false;
        booleanTwitter = false;
        booleanClientSocial = false;
    }
    System.out.print(utx.getStatus());
    utx.commit();
} catch (Exception e) {
    e.printStackTrace();
}
return result;

}

editaccount.xhtml

<h:form id="RegisterForm">
      <h:commandLink value="Logout" action=""></h:commandLink>
         <h:commandLink value="Change Password" action=""></h:commandLink>
      <h:outputLabel value=""></h:outputLabel>
        <h:panelGrid>
            <h1>Customer Information</h1>
            <h:outputLabel value="Name:" for="name" />
            <h:inputText id="name" required="true" requiredMessage="Please enter your name"  value="#{editAccountController.clientDetails.primaryContactName}">
                <f:validateLength maximum="50"></f:validateLength>
            </h:inputText>
            <h:message for="name"></h:message>

            <h:outputLabel value="Company:" for="company" />
            <h:inputText id="company" required="true" requiredMessage="Please enter your company" value="#{editAccountController.clientDetails.company}">
                <f:validateLength maximum="50"></f:validateLength>
            </h:inputText>
            <h:message for="company"></h:message>

            <h:outputLabel value="Designation:" for="designation" />
            <h:inputText id="designation" required="true"  requiredMessage="Please enter your designation" value="#{editAccountController.clientDetails.primaryDesignation}">
                <f:validateLength maximum="50"></f:validateLength>
            </h:inputText>
            <h:message for="designation"></h:message>

            <h:outputLabel value="Email Id:" for="email" />
            <h:inputText id="email" required="true" requiredMessage="Please enter your email, eg:yourid@domain.com"  value="#{editAccountController.clientDetails.primaryEmailId}">
                <f:validateLength maximum="70"></f:validateLength>
            </h:inputText>
            <h:message for="email"></h:message>

            <h:outputLabel value="Contact No:" for="phone" />
            <h:inputText id="phone" required="true" requiredMessage="Please enter your contact number" value="#{editAccountController.clientDetails.primaryContactNo}">
                <f:validateLength minimum="10" maximum="25"></f:validateLength>
            </h:inputText>
            <h:message for="phone"></h:message>  


            <h2>Website Information</h2>
            <h:outputLabel value="Domain:" for="production_url" />
            <h:inputText id="production_url" required="true" requiredMessage="Please enter domain name,eg:www.domain.com OR yourip/app_name"  value="#{editAccountController.clientWebsiteDetails.productionUrl}">
                <f:validateLength maximum="50"></f:validateLength>
            </h:inputText>
            <h:message for="production_url"></h:message>

            <h:outputLabel value="Site Name:" for="site_name" />
            <h:inputText id="site_name" required="true" requiredMessage="Please enter website name"  value="#{editAccountController.clientWebsiteDetails.siteName}">
                <f:validateLength maximum="255"></f:validateLength>
            </h:inputText>
            <h:message for="site_name"></h:message>

            <h:outputLabel value="Description:" for="description" />
            <h:inputTextarea id="description" rows="2" cols="40" requiredMessage="Please enter website description" value="#{editAccountController.clientWebsiteDetails.description}" title="Description about the website in few lines" required="required">
                <f:validateLength maximum="250"></f:validateLength>
            </h:inputTextarea>
            <h:message for="description"></h:message>



            <h3>Social Integration</h3>
            <h:outputLabel for="fb" value="Facebook:"></h:outputLabel>
            <h:selectBooleanCheckbox id="fb" value="#{editAccountController.booleanFacebook}" title="Select to integrate our Facebook app in your site">
            </h:selectBooleanCheckbox>
            <h:outputLabel for="tweet" value="Twitter:"></h:outputLabel>
            <h:selectBooleanCheckbox id="tweet" value="#{editAccountController.booleanTwitter}" title="Select to integrate our Twitter app in your site"></h:selectBooleanCheckbox>
            <h:outputLabel for="your_app" value="Integrate your social app with BazaAR:"></h:outputLabel>
            <h:selectBooleanCheckbox id="your_app" value="#{editAccountController.booleanClientSocial}" title="Select to integrate your social apps"></h:selectBooleanCheckbox>

            <h:commandButton value="Register" type="submit" action="#{editAccountController.saveAccountDetails}"></h:commandButton>

        </h:panelGrid>
    </h:form>

Both are Managed beans and are in session scope. The app is Java EE 5.

I need the username entered by user in my editController. I figure I am using the ManageProperty wrong. Can you guys point out how do I use the ManageProperty so I can get the value if username set to my email field in my ClientDetails POJO.

  • 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-28T15:05:14+00:00Added an answer on May 28, 2026 at 3:05 pm

    You need to put an EL-Expression into the ManagedProperty:

    @ManagedProperty(value="#{loginController}")
    

    Make sure that the name is right. And that the LoginController has the right annotations.

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

Sidebar

Related Questions

Apologies for asking what's probably a very obvious question, I've been banging my head
My question is probably very simple but it could also be the case that
Apologies or asking what is probably a very straightforward question, but I'm new to
I want to use to implement only REST service - a very simple one
I'm probably asking a very elementary Xcode question, but here it goes. My layout
back = $(#contactus_+id).prev(); I'm probably asking a simple question, but how do I get
I'm probably asking the question badly, so I'm going to give an example. I
So I wrote this simple console app to aid in my question asking. What
I apologise for asking a question that's probably been asked hundreds of times before,
The first question your probably asking is how many Group by / Order by

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.