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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:08:19+00:00 2026-06-16T01:08:19+00:00

I have the following GUI elements: a dropdown menu to select whether you want

  • 0

I have the following GUI elements: a dropdown menu to select whether you want to input text by yourself or you want to select from predefined texts.

<h:form id="test">
<div>
  <h:outputLabel value="Please select:" />
  <h:selectOneMenu value="#{myform.selection}">
    <f:selectItem itemValue="1" itemLabel="Input text" />
    <f:selectItem itemValue="2" itemLabel="Select from predefined texts" />
  </h:selectOneMenu>
</div>
<div>
  <h:outputLabel value="Your text: " />
  <h:inputText value="#{myform.inputText}" rendered="#{myform.selection == 1}" />
  <h:selectOneMenu value="#{myform.inputText}" rendered="#{myform.selection == 2}">
    <f:selectItem itemValue="11" itemLabel="Preselected text 1" />
    <f:selectItem itemValue="22" itemLabel="Preselected text 2" />
  </h:selectOneMenu>
</div>
</h:form>

How do I program the rendered conditions right?

UPDATE: When the form loads, 1 is already selected, so the inputText is rendered. The problem is that nothing happens when I change the selection to 2. We use a modified JSF library based on JSF 1.2

  • 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-16T01:08:20+00:00Added an answer on June 16, 2026 at 1:08 am

    If you don’t like to use a4j library you can just show/hide the components by using javascript as below.
    Add onchange event to your first selectOneMenu

    <h:selectOneMenu value="#{myform.selection}" onchange="myFunction(this.value)">
    

    Add Ids to your textBox and selectOneMenu as below.

    <h:inputText value="#{myform.inputText}" rendered="#{myform.selection == 1}" id="myText"/>
    <h:selectOneMenu value="#{myform.inputText}" rendered="#{myform.selection == 2}" id="mySelectMenu">
    

    Finally your javascript function should be as below.

    <script>
        function myFunction(selection) {
            if(selection == 1) {
                document.getElementById("test:myText").style.display = "";
                document.getElementById("test:mySelectMenu").style.display = "none";
            } else {
                document.getElementById("test:myText").style.display = "none";
                document.getElementById("test:mySelectMenu").style.display = "";
            }
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have designed the following GUI in which there are an axes. I want
I have the following function which sets up the GUI. public void go() {
I am using GridLayout in my SWT GUI app. I have the following GridData
I have following source. In insertMessage(..), it calls selectMessage to check whether duplicate record
I have following code in my application each time I want to do some
I have the following class class GUI( QtGui.QMainWindow ): ''' classdocs ''' ********************************************************************** Constructor
I have created following adapter: package org.virtualbet.gui.util; import java.util.List; import org.virtualbet.R; import org.virtualbet.model.Tip; import
I have built a simple GUI application in QtCreator-2.0.1 i have following files: first.pro
I have a solution with following projects GUI (contains views) ViewModels (contains all view
I'm working on translating our Qt gui at the moment. I have the following

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.