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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:55:47+00:00 2026-05-12T06:55:47+00:00

My form validation works great, but the messages use the JSF component name and

  • 0

My form validation works great, but the messages use the JSF component name and not the field label. For instance, I have a field subject and the error message I get when it is empty is something along the lines of:

UIComponent:contactBean.firstName cannot be empty.

My Form:

<div class="field">
<s:decorate id="firstNameDecorate" template="edit.xhtml">
    <ui:define name="label">#{messages['user.firstName']}</ui:define>
    <h:inputText id="firstName" required="true" value="#{contactBean.firstName}">
        <a:support event="onblur" reRender="firstNameDecorate"/>
    </h:inputText>
</s:decorate>

My edit template:

<div class="entry">
    <s:label styleClass="label #{invalid?'errors':''}">
        <ui:insert name="label"/>
        <s:span styleClass="required" rendered="#{required}">*</s:span>
    </s:label>
    <span class="input #{invalid?'errors':''}">
        <s:validateAll>
            <ui:insert/>
        </s:validateAll>
    </span>
    <s:message styleClass="error errors"/>
</div>

The validation works just like I want, the error messages are configurable (at least the value to the right of the label it uses), and the validators are so easy to configure as they simple are annotations on the ContactBean class’ fields.

I would just like to polish it off and get the right values displayed there for instance:

First Name cannot be empty.

The last part is the ajax, onblur, doesn’t actually do anything. That is a minor issue that I would like to address at some point as well.

ContactBean.java

package com.walterjwhite.seamCore.model;

import java.io.Serializable;

import org.hibernate.validator.Email;
import org.hibernate.validator.NotEmpty;

import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;

@AutoCreate
@Name("com.walterjwhite.seamCore.model.contactBean")
public class ContactBean
    implements Serializable
{
    protected String firstName;
    protected String lastName;
    protected String emailAddress;
    protected String subject;
    protected String message;

    public String getFirstName()
    {
        return firstName;
    }

    public void setFirstName(String firstName)
    {
        this.firstName = firstName;
    }

    @NotEmpty
    public String getLastName()
    {
        return lastName;
    }

    public void setLastName(String lastName)
    {
        this.lastName = lastName;
    }

    @NotEmpty
    @Email
    public String getEmailAddress()
    {
        return emailAddress;
    }

    public void setEmailAddress(String emailAddress)
    {
        this.emailAddress = emailAddress;
    }

    @NotEmpty
    public String getSubject()
    {
        return subject;
    }

    public void setSubject(String subject)
    {
        this.subject = subject;
    }

    @NotEmpty
    public String getMessage()
    {
        return message;
    }

    public void setMessage(String message)
    {
        this.message = message;
    }
}

Thanks,

Walter

  • 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-12T06:55:47+00:00Added an answer on May 12, 2026 at 6:55 am

    It’s actually quite straightforward. All you have to do is to set the label attribute on the inputText component, like so:

    <h:inputText id="firstName" label="#{messages['user.firstName']}" required="true" value="#{contactBean.firstName}">
        <a:support event="onblur" reRender="firstNameDecorate"/>
    </h:inputText>
    

    This is what the JSF error message will use when displaying the message. The s:label tag just renders a label on the screen and does not set the label of the input component.

    I hope this helps.

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

Sidebar

Related Questions

I have some client-side JavaScript validation on a form. It works great. But I
I have a form element (see below). This works great but the default selected
I'm using Springs annotations based form validation (mainly @NotBlank and @Length) which works great.
I have a form that calls on two separate models. My validation works correctly
I have made a form validation using ajax post method. But i got the
The jQuery Validation plugin works great and is very easy to use: $(".selector").validate({ })
I have Google form that gets filled in by a few users. Works great
I have a very strange problem. The required validation inside a datatable works great
I have a modal window that works great, and a jquery form that validates
I have, in my admin interface, a form with a ImageField. Everything works great

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.