Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6987101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:53:36+00:00 2026-05-27T18:53:36+00:00

I use a facelets login form for Spring Security: <h:messages globalOnly=true layout=table /> <h:form

  • 0

I use a facelets login form for Spring Security:

<h:messages globalOnly="true" layout="table" />
<h:form id="formLogin" prependId="false">
        <h:outputLabel for="j_username" value="Usuario:" />
        <h:inputText id="j_username" value="#{autenticacionController.administrador.login}" />
        <h:outputLabel for="j_password" value="Contraseña:" />
        <h:inputSecret id="j_password" value="#{autenticacionController.administrador.password}" />
        <h:commandButton value="Entrar" action="#{autenticacionController.loginAction}" />
        <h:commandButton value="Cancelar" immediate="true" action="#{autenticacionController.cancelarAction}" />
</h:form>`

The loginAction method forwards the request with this:

FacesContext.getCurrentInstance().getExternalContext().dispatch("/j_spring_security_check")

It works fine, but how can I show a facesmessage in my h:messages tag if the BadCredentials exception is thrown by Spring Security?

I know it can be done with a phase listener, but I don’t like that way (dealing with exceptions in listeners).

I’m trying another way, configuring Spring Security like this:

authentication-failure-url="/faces/paginas/autenticacion/login.xhtml?error=1

And then in the login page, catch the GET param “error”. But how can I show the facesmessage in this way?

Another way I tried was to override the messages properties file of Spring Security (overriding the message for the key “badcredentials”), but it didn’t work neither (I didn’t know how to show the message).

Anyone know how to do it?

Thank you very much in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:53:37+00:00Added an answer on May 27, 2026 at 6:53 pm

    And then in the login page, catch the GET param “error”. But how can I show the facesmessage in this way?

    This way:

    <f:metadata>
        <f:viewParam name="error" validator="#{auth.checkErrors}" />
    </f:metadata>
    <h:messages />
    

    with

    public void checkErrors(FacesContext context, UIComponent component, Object value) {
        if ("1".equals(value)) {
            throw new ValidatorException(new FacesMessage("Invalid credentials"));
        }
    }
    

    or maybe so:

    <f:metadata>
        <f:viewParam name="error" value="#{auth.error}" />
        <f:event type="preRenderView" listener="#{auth.checkErrors}" />
    </f:metadata>
    <h:messages />
    

    with

    private int error;
    
    public void checkErrors() {
        if (error == 1) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Invalid credentials"));
        }
    }
    

    Either way, this feels pretty hacky 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to use The Spring Security Facelets tag library to secure my UI
I use JSF 2.0 and facelets. I want to login check at each page
since I know I can't use the Spring tag library in Facelets, I wonder
I would like to use JavaScript to manipulate hidden input fields in a JSF/Facelets
Is it possible to use Facelets pages and .jsp style ICEfaces pages in the
I have a problem applying css to the web pages, using spring security (3.0.7
I try to create login form in web application. in JSP page I can
I want to use Facelets to build a static HTML prototype. This prototype will
I'm creating a JSF/Facelets web app in Eclipse. I've configured my project to use
In my JSF/Facelets app, here's a simplified version of part of my form: <h:form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.