0

I create two SelectOneMenu in JSF:

SelectOneMenu menu = new SelectOneMenu();
menu.setId("MenuSelect1" + ctrlCenterResultModel.getId());
UISelectItems item = new UISelectItems();
item.setValue(ctrlCenterResultModel.getBudget());
menu.getChildren().add(item);

SelectOneMenu menu1 = new SelectOneMenu();
menu1.setId("MenuSelect2" + ctrlCenterResultModel.getId());
UISelectItems item1 = new UISelectItems();
item1.setId("Item2"+ctrlCenterResultModel.getId());
item1.setValue(ctrlCenterResultModel.getPeriods());
menu1.getChildren().add(item1);

I want set ValueChangeListener for second menu. When I change value in first SelectOneMenu in second I want have different values. For example in first SelectOneMenu I choose Budget1 and I have period for this budget. Next my problem is that I set list of objects in UISelectItems and when I get value for this item I have String, not Object. I know how do that, when SelectOneMenu is created in XHTML, but in this case I create it in Java code.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
DanteVoronoi
  • 1,133
  • 1
  • 13
  • 20
  • Possible duplicate of [how to update a selectonemenu depending on other one selected value?](http://stackoverflow.com/questions/13338861/how-to-update-a-selectonemenu-depending-on-other-one-selected-value) – Jasper de Vries Aug 31 '16 at 12:46
  • @JasperdeVries but in this questions, `SelectOneMenu` is create in `xhtml` – DanteVoronoi Aug 31 '16 at 12:47
  • For your second problem you need a converter. http://stackoverflow.com/questions/19763346/what-is-the-purpose-of-converters-in-jsf – Jasper de Vries Aug 31 '16 at 12:48
  • Don't know what the benefit of using Java for this is. To update a component see http://www.primefaces.org/showcase/ui/misc/requestContext.xhtml – Jasper de Vries Aug 31 '16 at 13:01
  • Did you try [`addValueChangeListener`](http://docs.oracle.com/javaee/7/api/javax/faces/component/UIInput.html#addValueChangeListener-javax.faces.event.ValueChangeListener-)? – Jasper de Vries Aug 31 '16 at 21:24

0 Answers0