www.webdeveloper.com
Results 1 to 2 of 2

Thread: jsf inputSecret

  1. #1
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898

    jsf inputSecret

    I have the following code for my password text box:

    Code:
    <h:inputSecret styleClass="inputSecret" id="password" required="true"><f:validateLength minimum="6" maximum="8"></f:validateLength></h:inputSecret>
    In my Login.java class, when I try to print out the value of password after submitting the page, it always comes back null. Here is my code for the Login.java class:

    Code:
    public class Login extends PageCodeBase {
    
    	protected HtmlScriptCollector scriptCollector1;
    	protected HtmlForm form1;
    	protected HtmlOutputText text2;
    	protected HtmlInputSecret password;
    	protected HtmlMessage message2;
    	protected HtmlCommandExButton submit;
    	protected UIParameter param1;
    	protected HtmlOutputText text1;
    	String userid;
    	protected HtmlMessage message1;
    	protected HtmlScriptCollector getScriptCollector1() {
    		if (scriptCollector1 == null) {
    			scriptCollector1 =
    				(HtmlScriptCollector) findComponentInRoot("scriptCollector1");
    		}
    		return scriptCollector1;
    	}
    	protected HtmlForm getForm1() {
    		if (form1 == null) {
    			form1 = (HtmlForm) findComponentInRoot("form1");
    		}
    		return form1;
    	}
    	protected HtmlOutputText getText2() {
    		if (text2 == null) {
    			text2 = (HtmlOutputText) findComponentInRoot("text2");
    		}
    		return text2;
    	}
    	protected HtmlInputSecret getPassword() {
    		if (password == null) {
    			password = (HtmlInputSecret) findComponentInRoot("password");
    		}
    		return password;
    	}
    	protected HtmlMessage getMessage2() {
    		if (message2 == null) {
    			message2 = (HtmlMessage) findComponentInRoot("message2");
    		}
    		return message2;
    	}
    	protected HtmlCommandExButton getSubmit() {
    		if (submit == null) {
    			submit = (HtmlCommandExButton) findComponentInRoot("submit");
    		}
    		return submit;
    	}
    	
    	protected HtmlOutputText getText1() {
    		if (text1 == null) {
    			text1 = (HtmlOutputText) findComponentInRoot("text1");
    		}
    		return text1;
    	}
    	public String getUserid() {
    		return userid;
    	}
    	public void setUserid(String newUserid)	{
    		userid = newUserid;
    	}
    	protected HtmlMessage getMessage1() {
    		if (message1 == null) {
    			message1 = (HtmlMessage) findComponentInRoot("message1");
    		}
    		return message1;
    	}
    	
    	public String doSubmitAction() {
    		System.out.println("Userid: "+userid);
    		System.out.println("Password: "+password);
    			// Type Java code to handle command event here
    			// Note, this code must return an object of type String (or null)
    			System.out.println("inside doSubmitAction");
    			if (userid.equals("xxx") && password.equals("xxx")) {
    				System.out.println("inside success");
    				return "success";
    			} else {
    				System.out.println("inside failure");
    				return "failure";
    			}
    		}
    }

  2. #2
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    got it working

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles