-1

I want to submit following form via ajax. But when I submit it, it not get/ set value to char typed property. but when I changed password property in managed bean type as String it works. Why is that?

Form

<h:form>

        <h:inputText value="#{login.username}" id="username"
            a:placeholder="Username" />
        <br />

        <h:inputSecret a:placeholder="Password" id="password"
            value="#{login.password}" />
        <br />

        <h:inputText value="#{login.mvc}" />

        <h:commandButton value="Submit" >

            <f:ajax execute="@form" render="out" />
        </h:commandButton>
        <h:outputText id="out" />
    </h:form>

Managed Bean

@ManagedBean
public class Login {

    private String username;

    private char[] password;

    private String msg;

    private String mvc;

    @EJB
    private LoginService ls;

    public Login() {


    }



    public String getMvc() {
        return mvc;
    }



    public void setMvc(String mvc) {
        this.mvc = mvc;
    }



    public String getUsername() {
        System.out.println("getuser");
        return username;
    }



    public void setUsername(String username) {
        System.out.println("setuser");
        this.username = username;
    }

    public char[] getPassword() {
        System.out.println("getpass");

        return password;
    }



    public void setPassword(char[] password) {
        System.out.println("setpass");
        this.password = password;
    }



    public String getMsg() {
        return msg;
    }


}

No console log error shows and. when the data type password is String, console shows getuser setuser getpass setpass. When the data type is char it shows getuser getpass Why is that? char[] is not valid?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
top11
  • 13
  • 1
  • 7

1 Answers1

0

Please have a look on this link it clearly mentioned

  • Attribute Name :- value
  • Description :- The value attribute sets the current value for this component.
  • Type :- String

For more and detailed information you can check SO question related to <h:inputSecret />

Security: is there a way to use a straight reference to char[] instead of a String?

Community
  • 1
  • 1
Subodh Joshi
  • 12,717
  • 29
  • 108
  • 202