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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:57:57+00:00 2026-06-15T07:57:57+00:00

I hope someone can help me. This is a Category-Type-Item situation where the user

  • 0

I hope someone can help me. This is a “Category-Type-Item” situation where the user has to select from three different drop-down lists. In JSF I made it with three h:selectoneMenu. The first two h:selectOneMenu work OK. I read a solution here, about a “malformedXML” error when I tried the first time. That’s the reason each selectOneMenu is surrounded by a h:panelGorup. I implemented it and work partially and only after reload (F5) the page, but this is not an acceptable solution.

Here is the code that I’m implementing:

<p:panel rendered="#{temporadaControllerExt.noHayGrupos}" 
                         style="width: 650px">

                 <h:panelGrid columns="3">
                        <h:panelGroup id="fases">
                            <h:outputLabel value="Fase: "/>
                            <h:selectOneMenu value="#{temporadaControllerExt.faseSelectedFinal}">
                                <f:selectItems value="#{temporadaControllerExt.fases}"/>
                                <f:ajax render="grupos"/>
                            </h:selectOneMenu>
                        </h:panelGroup>

                        <h:panelGroup id="grupos">
                            <h:outputLabel value="Grupo: "/>
                            <h:selectOneMenu value="#{temporadaControllerExt.grupoSelected}" 
                                             disabled="#{temporadaControllerExt.grupoListDisable}">
                                <f:selectItems value="#{temporadaControllerExt.gruposDefase}"/>
                                <f:ajax render="jornadas"/>
                            </h:selectOneMenu>
                        </h:panelGroup>

                        <h:panelGroup id="jornadas">
                            <h:outputLabel value="Jornada: "/>
                            <h:selectOneMenu value="#{temporadaControllerExt.jornadaSelected}" 
                                             disabled="#{temporadaControllerExt.jornadaListDiseable}">
                                <f:selectItems value="#{temporadaControllerExt.jornadasEnGrupo}"/>
                            </h:selectOneMenu>
                        </h:panelGroup>

Of course is not complete, for space reasons. And here is part of the bean controller that I’m using:

@ManagedBean(name = "temporadaControllerExt")
@SessionScoped
public class TemporadaControllerExt extends TemporadaController {

    private Fase fase;
    private Grupo grupo;
    private Jornada jornada;

    private String faseSelectedFinal;
    private String grupoSelected;
    private String jornadaSelected;
    private boolean grupoListDiseable = true;
    private boolean jornadaListDiseable = true;

    // a lot more declarations, and methods incluiding getters & setters not important for the answer...

    //Entities Cache 
    private Map<String, Fase> mapFases = new HashMap<>();
    private Map<String, Grupo> mapGrupos = new HashMap<>();

    // use to enable the second selectOneMenu
    public void setFaseSelectedFinal(String faseSelectedFinal) {
        this.faseSelectedFinal = faseSelectedFinal;
        this.grupoListDiseable = false;
    }

    public void setGrupoSelected(String grupoSelected) {
        this.grupoSelected = grupoSelected;
        this.jornadaListDiseable = false;
    }

    // methods used to populate the selecOneMenu's
    public List<SelectItem> getFases(){
        List<SelectItem> fasesList = new ArrayList<>();
        fasesList.add(new SelectItem("-- Seleccione Fase --"));
        for(Map.Entry<String, Fase> item : mapFases.entrySet()){
            fasesList.add(new SelectItem(item.getKey()));
        } 
        return fasesList;
    }

    public List<SelectItem> getGruposDefase(){
        List<SelectItem> grupoList = new ArrayList<>();
        grupoList.add(new SelectItem("-- Seleccione Grupo --"));

        Fase faseSel = mapFases.get(faseSelectedFinal);
        List<Grupo> grupoInt = faseSel.getGrupoList();
        for(Grupo grp : grupoInt){
            grupoList.add(new SelectItem(grp.getNombre()));
        }

        return grupoList;
    }

    public List<SelectItem> getJornadasEnGrupo(){
        List<SelectItem> jornadaList = new ArrayList<>();
        jornadaList.add(new SelectItem("-- Seleccione Jornada --"));

        Grupo grupoSel = mapGrupos.get(grupoSelected);
        for(Jornada jor : grupoSel.getJornadaList()){
            jornadaList.add(new SelectItem(jor.getNumero().toString()));
        }
        return jornadaList;
    }
}

As you can appreciate I’m using primefaces (3.4), and this panel is rendered in accordance to the value of the “noHayGrupos” boolean variable. This works OK, my problem is the selectOneMenu chain.

  • 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-15T07:57:58+00:00Added an answer on June 15, 2026 at 7:57 am

    After some investigation on my problem, I found a solution. I read a tutorial in this place, the section relative to “Integrated Ajax Support in JSF 2.0” by Marty Hall. The solution was quite simple:

    Declare a boolean variable to determinate if a comboBox is selected or not, and ask if a previous combobox has a data valid selected, and that’s it, worked every thing. Here the code that I use in the method getGruposDefase():

    public List<SelectItem> getGruposDefase() {
        List<SelectItem> grupoList = new ArrayList<>();
        grupoList.add(new SelectItem("-- Seleccione Grupo --"));
    
        if (!grupoListDiseable && (faseSelectedFinal != null)) {
            Fase faseSel = mapFases.get(faseSelectedFinal);
            List<Grupo> grupoInt = faseSel.getGrupoList();
            for (Grupo grp : grupoInt) {
                grupoList.add(new SelectItem(grp.getNombre()));
            }
        }
        return grupoList;
    }
    

    The variable grupoListDisable is used to control access to the second comboBox, and faseSelectedFinal, say if you have selected a valid item in the first comboBox. This simple solution makes the code work smoothly. Thanks Marty Hall

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

Sidebar

Related Questions

Hope someone can help me with this, it has me totally stumped My application
I hope someone can help me with this, as I'm unable to find the
Hope someone can help me out with this problem I am having. I just
Hope someone can help i cant seem to get my head around this, i
I hope someone can help me here. I'm having trouble loading this variable. Right
I hope someone can help with the following. I'm trying to create a user-specific
I hope someone can help with this please. I am trying to query an
Hope someone can help me with this.. I have a magento store up&running, via
I really hope someone can help on this because I'm learning cocoa and have
Hope someone can help me with this issue. I'm trying to open an info

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.