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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:01:46+00:00 2026-06-15T02:01:46+00:00

I try to make 2 h:selectOneMenu component on the page. When I choose some

  • 0

I try to make 2 h:selectOneMenu component on the page. When I choose some subject from the first selectOneMenu I want to use ajax with listener where I get id selected subject and fill list tests for this subject in other selectOneMenu. I use bean with session scoped.

<f:event type="preRenderView" listener="#{test.getAllSubjects}" />
<h:form prependId="false">          
    <h:panelGroup rendered="#{not empty test.testBean.subjectList}">
                    <h:selectOneMenu value="#{test.testBean.subjectId}" id="subjects">
                        <f:selectItem itemLabel="--Select a subject--" itemValue="0" />
                        <f:selectItems value="#{test.testBean.subjectList}"
                            var="subjectItem" itemValue="#{subjectItem.subjectId}"
                            itemLabel="#{subjectItem.subject}" />
                        <f:ajax event="change" render="tests" listener="#{test.testsBySubjectId}" />                
                    </h:selectOneMenu>

    <h:selectOneMenu value="#{test.testBean.test.testIdentifer.testId}" id="tests">
                    <f:selectItem itemLabel="--Select a test--" itemValue="0" />
                        <f:selectItems value="#{test.testBean.testList}" var="testItem" 
                        itemValue="#{testItem.testIdentifer.testId}" itemLabel="#{testItem.testName}" />                                    
                    </h:selectOneMenu>
    </h:panelGroup>
</h:form> 

And in managed bean Use next listener

public void getTestsBySubjectId() throws DAOException {
     Long subjectId = testBean.getSubjectId();
     List<Test> testList = testBo.getTestBySubjectId(subjectId);
     testBean.setTestList(testList);
     }

But this listener will never be called.

That’s why I made some tricks I change tag as <f:ajax event="change" render="tests" /> without listener.

But in h:selectOneMenu for test I did

<f:selectItems value="#{test.testsBySubjectId}" var="testItem"
                        itemValue="#{testItem.testIdentifer.testId}"
                        itemLabel="#{testItem.testName}" /> 

And there I initialize value not values tests from bean test list. I try to init as

public List<Test> getTestsBySubjectId() throws DAOException {
        Long subjectId = testBean.getSubjectId();
        List<Test> testList = testBo.getTestBySubjectId(subjectId);
        testBean.setTestList(testList);
        return testList;
    } 

This variant works. But I don’t understand why previous variant with listener doesn’t work.

Where is my fault? And what should be changed for right result?

  • 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-15T02:01:47+00:00Added an answer on June 15, 2026 at 2:01 am

    @SJuan76 You are right. With name of listener but I understand my real problem.

    <f:event type="preRenderView" listener="#{test.getAllSubjects}" />
    

    This listener calls on ajax postback. I understand this from this article.Is it possible to disable f:event type=“preRenderView” listener on postback?

    Thanks @BalusC

    And I also add arg AjaxBehaviorEvent eventin listener method

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

Sidebar

Related Questions

i try make some parts of page with fixed style. I have similar HTML:
I'll try make this short. I want to get a list of browsers installed
I want to interrupt a thread1 from another thread2 but when I try make
I try to make a apps that need barcode scanner, i already can get
If I try make all , I get: make: ***No rule to make target
I try make a project to write data from .mif/.tab files to Data Base
I try to make some databinding involving an x:Array defined in the resources, but
Im try make a slider and load data dynamically from a php file, im
I try to make redirect in my folder: Redirect /promotion/ /newpromotion Redirect /promotion/first/ /new/first/
I try to make pop up from ASPxNewscontrol and put javascript:void('0') in NavigateUrlField and

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.