1

I'm struggling with the following issue in a web application using PrimeFaces 6.2 - and yes, I have read this and this and this and that and the wiki and took a look into the primefaces showcase as well.

The scenario: I have a selectOneMenu that gets its selectItems from a bean:

<p:selectOneMenu id="konfiguration" value="#{tpsManager.selectedKonfig}" > 
    <p:ajax event="change" listener="#{tpsManager.konfigChange}" />
    <f:selectItems value="#{tpsManager.konfigurationen}" /> 
</p:selectOneMenu>​

If the values are computed like this by getKonfigurationen() in the bean, a change-event is triggered if the user selects an item and konfigChange() is called:

ArrayList konfigurationen = new ArrayList<SelectItem>();
SelectItemGroup g1 = new SelectItemGroup("<Auswertungsbasis>");
g1.setSelectItems(new SelectItem[]{ new SelectItem("id Denver", "Denver" ),  new SelectItem("id San Francisco", "San Francisco" )  });
konfigurationen.add(g1);
konfigurationen.add(0, new SelectItem("id new York", "New York" ));
return konfigurationen;

This is nice, but unfortunately I need to create the selectItems in the selectItemGroup dynamically since those values are provided by a database. In the following snippet the third line returns an Array of selectItem and adds this to SelectItemGroup g1. The array contains selectItem-objects (containing Strings) only and NO null entries.

ArrayList konfigurationen = new ArrayList<SelectItem>();
SelectItemGroup g1 = new SelectItemGroup("<Auswertungsbasis>");
g1.setSelectItems( al.toArray(new SelectItem[al.size()]) );
konfigurationen.add(g1);
konfigurationen.add(0, new SelectItem("id new York", "New York" ));
return konfigurationen;

The problem: if the user now selects an item NO change-event is triggered and konfigChange() is NOT called. No exception is raised. In the debugger both arrays look identially. I'm out of ideas - any help is appreciated!

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
dpoerschke
  • 68
  • 7
  • Hi, it is good practice in Stackoverflow to create a [mcve]. I think the problem you run into is related to #4 in https://stackoverflow.com/questions/2118656/commandbutton-commandlink-ajax-action-listener-method-not-invoked-or-input-value. But I can only be sure when you have shown an [mcve]. Please do include scope annotations in there. – Kukeltje Mar 14 '19 at 16:27

1 Answers1

0

it is good practice in Stackoverflow to create a [mcve]. I think the problem you run into is related to #4 in commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated. But I can only be sure when you have shown an [mcve]. Please do include scope annotations in there.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • Thanks a lot, your hint lead me to the solution: the value of the iterating component has been altered and that was the problem. For the future I will try to use mcves :) – dpoerschke Mar 15 '19 at 09:19