Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
Show / hide password using JSF / PrimeFaces is not working
          form i {
            margin-left: -25px;
            margin-top: 11px;
            cursor: pointer;
          }
             <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css" />

            <p:inputText id="productadminpassword" required="true"
                value="#{ApplicationManagedBean24.saveRequestMap['Object::MasterPassword']}"
                styleClass="inputField border" style="width:300px;"
                requiredMessage="Admin Password is mandatory"
                type="password">
                <p:ajax event="change" process="@this"
                    update="@([id$=Adminpasswordcheck]) @([id$=prodeletepassword])"
                    onstart="AdminpasswordMessageRemove();" />  
            </p:inputText>
            
         <i class="bi bi-eye-slash" id="togglePassword"></i>

         <script type="text/javascript">
const togglePassword = document.querySelector('#togglePassword');
const password = document.querySelector('#productadminpassword');

togglePassword.addEventListener('click', function () {
    const type = password.getAttribute('type') === 'password' ? 'text' : 'password';
    password.setAttribute('type', type);
    this.classList.toggle('bi-eye');
});
</script>

These are i have done. Eye(eye-slash) icon is rendered, but it is not working and input text also remains hidden. I also tried new toggle feature in password tag. Kindly help me out.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can simply use the PrimeFaces p:password component with the toggleMask attribute set to true. This attribute will add a show/hide icon to the password to allow the password to be unmasked/remasked. So:

<p:password value="#{bean.password}" toggleMask="true"/>

See the showcase for a demo https://www.primefaces.org/showcase/ui/input/password.xhtml

See also https://primefaces.github.io/primefaces/12_0_0/#/components/password

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!