6

becomes empty automatically even if i keep value in the back bean for it. I have already set the value for password in inputsecret variable in the back bean in jsf2 than also the input secret is being shown empty.

deepmoteria
  • 2,279
  • 2
  • 19
  • 20

2 Answers2

11

This is indeed the default behaviour of <h:inputSecret> due to security reasons. You can get the value to redisplay anyway by setting the redisplay attribute to true.

<h:inputSecret value="#{bean.password}" redisplay="true" />

See also its view declaration language documentation (emphasis mine)

Encode Behavior

Render the clientId of the component as the value of the "name" attribute. Render the current value of the component as the value of the "value" attribute, if and only if the "redisplay" component attribute is the string "true". If the "styleClass" attribute is specified, render its value as the value of the "class" attribute.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
1

This is part of xhtml page:

<h:form>
    <h:inputSecret value="#{login.password}" />
</h:form>

This is backing bean:

@Component //Spring component
public class Login{
    private String password;
    public Login(){
       password="12341fsf"; //any value you want to set
    }
}

I tested this code it works fine

olyanren
  • 1,448
  • 4
  • 24
  • 42
  • Thanks for your reply but i am using the jsf managed bean, and it is not the case with it. Thanks again for reply – deepmoteria Dec 15 '11 at 06:07