Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <h:form>
- <h:panelGrid binding="#{myBean.myGrid}"></h:panelGrid>
- <h:commandButton id="submit" type="submit">
- </h:form>
- public HtmlPanelGrid getMyGrid()
- {
- resultGrid = new HtmlPanelGrid();
- resultGrid.setColumns(2)
- List children = resultGrid.getChildren();
- FacesContext myFacesInstance = FacesContext.getCurrentInstance();
- Application myApp = myFacesInstance.getApplication();
- ExpressionFactory expFactory = myApp.getExpressionFactory();
- SelectItem tempSelectItem;
- String valuStringExpression;
- ValueExpression valExpression;
- //create panel for the checkboxes
- HtmlSelectManyCheckbox checkboxPanel = new HtmlSelectManyCheckbox();
- checkboxPanel.setLayout("pageDirection");
- List<SelectItem> checkChoiceList = new ArrayList<SelectItem>();
- for (int i=0;i<numChoices;i++)
- {
- valStringExpression = "#{myBean.responseValue["+i+"]}";
- valExpression = expFactory.createValueExpression(myFacesInstance.getELContext(), valStringExpression, String.class);
- tempSelectItem = new SelectItem(valExpression,choiceLabels.get(i));
- checkChoiceList.add(tempSelectItem);
- }
- UISelectItems checkboxList = new UISelectItems();
- checkboxList.setValue(checkChoiceList);
- checkboxPanel.getChildren().add(checkboxList);
- children.add(checkboxPanel);
- return resultGrid;
- }
- value="ValueExpression[#{myBean.responseValue[0]}]"
- Object value = valExpression.getValue(elContext);
- tempSelectItem = new SelectItem(value, choiceLabels.get(i));
Add Comment
Please, Sign In to add comment