/** Test the built-in conversion for those renderers that have it. */
  public void testEmptyStrings() {
    UIViewRoot root = Util.getViewHandler(getFacesContext()).createView(getFacesContext(), null);
    root.setLocale(Locale.US);
    UIInput text = new UIInput(), hidden = new UIInput(), secret = new UIInput();

    text.setId("text");
    hidden.setId("hidden");
    secret.setId("secret");

    text.setRendererType("Text");
    hidden.setRendererType("Hidden");
    secret.setRendererType("Secret");

    root.getChildren().add(text);
    root.getChildren().add(hidden);
    root.getChildren().add(secret);
    TextRenderer textRenderer = new TextRenderer();
    HiddenRenderer hiddenRenderer = new HiddenRenderer();
    SecretRenderer secretRenderer = new SecretRenderer();

    try {
      textRenderer.decode(getFacesContext(), text);
      hiddenRenderer.decode(getFacesContext(), hidden);
      secretRenderer.decode(getFacesContext(), secret);
    } catch (Throwable e) {
      assertTrue(false);
    }
    assertTrue(text.isValid());
    assertTrue(hidden.isValid());
    assertTrue(secret.isValid());
  }
Exemple #2
0
  public void testComponentAnnotatations() throws Exception {

    getFacesContext()
        .getAttributes()
        .put("javax.faces.IS_POSTBACK_AND_RESTORE_VIEW", Boolean.FALSE);
    Application application = getFacesContext().getApplication();
    application.addComponent("CustomInput", CustomOutput.class.getName());
    CustomOutput c = (CustomOutput) application.createComponent("CustomInput");
    CustomOutput c2 = (CustomOutput) application.createComponent("CustomInput");
    UIViewRoot root = getFacesContext().getViewRoot();
    root.getChildren().add(c);
    root.getChildren().add(c2);
    assertTrue(c.getEvent() instanceof AfterAddToParentEvent);
    assertTrue(c2.getEvent() instanceof AfterAddToParentEvent);
    List<UIComponent> headComponents = root.getComponentResources(getFacesContext(), "head");
    System.out.println(headComponents.toString());
    assertTrue(headComponents.size() == 1);
    assertTrue(headComponents.get(0) instanceof UIOutput);
    assertTrue("test".equals(headComponents.get(0).getAttributes().get("library")));
    List<UIComponent> bodyComponents = root.getComponentResources(getFacesContext(), "body");
    assertTrue(bodyComponents.size() == 1);
    assertTrue(bodyComponents.get(0) instanceof UIOutput);
    assertTrue("test.js".equals(bodyComponents.get(0).getAttributes().get("name")));
    assertTrue("body".equals(bodyComponents.get(0).getAttributes().get("target")));

    application.addComponent("CustomInput2", CustomOutput2.class.getName());
    CustomOutput2 c3 = (CustomOutput2) application.createComponent("CustomInput2");
    root.getChildren().add(c3);
    assertTrue(c3.getEvent() instanceof AfterAddToParentEvent);
    c3.reset();
    c3.encodeAll(getFacesContext());
    assertTrue(c3.getEvent() instanceof BeforeRenderEvent);
  }
  /**
   * Test to verify that a class that registers itself is properly found using the search mechanism.
   * The J2SE classes are used for their inheritance hierarchy to test that converters registered to
   * interfaces and superclasses are properly found.
   *
   * <p>This test is meant for inheritance lookup only.
   */
  public void testConverterInheritance(UIViewRoot root)
      throws ConverterException, InstantiationException, IllegalAccessException,
          ClassNotFoundException {
    System.out.println("Testing ConverterInheritance");

    Converter converter;
    UIInput text = new UIInput();
    text.setId("my_date_converter");
    root.getChildren().add(text);

    // java.lang.Integer extends java.lang.Number.
    // Test to show that the standard converter registered to
    // java.lang.Integer should chosen over the inherited
    // java.lang.Number converter
    application.addConverter(java.lang.Number.class, "javax.faces.convert.NumberConverter");
    converter = application.createConverter(java.lang.Integer.class);
    assertTrue(converter != null);
    assertTrue(converter instanceof javax.faces.convert.IntegerConverter);

    // java.sql.Date extends java.util.Date
    // Test to find converter registered to java.util.Date
    application.addConverter(java.util.Date.class, "javax.faces.convert.DateTimeConverter");
    converter = null;
    converter = application.createConverter(java.sql.Date.class);
    assertTrue(converter != null);

    // java.util.HashSet is a subclass of java.util.AbstractSet which is
    // a subclass of java.util.AbstractCollection
    // Test to find the converter registered to java.util.AbstractCollection
    application.addConverter(
        java.util.AbstractCollection.class, "javax.faces.convert.DateTimeConverter");
    converter = null;
    try {
      converter = application.createConverter(java.util.HashSet.class);
    } catch (javax.faces.FacesException fe) {

    }
    assertTrue(converter != null);

    // java.lang.String implements java.lang.CharSequence
    // Test to find the converter registered to java.lang.CharSequence
    application.addConverter(
        java.text.CharacterIterator.class, "javax.faces.convert.CharacterConverter");
    converter = null;
    converter = application.createConverter(java.text.StringCharacterIterator.class);
    assertTrue(converter != null);

    // java.text.StringCharacterIterator implements
    // java.text.CharacterIterator which has a super-interface
    // java.lang.Cloneable
    // Test to find the converter registered to java.lang.Cloneable
    application.addConverter(java.lang.Cloneable.class, "javax.faces.convert.CharacterConverter");
    converter = null;
    converter = application.createConverter(java.text.StringCharacterIterator.class);
    assertTrue(converter != null);
  }
Exemple #4
0
  //
  // General Methods
  //
  private void buildTree() {
    FacesContext context = getFacesContext();
    UIViewRoot root = Util.getViewHandler(context).createView(context, null);
    root.setId("root");
    context.setViewRoot(root);

    HtmlForm form = new HtmlForm();
    form.setId("form");
    root.getChildren().add(form);

    buildPanel(form, "panel0");
    buildPanel(form, "panel1");
  }
 protected UIData getUIData(FacesContext context, String id) {
   UIData data = null;
   if (this.data != null) {
     data = this.data;
   } else {
     UIViewRoot root = context.getViewRoot();
     data = findUIData(root.getChildren(), id);
     if (data != null) {
       this.data = data; // cache it
     }
   }
   return data;
 }
  public void testNumberConverter(UIViewRoot root)
      throws ConverterException, InstantiationException, IllegalAccessException,
          ClassNotFoundException {
    System.out.println("Tesing NumberConverter");
    UIInput text = new UIInput();
    text.setId("my_input_number");
    root.getChildren().add(text);

    Converter converter = application.createConverter("javax.faces.Number");

    String stringToConvert = "99.9";
    Object obj = converter.getAsObject(getFacesContext(), text, stringToConvert);
    assertTrue(obj instanceof java.lang.Number);
    String str = converter.getAsString(getFacesContext(), text, obj);
    assertTrue(str.equals(stringToConvert));
  }
Exemple #7
0
  private void renderAll(FacesContext context, UIViewRoot viewRoot) throws IOException {
    // If this is a "render all via ajax" request,
    // make sure to wrap the entire page in a <render> elemnt
    // with the special viewStateId of VIEW_ROOT_ID.  This is how the client
    // JavaScript knows how to replace the entire document with
    // this response.
    PartialViewContext pvc = context.getPartialViewContext();
    PartialResponseWriter writer = pvc.getPartialResponseWriter();
    writer.startUpdate(PartialResponseWriter.RENDER_ALL_MARKER);

    if (viewRoot.getChildCount() > 0) {
      for (UIComponent uiComponent : viewRoot.getChildren()) {
        uiComponent.encodeAll(context);
      }
    }

    writer.endUpdate();
  }
  public static UIViewRoot findRoot(FacesContext context, ServletRequest req, Object etag)
      throws Exception {
    if (context == null) context = FacesContext.getCurrentInstance();

    UIViewRoot root = context.getViewRoot();

    if (root == null)
      throw new NullPointerException(L.l("f:view can't find current in FacesContext"));

    Object oldETag = root.getAttributes().get("caucho.etag");

    if (oldETag != null && !oldETag.equals(etag)) {
      // clear view on JSP change

      root.getChildren().clear();
      root.getFacets().clear();
    }

    root.getAttributes().put("caucho.etag", etag);

    return root;
  }
  @Override
  public void buildView(FacesContext facesContext, UIViewRoot uiViewRoot) throws IOException {
    super.buildView(facesContext, uiViewRoot);

    UIComponent coreForm = findCoreFormRecurse(uiViewRoot);

    if (coreForm != null) {

      // Since the JSF-1.2-based TCK does not have h:head tags in any of the JSPs, need to add one
      // dynamically so
      // that the jsf.js script resource can be rendered. This is necessary so that Trinidad Partial
      // Page
      // Rendering (PPR) will work properly.
      HtmlHead htmlHead = new HtmlHead();
      uiViewRoot.getChildren().add(htmlHead);

      // Add the "jsf.js" script resource to the h:head component.
      UIOutput uiOutput = new UIOutput();
      uiOutput.setRendererType("javax.faces.resource.Script");
      uiOutput.getAttributes().put("name", "jsf.js");
      uiOutput.getAttributes().put("library", "javax.faces");
      uiViewRoot.addComponentResource(facesContext, uiOutput, "head");

      // Due to a bug in the Trinidad tr:form renderer, need to add the javax.faces.encodedURL
      // hidden field
      // dynamically. See: https://issues.apache.org/jira/browse/TRINIDAD-2284
      String viewId = uiViewRoot.getViewId();
      String actionURL =
          facesContext.getApplication().getViewHandler().getActionURL(facesContext, viewId);
      ExternalContext externalContext = facesContext.getExternalContext();
      String encodedPartialActionURL = externalContext.encodePartialActionURL(actionURL);
      EncodedURLHiddenField encodedURLHiddenField = new EncodedURLHiddenField();
      encodedURLHiddenField.setValue(encodedPartialActionURL);
      coreForm.getChildren().add(encodedURLHiddenField);
    }
  }
 public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
   if (event.getClass() == PRERENDER_EVENT_CLASS) {
     LOGGER.debug("Prerender event {0} caught", event);
     // FIXME seriously, do it!
     FacesContext ctx = FacesContext.getCurrentInstance();
     UIViewRoot viewRoot = ctx.getViewRoot();
     if (viewRoot != null) {
       ServiceRegisterJSComponent comp;
       if ((comp = findServiceRegister(ctx)) == null) {
         LOGGER.debug("Cannot find a service register register component, adding one");
         viewRoot
             .getChildren()
             .add(
                 ctx.getApplication()
                     .createComponent(ServiceRegisterJSComponent.COMPONENT_TYPE));
         viewRoot.markInitialState();
       } else {
         LOGGER.debug("Found service register component with clientId {0}", comp.getClientId());
       }
     } else {
       LOGGER.error("Could not find a view root");
     }
   }
 }
  public void testDateConverter(UIViewRoot root)
      throws ConverterException, InstantiationException, IllegalAccessException,
          ClassNotFoundException {
    System.out.println("Testing DateConverter");
    UIInput text = new UIInput();
    text.setId("my_input_date");
    root.getChildren().add(text);

    Converter converter = null;
    converter = application.createConverter("javax.faces.DateTime");

    // date
    String stringToConvert = "Jan 1, 1967";
    Object obj = converter.getAsObject(getFacesContext(), text, stringToConvert);
    assertTrue(obj instanceof java.util.Date);
    String str = converter.getAsString(getFacesContext(), text, obj);
    // make sure we end up with the same string we started with..
    assertTrue(str.equals(stringToConvert));

    // time
    converter = application.createConverter("javax.faces.DateTime");
    ((DateTimeConverter) converter).setType("time");
    text = new UIInput();
    text.setId("my_input_time");
    stringToConvert = "10:10:10 AM";
    obj = converter.getAsObject(getFacesContext(), text, stringToConvert);
    assertTrue(obj instanceof java.util.Date);
    str = converter.getAsString(getFacesContext(), text, obj);
    // make sure we end up with the same string we started with..
    assertTrue(str.equals(stringToConvert));

    // datetime
    converter = application.createConverter("javax.faces.DateTime");
    ((DateTimeConverter) converter).setType("both");
    text = new UIInput();
    text.setId("my_input_datetime");
    stringToConvert = "Jan 1, 1967 10:10:10 AM";
    obj = converter.getAsObject(getFacesContext(), text, stringToConvert);
    assertTrue(obj instanceof java.util.Date);
    str = converter.getAsString(getFacesContext(), text, obj);
    // make sure we end up with the same string we started with..
    assertTrue(str.equals(stringToConvert));

    // test bogus type....
    boolean exceptionThrown = false;
    try {
      ((DateTimeConverter) converter).setType("foobar");
      obj = converter.getAsObject(getFacesContext(), text, stringToConvert);
    } catch (Exception e) {
      exceptionThrown = true;
    }
    assertTrue(exceptionThrown);

    // test NullPointerException (if either context or component arg is null)
    exceptionThrown = false;
    try {
      obj = converter.getAsObject(null, text, stringToConvert);
    } catch (NullPointerException npe) {
      exceptionThrown = true;
    }
    assertTrue(exceptionThrown);
    exceptionThrown = false;
    try {
      obj = converter.getAsObject(getFacesContext(), null, stringToConvert);
    } catch (NullPointerException npe) {
      exceptionThrown = true;
    }
    assertTrue(exceptionThrown);

    exceptionThrown = false;
    try {
      str = converter.getAsString(null, text, obj);
    } catch (NullPointerException npe) {
      exceptionThrown = true;
    }
    assertTrue(exceptionThrown);

    exceptionThrown = false;
    try {
      str = converter.getAsString(getFacesContext(), null, obj);
    } catch (NullPointerException npe) {
      exceptionThrown = true;
    }
    assertTrue(exceptionThrown);
  }
  public void testUISelectMany() throws Exception {
    // create the test bean
    TestBean bean = new TestBean();
    getFacesContext().getExternalContext().getRequestMap().put("bean", bean);
    // create a dummy root for the tree.
    UIViewRoot root = Util.getViewHandler(getFacesContext()).createView(getFacesContext(), null);
    root.setId("root");
    root.setLocale(Locale.US);
    getFacesContext().setViewRoot(root);

    // test model type of boolean []
    UISelectMany booleanv = new UISelectMany();
    booleanv.setId("bool");
    booleanv.setRendererType("javax.faces.Checkbox");
    booleanv.setValueExpression(
        "value",
        (getFacesContext()
            .getApplication()
            .getExpressionFactory()
            .createValueExpression(
                getFacesContext().getELContext(), "#{bean.booleans}", Boolean.class)));
    root.getChildren().add(booleanv);
    booleanv.getChildren().add(newUISelectItem(Boolean.TRUE));
    booleanv.getChildren().add(newUISelectItem(Boolean.FALSE));
    booleanv.decode(getFacesContext());
    booleanv.validate(getFacesContext());
    booleanv.updateModel(getFacesContext());
    assertNotNull(bean.getBooleans());
    assertTrue(bean.getBooleans()[0] == false);
    assertTrue(bean.getBooleans()[1] == true);
    assertTrue(bean.getBooleans()[2] == false);

    // test model type of boolean []
    booleanv = new UISelectMany();
    booleanv.setId("bool2");
    booleanv.setRendererType("javax.faces.Checkbox");
    booleanv.setValueExpression(
        "value",
        (getFacesContext()
            .getApplication()
            .getExpressionFactory()
            .createValueExpression(
                getFacesContext().getELContext(), "#{bean.booleans}", Object.class)));
    root.getChildren().add(booleanv);
    booleanv.getChildren().add(newUISelectItem(Boolean.TRUE));
    booleanv.getChildren().add(newUISelectItem(Boolean.FALSE));
    booleanv.decode(getFacesContext());
    booleanv.validate(getFacesContext());
    booleanv.updateModel(getFacesContext());
    assertNotNull(bean.getBooleans());
    assertTrue(bean.getBooleans()[0] == false);
    assertTrue(bean.getBooleans().length == 1);

    // test model type of byte []
    UISelectMany bytev = new UISelectMany();
    bytev.setId("byte");
    bytev.setRendererType("javax.faces.Checkbox");

    bytev.setValueExpression(
        "value",
        getFacesContext()
            .getApplication()
            .getExpressionFactory()
            .createValueExpression(
                getFacesContext().getELContext(), "#{bean.bytes}", Object.class));
    bytev.getChildren().add(newUISelectItem(new Byte(Byte.MIN_VALUE)));
    bytev.getChildren().add(newUISelectItem(new Byte(Byte.MAX_VALUE)));
    bytev.getChildren().add(newUISelectItem(new Byte((byte) 1)));
    bytev.getChildren().add(newUISelectItem(new Byte((byte) -1)));
    root.getChildren().add(bytev);
    bytev.decode(getFacesContext());
    bytev.validate(getFacesContext());
    bytev.updateModel(getFacesContext());
    assertNotNull(bean.getBytes());
    assertTrue(bean.getBytes()[0] == Byte.MIN_VALUE);
    assertTrue(bean.getBytes()[1] == Byte.MAX_VALUE);
    assertTrue(bean.getBytes()[2] == 1);

    // test model type of char []
    UISelectMany charv = new UISelectMany();
    charv.setId("char");
    charv.setRendererType("javax.faces.Checkbox");
    charv.setValueExpression(
        "value",
        getFacesContext()
            .getApplication()
            .getExpressionFactory()
            .createValueExpression(
                getFacesContext().getELContext(), "#{bean.chars}", Object.class));
    root.getChildren().add(charv);
    charv.getChildren().add(newUISelectItem(new Character('Q')));
    charv.getChildren().add(newUISelectItem(new Character('A')));
    charv.getChildren().add(newUISelectItem(new Character('Z')));
    charv.getChildren().add(newUISelectItem(new Character('z')));
    charv.decode(getFacesContext());
    charv.validate(getFacesContext());
    charv.updateModel(getFacesContext());
    assertNotNull(bean.getChars());
    assertTrue(bean.getChars()[0] == 'Q');
    assertTrue(bean.getChars()[1] == 'A');
    assertTrue(bean.getChars()[2] == 'z');

    // test model type of short []
    UISelectMany shortv = new UISelectMany();
    shortv.setId("short");
    shortv.setRendererType("javax.faces.Checkbox");
    shortv.setValueExpression(
        "value",
        getFacesContext()
            .getApplication()
            .getExpressionFactory()
            .createValueExpression(
                getFacesContext().getELContext(), "#{bean.shorts}", Object.class));
    root.getChildren().add(shortv);
    shortv.getChildren().add(newUISelectItem(new Short((short) (Byte.MAX_VALUE + 1))));
    shortv.getChildren().add(newUISelectItem(new Short((short) 100)));
    shortv.getChildren().add(newUISelectItem(new Short(Short.MIN_VALUE)));
    shortv.getChildren().add(newUISelectItem(new Short(Short.MAX_VALUE)));
    shortv.decode(getFacesContext());
    shortv.validate(getFacesContext());
    shortv.updateModel(getFacesContext());
    assertNotNull(bean.getShorts());
    assertTrue(bean.getShorts()[0] == Short.MIN_VALUE);
    assertTrue(bean.getShorts()[1] == Short.MAX_VALUE);
    assertTrue(bean.getShorts()[2] == Byte.MAX_VALUE + 1);

    // test model type of int []
    UISelectMany intv = new UISelectMany();
    intv.setId("int");
    intv.setRendererType("javax.faces.Checkbox");
    intv.setValueExpression(
        "value",
        getFacesContext()
            .getApplication()
            .getExpressionFactory()
            .createValueExpression(getFacesContext().getELContext(), "#{bean.ints}", Object.class));
    root.getChildren().add(intv);
    intv.getChildren().add(newUISelectItem(new Integer(Short.MAX_VALUE + 1)));
    intv.getChildren().add(newUISelectItem(new Integer(100)));
    intv.getChildren().add(newUISelectItem(new Integer(Integer.MIN_VALUE)));
    intv.getChildren().add(newUISelectItem(new Integer(Integer.MAX_VALUE)));
    intv.decode(getFacesContext());
    intv.validate(getFacesContext());
    intv.updateModel(getFacesContext());
    assertNotNull(bean.getInts());
    assertTrue(bean.getInts()[0] == Integer.MIN_VALUE);
    assertTrue(bean.getInts()[1] == Integer.MAX_VALUE);
    assertTrue(bean.getInts()[2] == Short.MAX_VALUE + 1);

    // test model type of float []
    UISelectMany floatv = new UISelectMany();
    floatv.setId("float");
    floatv.setRendererType("javax.faces.Checkbox");
    floatv.setValueExpression(
        "value",
        getFacesContext()
            .getApplication()
            .getExpressionFactory()
            .createValueExpression(
                getFacesContext().getELContext(), "#{bean.floats}", Object.class));
    root.getChildren().add(floatv);
    floatv.getChildren().add(newUISelectItem(new Float(Integer.MAX_VALUE + 1)));
    floatv.getChildren().add(newUISelectItem(new Float(100)));
    floatv.getChildren().add(newUISelectItem(new Float(Float.MIN_VALUE)));
    floatv.getChildren().add(newUISelectItem(new Float(Float.MAX_VALUE)));
    floatv.decode(getFacesContext());
    floatv.validate(getFacesContext());
    floatv.updateModel(getFacesContext());
    assertNotNull(bean.getFloats());
    assertTrue(bean.getFloats()[0] == Float.MIN_VALUE);
    assertTrue(bean.getFloats()[1] == Float.MAX_VALUE);
    assertTrue(bean.getFloats()[2] == Integer.MAX_VALUE + 1);

    // test model type of long []
    UISelectMany longv = new UISelectMany();
    longv.setId("long");
    longv.setRendererType("javax.faces.Checkbox");
    longv.setValueExpression(
        "value",
        getFacesContext()
            .getApplication()
            .getExpressionFactory()
            .createValueExpression(
                getFacesContext().getELContext(), "#{bean.longs}", Object.class));
    root.getChildren().add(longv);
    longv.getChildren().add(newUISelectItem(new Long(Integer.MAX_VALUE + 1)));
    longv.getChildren().add(newUISelectItem(new Long(100)));
    longv.getChildren().add(newUISelectItem(new Long(Long.MIN_VALUE)));
    longv.getChildren().add(newUISelectItem(new Long(Long.MAX_VALUE)));
    longv.decode(getFacesContext());
    longv.validate(getFacesContext());
    longv.updateModel(getFacesContext());
    assertNotNull(bean.getLongs());
    assertTrue(bean.getLongs()[0] == Long.MIN_VALUE);
    assertTrue(bean.getLongs()[1] == Long.MAX_VALUE);
    assertTrue(bean.getLongs()[2] == Integer.MAX_VALUE + 1);

    // test model type of double []
    UISelectMany doublev = new UISelectMany();
    doublev.setId("double");
    doublev.setRendererType("javax.faces.Checkbox");
    doublev.setValueExpression(
        "value",
        getFacesContext()
            .getApplication()
            .getExpressionFactory()
            .createValueExpression(
                getFacesContext().getELContext(), "#{bean.doubles}", Object.class));
    root.getChildren().add(doublev);
    doublev.getChildren().add(newUISelectItem(new Double(Long.MAX_VALUE + 1)));
    doublev.getChildren().add(newUISelectItem(new Double(100)));
    doublev.getChildren().add(newUISelectItem(new Double(Double.MIN_VALUE)));
    doublev.getChildren().add(newUISelectItem(new Double(Double.MAX_VALUE)));
    doublev.decode(getFacesContext());
    doublev.validate(getFacesContext());
    doublev.updateModel(getFacesContext());
    assertNotNull(bean.getDoubles());
    assertTrue(bean.getDoubles()[0] == Double.MIN_VALUE);
    assertTrue(bean.getDoubles()[1] == Double.MAX_VALUE);
    assertTrue(bean.getDoubles()[2] == Long.MAX_VALUE + 1);

    // test model type of String []
    UISelectMany str = new UISelectMany();
    str.setId("str");
    str.setRendererType("javax.faces.Checkbox");
    str.setValueExpression(
        "value",
        getFacesContext()
            .getApplication()
            .getExpressionFactory()
            .createValueExpression(
                getFacesContext().getELContext(), "#{bean.strings}", Object.class));
    root.getChildren().add(str);
    str.getChildren().add(newUISelectItem("value1"));
    str.getChildren().add(newUISelectItem("value2"));
    str.getChildren().add(newUISelectItem("value3"));
    str.getChildren().add(newUISelectItem("value4"));
    str.decode(getFacesContext());
    str.validate(getFacesContext());
    str.updateModel(getFacesContext());
    assertNotNull(bean.getStrings());
    assertTrue("value1".equals(bean.getStrings()[0]));

    // test model type of Date []
    UISelectMany date = new UISelectMany();
    Converter dateConv = Util.getConverterForIdentifer("javax.faces.DateTime", getFacesContext());
    assertNotNull(dateConv);
    date.setConverter(dateConv);
    date.setId("date");
    date.setRendererType("javax.faces.Checkbox");
    date.setValueExpression(
        "value",
        getFacesContext()
            .getApplication()
            .getExpressionFactory()
            .createValueExpression(
                getFacesContext().getELContext(), "#{bean.dates}", Object.class));
    root.getChildren().add(date);

    try {
      SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
      df.setTimeZone(TimeZone.getTimeZone("GMT"));
      date.getChildren().add(newUISelectItem(df.parse("19670101")));
      date.getChildren().add(newUISelectItem(df.parse("20030526")));
      date.getChildren().add(newUISelectItem(df.parse("19460819")));
      date.getChildren().add(newUISelectItem(df.parse("17760704")));
    } catch (ParseException e) {
      assertTrue(e.getMessage(), false);
    }

    date.decode(getFacesContext());
    date.validate(getFacesContext());
    date.updateModel(getFacesContext());
    assertNotNull(bean.getDates());
    Object expected = null;
    try {
      SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
      df.setTimeZone(TimeZone.getTimeZone("GMT"));
      expected = df.parse("19460819");
    } catch (ParseException e) {
      assertTrue(e.getMessage(), false);
    }
    assertEquals("bean.getDates()[2] not as expected: ", expected, bean.getDates()[2]);

    // test model type of Number []
    UISelectMany number = new UISelectMany();
    Converter numberConv = Util.getConverterForIdentifer("javax.faces.Number", getFacesContext());
    assertNotNull(numberConv);
    number.setConverter(numberConv);
    number.setId("num");
    number.setRendererType("javax.faces.Checkbox");
    number.setValueExpression(
        "value",
        getFacesContext()
            .getApplication()
            .getExpressionFactory()
            .createValueExpression(
                getFacesContext().getELContext(), "#{bean.numbers}", Object.class));
    root.getChildren().add(number);
    number.getChildren().add(newUISelectItem(new Double(3.14)));
    number.getChildren().add(newUISelectItem(new Double(49.99)));
    number.getChildren().add(newUISelectItem(new Long(12)));
    number.getChildren().add(newUISelectItem(new Double(-145.5)));
    number.decode(getFacesContext());
    number.validate(getFacesContext());
    number.updateModel(getFacesContext());
    assertNotNull(bean.getNumbers());
    try {
      DecimalFormat df = new DecimalFormat("'$'##.##", new DecimalFormatSymbols(Locale.US));
      expected = df.parse("$49.99");
    } catch (ParseException e) {
      assertTrue(e.getMessage(), false);
    }
    assertTrue(expected.equals(bean.getNumbers()[2]));

    // test model type of List of Strings
    UISelectMany stringList = new UISelectMany();
    stringList.setId("stringList");
    stringList.setRendererType("javax.faces.Checkbox");
    stringList.setValueExpression(
        "value",
        getFacesContext()
            .getApplication()
            .getExpressionFactory()
            .createValueExpression(
                getFacesContext().getELContext(), "#{bean.stringList}", Object.class));
    root.getChildren().add(stringList);
    stringList.getChildren().add(newUISelectItem("value1"));
    stringList.getChildren().add(newUISelectItem("value2"));
    stringList.getChildren().add(newUISelectItem("value3"));
    stringList.getChildren().add(newUISelectItem("value4"));
    stringList.decode(getFacesContext());
    stringList.validate(getFacesContext());
    stringList.updateModel(getFacesContext());
    assertNotNull(bean.getStringList());
    assertTrue(bean.getStringList().get(0).equals("value1"));
    assertTrue(bean.getStringList().get(1).equals("value2"));
    assertTrue(bean.getStringList().get(2).equals("value3"));
  }