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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:26:32+00:00 2026-05-30T00:26:32+00:00

I have following sample code. Initially, only commandButton Two is visible. When I click

  • 0

I have following sample code.
Initially, only commandButton Two is visible. When I click this button, commandButton One is also visible. But when I click One, the backing-bean method click1 does not get fired.

Following is my code:

xhtml

<h:form id="form1">
    <h:inputHidden id="show" value="#{bean.show1}" />
    <h:commandButton id="button1" value="One" action="#{bean.click1}"
        rendered="#{bean.show1}" />
</h:form>
<h:form id="form2">
    <h:inputHidden id="show" value="#{bean.show1}" />
    <h:commandButton id="button2" value="Two" action="#{bean.click2}" />
</h:form>

backing-bean

@RequestScoped
@Named("bean")
public class JsfTrial implements Serializable {

    private static final long serialVersionUID = 2784462583813130092L;

    private boolean show1; // + getter, setter

    public String click1() {
        System.out.println("Click1()");
        return null;
    }

    public String click2() {
        System.out.println("Click2()");
        setShow1(true);
        return null;
    }

}

I found a very informative answer by BalusC.

  • h:commandLink / h:commandButton is not being invoked

If I understand it correctly, my problem is due to point 5 of this answer.

Does that also mean we can not use hidden commandButton with @RequestScoped backing-bean?

  • 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-30T00:26:34+00:00Added an answer on May 30, 2026 at 12:26 am

    You can use the request scope, you should only pass the condition as a request parameter to the subsequent requests by <f:param> instead of by a JSF hidden input field <h:inputHidden>. The value of the hidden input field is only set in the model during Update Model Values phase, while the condition of the rendered attribute is already evaluated during Apply Request Values phase which is earlier.

    So, use <f:param> instead of <h:inputHidden>:

    <h:form id="form1">
        <h:commandButton id="button1" value="One" action="#{bean.click1}"
            rendered="#{bean.show1}">
            <f:param name="show1" value="#{bean.show1}" />
        </h:commandButton>
    </h:form>
    <h:form id="form2">
        <h:commandButton id="button2" value="Two" action="#{bean.click2}">
            <f:param name="show1" value="#{bean.show1}" />
        </h:commandButton>
    </h:form>
    

    This way you can extract them as request parameter in bean’s (post)constructor.

    public JsfTrial() {
        String show1 = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("show1");
        this.show1 = (show1 != null) && Boolean.valueOf(show1);
    }
    

    Ugly, but CDI doesn’t offer a builtin annotation which substituties JSF’s @ManagedProperty("#{param.show1}"). You could however homegrow such an annotation.

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

Sidebar

Related Questions

i have the following simple code, but it doesn,t work <ul> <li id=one onmouseover=this.style.background-color='white';>
I have downloaded sample code from Apple Center.I also have gone through following question:
I have the following sample code that zooms each time a button is pressed:
I have the following sample code which doesn't seem to want to run. import
I have the following code sample that im trying to wrap my head around
I have the following code sample: float val = 16777216.0F; var badResult = Convert.ToDecimal(val);
I have a Dictionary bound to DataGridView by using following sample code. DataGridView bound
I am new to Emacs, and I have the following code as a sample.
I have the following sample code in a VB.NET console application. It compiles and
I have the following sample code in WPF. It is working well when I

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.