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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:12:44+00:00 2026-06-14T23:12:44+00:00

How can I repopulate my list (stationaryList) ? What’s wrong in my code ?

  • 0

How can I repopulate my list (stationaryList) ? What’s wrong in my code ? Nothing change in my list if I select value = CDL or MEL or NEF. Thanks.

<h:form id="frmCreateNewStationary">
<ui:param name="s" value="#{myController.selected}"/>
<h:panelGrid columns="2">
    <h:outputLabel value="Type" for="idType" />
    <h:selectOneMenu id="idType" value="#{s.stationaryid.type}">
        <f:selectItem itemLabel="Select ..." noSelectionOption="true" />
        <f:selectItem itemLabel="CDL" itemValue="CDL" />
        <f:selectItem itemLabel="MEL" itemValue="MEL" />
        <f:selectItem itemLabel="NEF" itemValue="NEF" />
        <f:ajax event="change" listener="#{myController.changeStationaryCodeList}" render="idCode" execute="@this" />
    </h:selectOneMenu>
    <h:outputLabel value="Code" for="idCode" />
    <h:selectOneMenu id="idCode" value="#{s.stationaryid.code}">
        <f:selectItem itemLabel="Select ..." noSelectionOption="true" />
        <f:selectItems value="#{myController.stationaryList}" />
    </h:selectOneMenu>
</h:panelGrid>
</h:form>

Java

private List<Stationary> stationaryList = null;
public List<Stationary> getStationaryList() {
    stationaryList = getCode();
    return stationaryList;
}

public void setStationaryList(List<Stationary> stationaryList) {
    this.stationaryList = stationaryList;
}

…

public List<Stationary> getCode() {
    //"Stationary.ccc", query = "SELECT s.code FROM Stationary s"),
    EntityManager emf = facade.getEntityManager();
    Query query = emf.createNamedQuery("Stationary.ccc");
    return query.getResultList();        
}

…

public List<Stationary> getStationaryCodeItems(String type) {
    //"Stationary.code", query = "SELECT s.code FROM Stationary s WHERE s.type = :type"),
    EntityManager emf = facade.getEntityManager();
    Query query = emf.createNamedQuery("Stationary.code");
    query.setParameter("type", type);
    return query.getResultList();
}

AjaxBehaviorEvent looks like this:

public void changeStationaryCodeList(AjaxBehaviorEvent ev) {
    stationaryList.clear();
    String type = (String) ((UIInput) ev.getComponent()).getValue();
    System.out.println("Test__changeStationaryCodeList -- state == " + type);
    stationaryList = getStationaryCodeItems(type);
    //setStationaryList(stationaryList);
}
  • 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-14T23:12:46+00:00Added an answer on June 14, 2026 at 11:12 pm

    Your <h:selectOneMenu id="idType"> does not have a value attribute set. Bind it to a value in your backing bean as you already are doing with <h:selectOneMenu id="idCode" value="#{s.stationaryid.code}"> and you can then use that attribute in your ajax listener as the submitted value. I also have a feeling you might not be using the right scope here. Annotate your backing bean with a @ViewScoped annotation for hitch-free results in your ajax-ing

    Unrelated to this, why do you have a backing bean named “s”? That’s just going to make your code painful to read.

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

Sidebar

Related Questions

I want to know if I can repopulate the autoincrement value in mysql. Because,
Can anyone let me know how can we change the value of kendo combobox
Can I change the field public virtual ClassOne ClassOne { get; set; } to
Can we change the default action of the edit selected row button? Here is
Can someone thoroughly explain the last line of the following code: def myMethod(self): #
I have a CListCtrl (report style) where I clear the list and repopulate it
Can I order my users in the database, so I don't have to say
Can I authenticate with just Google account username and password instead of using OAuth?
Can any one tell, how to get the result of LINQ query contains group
Can anyone enlighten me to a way I can Highlight the content of an

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.