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 8221037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:45:41+00:00 2026-06-07T13:45:41+00:00

In JSF, how can I invoke method in case of conversion failing on any

  • 0

In JSF, how can I invoke method in case of conversion failing on any of input fields? I guess I can write my own converters and do all the stuff there, but isn’t there a more simple way?

  • 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-06-07T13:45:43+00:00Added an answer on June 7, 2026 at 1:45 pm

    You could use a PreRenderViewEvent listener, and in that method check if validation has failed. This listener method will be called every time just before the view is rendered.

    E.g.

    Consider the following Facelet:

    <html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
    >
        <h:body>
    
            <h:messages/>
    
            <f:event listener="#{onErrorBean.onPreRenderView}" type="preRenderView" />
    
            <h:form>
                <h:inputText value="#{onErrorBean.test}" label="test" required="true" />
    
                <h:commandButton value="Submit" action="#{onErrorBean.onSuccess}" />
            </h:form>
    
        </h:body>
    </html>
    

    And the following backing bean:

    @ViewScoped
    @ManagedBean
    public class OnErrorBean {
    
        private String test;
    
        public void onPreRenderView() {
            if (FacesContext.getCurrentInstance().isValidationFailed()) {
                onError();
            }
        }
    
        public void onSuccess() {
            System.out.println("Success!");
        }
    
        public void onError() {
            System.out.println("Error!");
        }
    
        public String getTest() {
            return test;
        }
    
        public void setTest(String test) {
            this.test = test;
        }
    
    }
    

    If you press the button without entering a value you’ll see “Error!” being printed in your console, enter a value and you’ll see “Success!”.

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

Sidebar

Related Questions

I'm using JSF2 and PrimeFaces3. How can I write selectOneMenu that would invoke JSF
Is there any way in JSF which can be used to find out whether
Can I rerender a jsf ui component when a valuechangelistener method is run? The
Can any one list out the tips to tune JSF WebApp @ its best.
How can I in JSF 2.0 invoke direct methods or methods with arguments /
Core JavaServer Faces Third Edition mentions a case where JSF can go from the
Is there any tag in JSF which can be used to assign some id
Is it possible to invoke a method where property is expected in JSF 2.0
JSF can validate the input values. Can anybody say where JSF validates..?
In JSF 2 you can pass around ids, Strings other things that can be

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.