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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:22:42+00:00 2026-05-26T20:22:42+00:00

I have a custom converter which is this : @ManagedBean @RequestScoped public class MeasureConverter

  • 0

I have a custom converter which is this :

@ManagedBean
@RequestScoped
public class MeasureConverter implements Converter {

    @EJB
    private EaoMeasure eaoMeasure;

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        if (!(value instanceof Measure) || ((Measure) value).getId() == null) {
            return null;
        }

        return String.valueOf(((Measure) value).getId());
    }

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {

        if (value == null || !value.matches("\\d+")) {
            return null;
        }

        Measure measure = eaoMeasure.find(Integer.valueOf(value));

        if (measure == null) {
            throw new ConverterException(new FacesMessage("Unknown Measure ID: " + value));
        }

        return measure;
    }

But I would like to validate this as I’m doing with the other fields, just like this for example :

<h:outputLabel for="name" value="Name:" />
<h:inputText id="name" value="#{bean.name}">
<f:ajax event="blur" listener="#{validator.name}" render="m_name" />
</h:inputText>
<rich:message id="m_name" for="name" ajaxRendered="false" />

So when the blur event occurs an icon appears indicating if the selection in correct or not (the code above do this what I’m talking )

But I want to apply this kind of validation in this same custom converter, just to keep the standard validation through my project to the all kinds of inputs or sorts of.

I already try to use a @ManagaProperty in a RequestScope but without success:

@ManagedProperty("#{param.measure}")
private String measure;

So when the blur events occurs it calls my validate bean which has the requestScope as BalusC said here, but what it comes is a empty string.

Any idea ?

  • 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-26T20:22:42+00:00Added an answer on May 26, 2026 at 8:22 pm

    You should implement a Validator.

    E.g.

    @FacesValidator("measureValidator")
    public class MeasureValidator implements Validator {
    
        @Override
        public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
            Measure measure = (Measure) value;
    
            // ...
    
            if (!valid) { 
                throw new ValidatorException(new FacesMessage("Not valid"));
            }
        }
    
    }
    

    You can declare it by the input component’s validator attribute

    <h:inputText validator="measureValidator">
    

    or by the <f:validator> tag (yes, you can have multiple of them; they will be invoked in the order they are been attached to the component)

    <h:inputText>
        <f:validator validatorId="measureValidator" />
    </h:inputText>
    

    The converter is not relevant here. It has already done its job of converting String to Measure. The validator will just retrieve the Measure. The @ManagedProperty which you’ve there will also not work that way. It will basically set the property with result of request.getParameter("measure") and I don’t think that there’s such a parameter submitted by your form.

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

Sidebar

Related Questions

I have a command object: public class Job { private String jobType; private String
I have this legacy database for which I'm building a custom viewer using Linq
I have made my own custom converter which given a string returns a Brush
I have a custom Fraction class, which I'm using throughout my whole project. It's
I have an array of custom objects. MyCustomArr[]. I want to convert this to
hi i would like to create a custom calendar, this calendar will have custom
I have a custom list which I want to embed as a resource so
I have a legacy class, with a lot of public double fields. All double
I'm trying to create a custom control - a button - which will have
I have created a custom MultiValue Converter to perform a bit of logic while

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.