Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Cannot set class fields using textInput

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Thanked 0 Times in 0 Posts

    Default Cannot set class fields using textInput

    when the validation function for a user's login runs, the username and password fields are null. i have written the code according to many examples that i have seen on the internet. please help me understand why these fields are not being set.

    also, when i run this app in a browser, the fields literally say #{Login.username}, and #{Login.password} instead of being blank like in other people's examples and tutorials. i assume it is a symptom of the problem here.

    thanks in advance
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-name>Faces Servlet</servlet-name>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
                <title>JSP Page</title>
                            <td><h:outputText value="Username: "/></td>
                            <td><h:inputText id="username" required="true" value="#{Login.username}" /></td>
                            <td><h:outputText value="Password: "/></td>
                            <td><h:inputText id="password" required="true" value="#{Login.password}"/></td>
                            <td><h:commandButton value="login" action="#{Login.ValidateLogin}"/></td>
    package Security;
    public class Login {
        private String username;
        private String password;
        public Login() {} // Inline Constructor for Login class
        public void setUsername(String username) { this.username = username; }
        public void setPassword(String password) { this.password = password; }
        public String ValidateLogin() {
            if("ianmcdavid".equals(username) && "cole".equals(password)) {
                return "success";
            else {
                return "failure";
    Last edited by copeg; August 26th, 2010 at 08:49 AM. Reason: Please use the code tags

Similar Threads

  1. Replies: 0
    Last Post: April 11th, 2010, 08:56 AM
  2. problem with data access when a class call another class
    By ea09530 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 4th, 2010, 05:20 PM
  3. Putting text fields in an array
    By Movies32 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 10th, 2010, 07:46 PM
  4. Validating fields in a js shopping cart
    By rockc in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 10th, 2010, 03:37 PM
  5. Static fields and inheritance
    By helloworld922 in forum Java Programming Tutorials
    Replies: 1
    Last Post: January 22nd, 2010, 04:02 AM