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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:09:13+00:00 2026-06-18T02:09:13+00:00

I have a h:commandButton on a jsf page. And it needs to be rendered

  • 0

I have a h:commandButton on a jsf page. And it needs to be rendered based on a condition. The property on the condition is a hidden input to the page. The action method on the button is not called when the rendering condition is specified.

Any ideas?

here is the sample code:

<h:commandButton value="Button" 
action="#{bean.method}"
rendered="#{bean.conditon}"
type="submit"/>

<h:inputHidden value="#{bean.condition}" />
  • 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-18T02:09:14+00:00Added an answer on June 18, 2026 at 2:09 am

    I understand that your bean is request scoped, otherwise you wouldn’t have this problem. This is a timing problem.

    The rendered attribute is also determined during “apply request values” phase of JSF lifecycle. However, the submitted values are only been set in the model during “update model values” phase of JSF lifecycle, which is later. Thus, when rendered attribute is evaluated, it doesn’t get the submitted value from the hidden input, but instead the property’s default value.

    If it’s not an option to change the request scope to the view scope, then you’d need to salvage this problem differently. One of the simplest ways changing the <h:inputHidden> to be a <f:param> and inject the value via @ManagedProperty on #{param} map:

    <h:commandButton value="Button" 
        action="#{bean.method}"
        rendered="#{bean.conditon}"
    >
        <f:param name="condition" value="#{bean.condition}" />
    </h:commandButton>
    

    (note that I omitted type="submit" as it’s the default already)

    with

    @ManagedProperty("#{param.condition}")
    private boolean condition;
    

    See also:

    • commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated – point 6
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an inputText and a commandButton in a JSF page. The user inputs
Suppose i have JSF page <h:body> <h:form id=formID prependId=false> <h:outputText id=randomID value=#{randomNumber.random}/> <h:commandButton id=buttonID
I have an a4j:commandButton which looks like this <a4j:commandButton id=stopBtn type=button reRender=lastOp action=#{MyBacking.stop} value=Stop
I have the following layout in my page (simplified) <h:form> <h:commandButton action=#{bean.save} value=Save/> <rich:tabPanel
I have a JSF page that contains two subviews. Depending on which commandButton is
I have a JSF page with a button and a label. When the user
I have simple JSF page and simple backing bean. I have p:commandButton on the
I have jsf page: .... <form jsfc=h:form action=> <h:dataTable value=#{newMusician.strings} var=preferredMusicGenre id=musicGenresSelectTable> <h:column> <h:inputText
I have a JSF page that includes a tree form tag which is rendered
I have a page start.jsf which points to an action #{ruler.start}, this action forwards

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.