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

  • Home
  • SEARCH
  • 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 9071745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:59:24+00:00 2026-06-16T17:59:24+00:00

I’m currently encountering the problem specified above when trying to add a converter and

  • 0

I’m currently encountering the problem specified above when trying to add a converter and a validator to a single field. I know how these 2 works because I’ve used them before, but this is the first time I’ve tried both of them on a single field. Here are my codes:

<p:selectOneMenu id="bussProgram"
    value="#{signupWizardBean.subscription.businessProgram}">
    <f:converter binding="#{membershipProgramConverter}"></f:converter>
    <f:validator binding="#{dropdownValidator}"></f:validator>
    <f:selectItems value="#{signupWizardBean.membershipPrograms}"
        var="plan" itemValue="#{plan}"
        itemLabel="#{plan.description}" />
</p:selectOneMenu>

Converter

@Named
@ApplicationScoped
public class MembershipProgramConverter implements Converter {
    @PersistenceContext
    private transient EntityManager em;

    @Inject
    private Logger log;

    @Override
    public Object getAsObject(FacesContext ctx, UIComponent component,
        String value) {
    if (StringUtils.isBlank(value) || value.equals("0"))
        return null;

    return em.find(MembershipProgram.class, new Long(value));
}

    @Override
    public String getAsString(FacesContext fc, UIComponent uic, Object o) {
        MembershipProgram mp = (MembershipProgram) value;
    return mp.getId() != null ? String.valueOf(mp.getId()) : null;
    }
}

Validator:

@Named
@ApplicationScoped
public class DropdownValidator implements Validator, Serializable {
    private static final long serialVersionUID = -456545939475878299L;

    @Inject
    private ResourceBundle bundle;

    @Inject
    private FacesContext facesContext;

    @Inject
    private Logger log;

    @Override
    public void validate(FacesContext context, UIComponent component,
        Object value) throws ValidatorException {
    log.debug("[dropship-web] validating value={}", value);
    if (value == null) {
        FacesMessage msg = new FacesMessage(
                bundle.getString("error.requiredField"),
                bundle.getString("error.requiredField"));
        msg.setSeverity(FacesMessage.SEVERITY_ERROR);
        facesContext.addMessage("promoCode", msg);

        throw new ValidatorException(msg);
    }
}
}

Entity Class:

@Entity
@Table(name = "CRM_MEMBERSHIP_PROGRAMS", uniqueConstraints = @UniqueConstraint(columnNames = { "code" }))
@SequenceGenerator(name = "ID_GENERATOR", sequenceName = "CRM_MEMBERSHIP_PROGRAM_SEQ")
public class MembershipProgram extends BaseEntity {
    private static final long serialVersionUID = -7796298586810386239L;

    @Size(max = 25)
    @Column(name = "CODE", nullable = false)
    private String code;

    @Size(max = 100)
    @Column(name = "DESCRIPTION", nullable = true)
    private String description;

    public MembershipProgram() {

    }

    public MembershipProgram(long id, String description) {
        setId(id);
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = super.hashCode();
        result = prime * result + ((code == null) ? 0 : code.hashCode());
        result = prime * result
                + ((description == null) ? 0 : description.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (!super.equals(obj))
            return false;
        if (getClass() != obj.getClass())
            return false;
        MembershipProgram other = (MembershipProgram) obj;
        if (code == null) {
            if (other.code != null)
                return false;
        } else if (!code.equals(other.code))
            return false;
        if (description == null) {
            if (other.description != null)
                return false;
        } else if (!description.equals(other.description))
            return false;
        return true;
    }
}

Note that on debug: both the MembershipProgramConverter.getAsObject/getAsString, DropdownValidator.validate methods are called.

I also found out that with or without selected item from the dropdown list, I’m encountering:

.validation.UnexpectedTypeException: HV000030: No validator could be found for type: com.czetsuya.models.membership.MembershipProgram.
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: com.czetsuya.models.membership.MembershipProgram.
  • 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-16T17:59:26+00:00Added an answer on June 16, 2026 at 5:59 pm

    Finally I was able to figure out the problem, I’ve added @Size annotation on the target entity, just removed the @Size:

    @Size(max = 25)
    @OneToOne(optional = false)
    @JoinColumn(name = "BUSINESS_PROGRAM", nullable = false)
    private MembershipProgram businessProgram;
    

    When I removed the @Size, the problem was solved but I have encountered a new one, on submit it the form always throw:

    Validation Error: Value is not valid
    

    To fixed the Value is not valid, make sure that you have properly implemented Model.equals method. My fault was that I rely on eclipse generate hashcode and equals feature, I failed to notice that it calls the equals method from my BaseEntity.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was

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.