Guest User

Untitled

a guest
Jul 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. <h:form>
  2. <h:panelGrid binding="#{myBean.myGrid}"></h:panelGrid>
  3. <h:commandButton id="submit" type="submit">
  4. </h:form>
  5.  
  6. public HtmlPanelGrid getMyGrid()
  7. {
  8. resultGrid = new HtmlPanelGrid();
  9. resultGrid.setColumns(2)
  10. List children = resultGrid.getChildren();
  11.  
  12. FacesContext myFacesInstance = FacesContext.getCurrentInstance();
  13. Application myApp = myFacesInstance.getApplication();
  14. ExpressionFactory expFactory = myApp.getExpressionFactory();
  15.  
  16. SelectItem tempSelectItem;
  17. String valuStringExpression;
  18. ValueExpression valExpression;
  19.  
  20. //create panel for the checkboxes
  21. HtmlSelectManyCheckbox checkboxPanel = new HtmlSelectManyCheckbox();
  22. checkboxPanel.setLayout("pageDirection");
  23.  
  24. List<SelectItem> checkChoiceList = new ArrayList<SelectItem>();
  25.  
  26. for (int i=0;i<numChoices;i++)
  27. {
  28. valStringExpression = "#{myBean.responseValue["+i+"]}";
  29. valExpression = expFactory.createValueExpression(myFacesInstance.getELContext(), valStringExpression, String.class);
  30. tempSelectItem = new SelectItem(valExpression,choiceLabels.get(i));
  31. checkChoiceList.add(tempSelectItem);
  32. }
  33.  
  34. UISelectItems checkboxList = new UISelectItems();
  35. checkboxList.setValue(checkChoiceList);
  36. checkboxPanel.getChildren().add(checkboxList);
  37.  
  38. children.add(checkboxPanel);
  39.  
  40. return resultGrid;
  41. }
  42.  
  43. value="ValueExpression[#{myBean.responseValue[0]}]"
  44.  
  45. Object value = valExpression.getValue(elContext);
  46. tempSelectItem = new SelectItem(value, choiceLabels.get(i));
Add Comment
Please, Sign In to add comment