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

The Archive Base Latest Questions

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

I have two pages. Search page is the first page that takes user inputs.

  • 0

I have two pages. Search page is the first page that takes user inputs. Second page shows the result set in datatable. Second page has 3 panel for resultset, update and create all in single page. Depending upon the which button being clicked, I am rendering panels true and false.

<h:panelGroup styleClass="panelGroup"
                id="resultSet" rendered="#{bean.truefalse1}">
.
.
</h:panelGroup

<h:panelGroup styleClass="panelGroup"
                id="updateForm" rendered="#{bean.truefalse2}">
.
.
</h:panelGroup


<h:panelGroup styleClass="panelGroup"
                id="createForm" rendered="#{bean.truefalse3}">
.
.
</h:panelGroup>

From the search page I am setting these create and update panels to false and displaying only resultset.After the row from the result set is clicked I am showing
updateForm panel but keeping create panel to false.

But here the problem is, If there is validation error, then the property that was set from search page is being lost and all the panels are shown.

How do I get the value(boolean true or false) that was set from search page previously, since I am not navigating to different page.

I have getters and setters for boolean property in second class. I even tried keeping hidden fields(i.e the boolean property that was set from search page).
Shouldn’t all the submitted values be recovered after validation error. Or just the ones we type in the form.

What is the best solution?

Any help is highly appreciated!!!

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

    You indeed need to transfer the very same boolean properties to the next request. You can in theory use <h:inputHidden value="#{bean.boolean1}" /> for this, but unfortunately those will only be set during update model values phase, while you actually need it to be available during apply request values phase. Besides, they will also go lost when a validation error occurs.

    There are three ways to fix this non-intuitive behaviour of h:inputHidden (I’ve ever filed a bug against it at the Mojarra issue list, but they didn’t seem to do anything with it).

    First is to use the binding on the h:inputHidden instead:

    <h:inputHidden binding="#{bean.hidden1}" />
    

    This however requires changes in the way you get/set the boolean values in the backing bean code. For example:

    private HtmlInputHidden hidden1 = new HtmlInputHidden(); // +getter +setter.
    
    public void setBoolean1(boolean boolean1) {
        hidden1.setValue(boolean1);
    }
    
    public boolean getBoolean1() {
        return (Boolean) hidden1.getValue();
    }
    

    Second is to use Tomahawk‘s t:saveState instead.

    <t:saveState value="#{bean.boolean1}" />
    

    The major advantage is that you don’t need to change anything in the backing bean code. It will restore the value early before the apply request values phase. You only need to add extra libraries if not done yet, but as Tomahawk provides much more advantages than only the t:saveState, such as the in basic JSF implementation missing components/features t:inputFileUpload, t:dataList, t:dataTable preserveDataModel="true", t:selectOneRadio layout="spread" and so on, it is worth the effort.

    The third way is to store them in a session scoped bean, but you actually don’t want to do that for request scoped variables. It would only give “wtf?” experiences when the enduser has multiple tabs/windows open in the same session.

    Edit: as per the comments, here’s an SSCCE of the second way:

    JSF page:

    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <f:view>
        <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
            </head>
            <body>
                <h:form id="form">
                    <h:inputHidden binding="#{myBean.hidden}" converter="javax.faces.Boolean" />
                    <h:commandButton value="submit" action="#{myBean.submit}"/>
                    <h:outputText value="Current boolean value: #{myBean.hidden.value}" />
                </h:form>
            </body>
        </html>
    </f:view>
    

    MyBean class:

    package mypackage;
    
    import javax.faces.component.html.HtmlInputHidden;
    
    public class MyBean {
    
        private HtmlInputHidden hidden = new HtmlInputHidden();
    
        public void submit() {
            if (hidden.getValue() == null) {
                hidden.setValue(true); // Set to true on 1st submit.
            } else {
                hidden.setValue(!((Boolean) hidden.getValue())); // Toggle true/false.
            }
        }
    
        public HtmlInputHidden getHidden() {
            return hidden;
        }
    
        public void setHidden(HtmlInputHidden hidden) {
            this.hidden = hidden;
        }
    
    }
    

    The relevant part of faces-config.xml:

    <managed-bean>
        <managed-bean-name>myBean</managed-bean-name>
        <managed-bean-class>mypackage.MyBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    

    Playground environment is JSF 1.2_13 on Tomcat 6.0.20.

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

Sidebar

Related Questions

I have two pages that inherit from one master page, First.aspx or second.aspx. Navigation
I have xpath page.search(//table[@class='campaign']//table) which returns two tables. I need to choose only first
I have an ASP.NET page that contains two div's. Both have search fields and
I have two pages, on the first page after an event happens I change
I have two controls on a page, one is a search entry and submission
I have two pages, NonMember.aspx and Member.aspx. If a user comes to the site,
I have two pages. First one we open with $_POST variables in its url,
I have two forms on one page: a results form and a search form.
I have two search buttons on a page, one linked to a dropdown list
I have a page with two tabs, a search-tab and a tab with a

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.