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

The Archive Base Latest Questions

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

My least favorite part of coding JSF 2.0 forms has to do with the

  • 0

My least favorite part of coding JSF 2.0 forms has to do with the handing of the id attributes of the various input elements. I am forever having trouble coding the clientID of the target component from within the backing bean, particularly since PrimeFaces tabView now includes the id of the p:tab element as part of the clientID. I waste tons of time coding, testing, then re-coding those clientIDs.

It is reminiscent of older-style assembly language programming where you have to generate tons of label names for your branches and loops. I’ve done of enough of that for a lifetime.

One approach I am trying is to use only auto-generated id attributes. For example one line of my form might look like this.

<h:outputLabel value="Full Name:" />
<p:inputText value="#{editUser.user.fullName}"
             binding="#{editUser.compFullName}"/>
<p:message for="#{editUser.compFullName.clientId}" />

Note that I do not have an explicit id attribute. Then in the backing bean:

    String clientID = getCompFullName().getClientId();
    msg = new FacesMessage(FacesMessage.SEVERITY_INFO, 
            "Summary Message For Full Name", "Detail Message Full Name");
    FacesContext.getCurrentInstance().addMessage(clientID, msg);

This always works, even if the component has a complex clientID, such as when PrimeFaces inserts the p:tab id into the clientID. (Which it does starting v 3). Rearranging the form never breaks anything.

It is, however, laborious, since I have to create UIComponent properties, getters and setters, and bind them in the form with binding attributes. Can anyone suggest a better way of doing this?

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

    since I have to create UIComponent properties, getters and setters, and bind them in the form with binding attributes. Can anyone suggest a better way of doing this?

    It’s not required to bind the component to some backing bean if you don’t use it in there at all. Just bind it to the view instead:

    <p:inputText value="#{editUser.user.fullName}"
                 binding="#{compFullName}"/>
    <p:message for="#{compFullName.clientId}" />
    

    To make the code more self-documenting, I suggest to put a HashMap in the request scope by faces-config.xml:

    <managed-bean>
        <description>Holder of all component bindings.</description>
        <managed-bean-name>components</managed-bean-name>
        <managed-bean-class>java.util.HashMap</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    

    with

    <p:inputText value="#{editUser.user.fullName}"
                 binding="#{components.fullName}"/>
    <p:message for="#{components.fullName.clientId}" />
    

    Adding messages is supposed to be done by a Converter or a Validator which is trowing it as a ConverterException or ValidatorException respectively. It will automatically end up in the right message holder. Or if it are informal messages, just add it on the client ID of the UIComponent which is already available as method argument.

    See also:

    • JSF component binding without bean property
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Everyone (at least everyone who uses a compiled language) has faced compilation errors but
DropDownLists are probably my least favourite part of working with the MVC framework. I
Least Recently Used (LRU) Cache is to discard the least recently used items first
At least two brilliant programmers, Linus Torvalds and Guido von Rossum, disparage the practice
At least on my local instance, when I create tables, they are all prefixed
...at least to me. This code used to work fine. I'm pretty sure nothing
I've configured (at least I've tried to configure) Lighty to enable the WebDAV plugin
In .NET (at least in the 2008 version, and maybe in 2005 as well),
I have seen at least one site in the past that had analytics on
POSIX environments provide at least two ways of accessing files. There's the standard system

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.