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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:49:44+00:00 2026-06-05T19:49:44+00:00

In my application, I have the following piece of code: <h:form> <h:panelGrid id=initPanel columns=3>

  • 0

In my application, I have the following piece of code:

<h:form>
    <h:panelGrid id="initPanel" columns="3">
        <h:outputLabel for="type" value="*Type: " />
        <h:selectOneMenu label="type" id="type" value="#{createNews.type}"
                         required="true" requiredMessage="Type is required.">
            <f:ajax render="typePanel" />
            <f:selectItem noSelectionOption="true" itemLabel="Choose one..." />
            <f:selectItem itemValue="Article" itemLabel="Article" />
            <f:selectItem itemValue="Video"   itemLabel="Video" />
        </h:selectOneMenu>
        <p:message for="type" />

        <h:outputLabel for="title" value="*Title: " />
        <p:inputText label="title" id="title" 
                     value="#{createNews.news.title}" 
                     required="true" requiredMessage="Title is required." />
        <p:message for="title" />
    </h:panelGrid>

    <h:panelGroup id="typePanel">
        <h:panelGrid rendered="#{createNews.type == 'Article'}" columns="1">
            <h:panelGrid columns="2">
                <h:outputLabel for="content" value="*Content: " />
                <p:message id="contentMsg" for="content" />
            </h:panelGrid>

            <p:editor id="content" value="#{createNews.news.content}" width="580" />
        </h:panelGrid>

        <h:panelGrid rendered="#{createNews.type == 'Video'}" columns="3">
            <h:outputLabel for="embedCode" value="*Embed code: " />
            <p:inputText label="embedCode" id="embedCode" 
                         value="#{createNews.news.embedCode}" />
            <p:message for="embedCode" />
        </h:panelGrid>
    </h:panelGroup>

    <p:commandButton value="Confirm" update="initPanel typePanel" actionListener="#{createNews.createNews}" />

</h:form>

And this is the managed bean:

@Named(value = "createNews")
@RequestScoped
public class CreateNews {
    private Integer type;
    private News    news;

    public void createNews() {...}

    // Getters and Setters
}

When I choose Article or Video, the corresponding portion is rendered correctly in typePanel. In the below example, I chose Video and the Embed code portion was rendered.

The Embed code portion is rendered correctly.

However, when I click Confirm, the portion rendered earlier suddenly disappear.

The Embed code portion disappeared!

Somehow, the type property of my managed bean did not receive the value of the <h:selectOneMenu>.

I’d be very grateful if you could give me an advice.

Best regards,

  • 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-05T19:49:45+00:00Added an answer on June 5, 2026 at 7:49 pm

    This problem is caused by the following 2 facts:

    • A request scoped bean is created on every request (including ajax requests).
    • Model values are not updated in case of a general validation failure.

    When you change the dropdown, you’re creating one request scoped bean wherein the right property for the rendered attribute is been set. But the request scoped bean is of course garbaged by end of request. When you submit the confirm button, a brand new request scoped bean is created with all properties set to default which are not updated due to a general validation failure, that’s why the rendered attribute evaluates back to false.

    Placing the bean in the JSF view scope or CDI conversation scope should solve it.

    An alternative is to bind the dropdown to an UIInput in the current view scope and evaluate the selected value by its UIInput#getValue() instead.

    <h:selectOneMenu ... binding="#{type}">
    ...
    <h:panelGrid rendered="#{type.value == 'Article'}">
    ...
    <h:panelGrid rendered="#{type.value == 'Embed'}">
    

    See also:

    • How to choose the right bean scope?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following piece of code in my Spring MVC application: @RequestMapping(value =
I have the following piece of code for handling exceptions in my web application:
I have the following piece of code in a java application Thread.currentThread().sleep(10000); However eclipse
I have the following piece of code: string root = Path.GetDirectoryName(Application.ExecutablePath); List<string> FullFileList =
I have the following code piece for a console application that I would like
In my Rails 3.2.3 application I have the following code in the application.html.erb to
I have following code in my application: // to set tip - photo in
I have following code in my Application. Comments in my code will specify My
I have following code in my application. [self.navigationController pushViewController:x animated:YES]; It will push a
I have the following piece of code (that may be invoked multiple times or

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.