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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:11:46+00:00 2026-06-09T10:11:46+00:00

I have build a custom component in JSF 2.0 The tag looks like this:

  • 0

I have build a custom component in JSF 2.0

The tag looks like this:

<x:myTag id="1" name="AAA" />

The corresponding java class:

@FacesComponent("a.b.c.MyTag")
public class UIMyTag extends UIInput {

   private String name;
   private String id;

   public String getId() {
      return id;
   }

   public void setId(String id) {
       this.id = id;
   }


   public String getId() {
      return id;
   }

   public void setId(String id) {
       this.id = id;
   }

   public String getName() {
      return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   @Override
   public void encodeBegin(FacesContext context) throws IOException {
       ResponseWriter writer = context.getResponseWriter();
       logger.debug(getName()); //prints null for name="#{dummyBean.name}" 
                                //   and AAA for name="AAA"
       logger.debug(getAttributes().get("name")); // always correct value
   ...
}
   ....

}

If I use

<x:myTag id="1" name="AAA" />

everything works as expected, but when I use EL for myTag attributes the setName() method never gets called. So for,

<x:myTag id="#{dummyBean.id}" name="#{dummyBean.name}" />

I always get null for the name property inside my encodeBegin method. After debugging I’ve noticed that the setName method never gets called. I thought that maybe something regarding EL messes things up (and I still believe that the reason is related to that), but what’s really weird is that the id property works good: the setter gets called, and the value is as expected when the econding begins.

I have to mention that if I call getAttributes().get("name") from the encodeBegin method I get the correct name value, but I’m intrigued why it doesn’t work with getter and setter.

Any ideas what’s missing to my component?

  • 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-09T10:11:47+00:00Added an answer on June 9, 2026 at 10:11 am

    This behavior is expected and by specification. Attribute values which are value expressions are set by UIComponent#setValueExpression(). They are namely supposed to be evaluated only when they are really been used, usually during view render time.

    The id (and binding) attribute has special treatment: it’s evaluated during view build time before it’s been set, so the “regular” setter would be called instead of the setValueExpression() (because rendering of the view would otherwise crash when the id (or binding) attribute dynamically evaluates to a different value than it was during the view build time for some reason).

    Better is to delegate the getters/setters to UIComponent#getStateHelper() instead of to local properties. The setValueExpression() ultimately also end up in the StateHelper (note that it doesn’t call the setter at all; just call the getter if you need the data) and the getAttributes() also resolves the values from the StateHelper.

    public String getName() {
       return (String) getStateHelper().eval("name");
    }
    
    public void setName(String name) {
        getStateHelper().put("name", name);
    }
    

    Note that you can safely remove the getId() and setId() methods, because they’re already definied in the UIComponentBase superclass which you’re extending from.

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

Sidebar

Related Questions

I have a test that exercises a custom Swing component using java.awt.Robot. I'd like
I have a custom class that I use to build table strings. I would
I have a custom built sign up component that I would like to enhance.
I have built a custom component using some containers and a TileList. Now when
I am moving away from MXML and have built a custom component control within
I have a custom component built for a Joomla 2.5 website. It is working
I have a custom build target in a visual studio 2008 c# project. Is
I have a custom build of a Unix OS. My task: Adding an IPSec
For reference, I'm using Visual Studio 2010. I have a custom build step defined
I have to build a more complex custom view in Android. The final layout

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.