Application application = context.getApplication();
UIViewRoot viewRoot = new UIViewRoot();
UIForm form = new UIForm();
viewRoot.getChildren().add(form);
UIPanel grid = new UIPanel();
grid.setRendererType("javax.faces.Grid");
grid.getAttributes().put("columns", "2");
UIOutput emailLabel = new UIOutput();
emailLabel.setValue("Email Address:");
grid.getChildren().add(emailLabel);
UIInput email = new UIInput();
ValueBinding emailAddr =
application.createValueBinding("#{subscr.emailAddr}");
email.setValueBinding("value", emailAddr);
grid.getChildren().add(email);
UIOutput subsLabel = new UIOutput();
subsLabel.setValue("Newsletters:");
grid.getChildren().add(subsLabel);
UISelectMany subs = new UISelectMany();
subs.setRendererType("javax.faces.Checkbox");
ValueBinding subIds =
application.createValueBinding("#{subscr.subscriptionIds}");
subs.setValueBinding("value", subIds);
UISelectItems sis = new UISelectItems();
List choices = new ArrayList();
choices.add(new SelectItem("1", "JSF News"));
choices.add(new SelectItem("2", "IT Industry News"));
choices.add(new SelectItem("3", "Company News"));
sis.setValue(choices);
subs.getChildren().add(sis);
grid.getChildren().add(subs);
form.getChildren().add(grid);
UICommand command = new UICommand();
command.setValue("Save");
MethodBinding action =
application.createMethodBinding("#{subscrHandler.saveSubscriber}",
null);
command.setAction(action);
form.getChildren().add(command);
viewRoot.getChildren().add(form);
return viewRoot;