Package org.araneaframework.uilib.form.control

Examples of org.araneaframework.uilib.form.control.NumberControl$ViewModel


      FormListUtil.addAddButtonToAddForm("#", formList, addForm);
    }

    private void addCommonFormFields(FormWidget form) throws Exception {
      form.addElement("stringField", "#String field", new TextControl(), new StringData(), true);
      form.addElement("longField", "#Long field", new NumberControl(), new LongData(), true);
      form.addElement("booleanField", "#Boolean field", new CheckboxControl(), new BooleanData(), true);
    }
View Full Code Here


      FormListUtil.addAddButtonToAddForm("#", editableRows, addForm);
    }

    private void addCommonFormFields(FormWidget form) throws Exception {
      form.addElement("stringField", "#String field", new TextControl(), new StringData(), true);
      form.addElement("longField", "#Long field", new NumberControl(), new LongData(), true);
      form.addElement("booleanField", "#Boolean field", new CheckboxControl(), new BooleanData(), true);
    }
View Full Code Here

      FormListUtil.addAddButtonToAddForm("#", formList, addForm);
    }

    private void addCommonFormFields(FormWidget form) throws Exception {
      form.addElement("stringField", "#String field", new TextControl(), new StringData(), true);
      form.addElement("longField", "#Long field", new NumberControl(), new LongData(), true);
      form.addElement("booleanField", "#Boolean field", new CheckboxControl(), new BooleanData(), true);
    }
View Full Code Here

   */
  public void testNumberControlSimpleValidation() throws Exception {
    MockHttpServletRequest correctValueRequest = new MockHttpServletRequest();
    correctValueRequest.addParameter("myNumberInput", "108");
   
    NumberControl nc = new NumberControl();
    nc._getComponent().init(new MockEnviroment());
    MockUiLibUtil.emulateHandleRequest(nc, "myNumberInput", correctValueRequest);
    nc.convertAndValidate();
   
    assertTrue("Number control must be valid.", nc.isValid());
    assertTrue("Number control value must be a 'BigInteger'.", nc.getRawValue() instanceof BigInteger);
    assertTrue("Number control value must be '108'.", ((BigInteger) nc.getRawValue()).longValue() == 108L);

    MockHttpServletRequest incorrectValueRequest = new MockHttpServletRequest();
    incorrectValueRequest.addParameter("myNumberInput", "abcd");
   
    MockUiLibUtil.emulateHandleRequest(nc, "myNumberInput", incorrectValueRequest);
    nc.convertAndValidate();   
   
    assertTrue("Number control mustn't be valid.", !nc.isValid());
   
    nc._getComponent().destroy();
  }
View Full Code Here

   */
  public void testNumberControlMinMaxValidation() throws Exception {
    MockHttpServletRequest correctValueRequest = new MockHttpServletRequest();
    correctValueRequest.addParameter("myNumberInput", "50");
   
    NumberControl nc = new NumberControl();
    nc._getComponent().init(new MockEnviroment());
   
    nc.setMinValue(new BigInteger("25"));
    nc.setMaxValue(new BigInteger("75"));
   
    MockUiLibUtil.emulateHandleRequest(nc, "myNumberInput", correctValueRequest);
    nc.convertAndValidate();
   
    assertTrue("Number control must be valid.", nc.isValid());   
    assertTrue("Number control value must be '50'.", ((BigInteger) nc.getRawValue()).longValue() == 50L);
   
    MockHttpServletRequest tooLittleValueRequest = new MockHttpServletRequest();
    tooLittleValueRequest.addParameter("myNumberInput", "20");
   
    MockUiLibUtil.emulateHandleRequest(nc, "myNumberInput", tooLittleValueRequest);
    nc.convertAndValidate();   
   
    assertTrue("Number control mustn't be valid.", !nc.isValid());
      
    MockHttpServletRequest tooBigValueRequest = new MockHttpServletRequest();
    tooBigValueRequest.addParameter("myNumberInput", "80");
   
    MockUiLibUtil.emulateHandleRequest(nc, "myNumberInput", tooBigValueRequest);
    nc.convertAndValidate();   
   
    assertTrue("Number control mustn't be valid.", !nc.isValid());
   
    nc._getComponent().destroy();
  }
View Full Code Here

TOP

Related Classes of org.araneaframework.uilib.form.control.NumberControl$ViewModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.