Package org.araneaframework.uilib.form

Examples of org.araneaframework.uilib.form.FormWidget


  /**
   * Tests basic Value Object reading.
   */
  public void testFormBasicVoReading() throws Exception {

    FormWidget voForm = makeVoForm();
    TestVO test = new TestVO();

    final String LIFE_IS_BEAUTIFUL = "Life is beautiful";
    final Long TEN = new Long(10);

    voForm.setValueByFullName("booleanValue", Boolean.TRUE);
    voForm.setValueByFullName("stringValue", LIFE_IS_BEAUTIFUL);
    voForm.setValueByFullName("longValue", TEN);

    BeanFormReader voReader = new BeanFormReader(voForm);

    voReader.readFormBean(test);

View Full Code Here


  /**
   * Tests hierarchical Value Object reading.
   */
  public void testFormHierarchicalVoReading() throws Exception {

    FormWidget voForm = makeVoForm();
    TestVO test = new TestVO();

    final String LIFE_IS_BEAUTIFUL = "Life is beautiful";
    final Long TEN = new Long(10);  

    voForm.setValueByFullName("subTestVO.booleanValue", Boolean.TRUE);
    voForm.setValueByFullName("subTestVO.stringValue", LIFE_IS_BEAUTIFUL);
    voForm.setValueByFullName("subTestVO.longValue", TEN);

    BeanFormReader voReader = new BeanFormReader(voForm);

    voReader.readFormBean(test);

View Full Code Here

  /**
   * Tests basic Value Object writing.
   */
  public void testFormBasicVoWriting() throws Exception {

    FormWidget voForm = makeVoForm();
    TestVO test = new TestVO();

    final String LIFE_IS_BEAUTIFUL = "Life is beautiful";
    final Long TEN = new Long(10);

    test.setBooleanValue(Boolean.TRUE);
    test.setStringValue(LIFE_IS_BEAUTIFUL);
    test.setLongValue(TEN);

    BeanFormWriter voWriter = new BeanFormWriter(test.getClass());

    voWriter.writeFormBean(voForm, test);

    assertTrue("Boolean value written properly", voForm.getValueByFullName("booleanValue").equals(Boolean.TRUE));
    assertTrue("String value written properly", voForm.getValueByFullName("stringValue").equals(LIFE_IS_BEAUTIFUL));
    assertTrue("Long value written properly", voForm.getValueByFullName("longValue").equals(TEN));
  }
View Full Code Here

  /**
   * Tests hierarchical Value Object writing.
   */
  public void testFormHierarchicalVoWriting() throws Exception {

    FormWidget voForm = makeVoForm();
    TestVO test = new TestVO();

    final String LIFE_IS_BEAUTIFUL = "Life is beautiful";
    final Long TEN = new Long(10);

    test.setSubTestVO(new TestVO());

    test.getSubTestVO().setBooleanValue(Boolean.TRUE);
    test.getSubTestVO().setStringValue(LIFE_IS_BEAUTIFUL);
    test.getSubTestVO().setLongValue(TEN);

    BeanFormWriter voWriter = new BeanFormWriter(test.getClass());

    voWriter.writeFormBean(voForm, test);

    assertTrue("Boolean value written properly", voForm.getValueByFullName("subTestVO.booleanValue").equals(Boolean.TRUE));
    assertTrue("String value written properly", voForm.getValueByFullName("subTestVO.stringValue").equals(LIFE_IS_BEAUTIFUL));
    assertTrue("Long value written properly", voForm.getValueByFullName("subTestVO.longValue").equals(TEN))}
View Full Code Here

  /**
   * Tests basic Map reading.
   */
  public void testFormBasicMapReading() throws Exception {

    FormWidget mapForm = makeVoForm();   

    final String LIFE_IS_BEAUTIFUL = "Life is beautiful";
    final Long TEN = new Long(10);

    mapForm.setValueByFullName("booleanValue", Boolean.TRUE);
    mapForm.setValueByFullName("stringValue", LIFE_IS_BEAUTIFUL);
    mapForm.setValueByFullName("longValue", TEN);

    MapFormReader mapReader = new MapFormReader(mapForm);

    Map readMap = mapReader.getMap();

View Full Code Here

  /**
   * Tests hierarchical Map reading.
   */
  public void testFormHierarchicalMapReading() throws Exception {

    FormWidget mapForm = makeVoForm();   

    final String LIFE_IS_BEAUTIFUL = "Life is beautiful";
    final Long TEN = new Long(10);

    mapForm.setValueByFullName("subTestVO.booleanValue", Boolean.TRUE);
    mapForm.setValueByFullName("subTestVO.stringValue", LIFE_IS_BEAUTIFUL);
    mapForm.setValueByFullName("subTestVO.longValue", TEN);
   
    MapFormReader mapReader = new MapFormReader(mapForm);

    Map readMap = mapReader.getMap();

View Full Code Here

  /**
   * Tests basic Map writing.
   */
  public void testFormBasicMapWriting() throws Exception {

    FormWidget mapForm = makeVoForm();
    Map testMap = new HashMap();

    final String LIFE_IS_BEAUTIFUL = "Life is beautiful";
    final Long TEN = new Long(10);

    testMap.put("booleanValue", Boolean.TRUE);
    testMap.put("stringValue", LIFE_IS_BEAUTIFUL);
    testMap.put("longValue", TEN);

    MapFormWriter mapWriter = new MapFormWriter();

    mapWriter.writeForm(mapForm, testMap);

    assertTrue("Boolean value written properly", mapForm.getValueByFullName("booleanValue").equals(Boolean.TRUE));
    assertTrue("String value written properly", mapForm.getValueByFullName("stringValue").equals(LIFE_IS_BEAUTIFUL));
    assertTrue("Long value written properly", mapForm.getValueByFullName("longValue").equals(TEN));
 
View Full Code Here

  /**
   * Tests hierarchical Map writing.
   */
  public void testFormHierarchicalMapWriting() throws Exception {

    FormWidget mapForm = makeVoForm();
    Map testMap = new HashMap();

    final String LIFE_IS_BEAUTIFUL = "Life is beautiful";
    final Long TEN = new Long(10);

    testMap.put("booleanValue", Boolean.TRUE);
    testMap.put("stringValue", LIFE_IS_BEAUTIFUL);
    testMap.put("longValue", TEN);
   
   
    Map topTestMap = new HashMap();
    topTestMap.put("subTestVO", testMap);   

    MapFormWriter mapWriter = new MapFormWriter();

    mapWriter.writeForm(mapForm, topTestMap);

    assertTrue("Boolean value written properly", mapForm.getValueByFullName("subTestVO.booleanValue").equals(Boolean.TRUE));
    assertTrue("String value written properly", mapForm.getValueByFullName("subTestVO.stringValue").equals(LIFE_IS_BEAUTIFUL));
    assertTrue("Long value written properly", mapForm.getValueByFullName("subTestVO.longValue").equals(TEN));
  }   
View Full Code Here

  boolean eventsWork = false;

  private FormWidget makeUsualForm() throws Exception {

    //Creating form :-)
    FormWidget testForm = new FormWidget();
    testForm._getComponent().init(new MockEnviroment());
   
    //Adding elements to form
    testForm.addElement("myCheckBox", "my checkbox", new CheckboxControl(), new BooleanData(), true);
    testForm.addElement("myLongText", "my long text", new TextControl(), new LongData(), true);
    testForm.addElement("myDateTime", "my date and time", new DateTimeControl(), new DateData(), false);
    testForm.addElement("myButton", "my button", new ButtonControl(), null, false);

    //Adding a composite element
    FormWidget hierarchyTest = testForm.addSubForm("hierarchyTest");
    hierarchyTest.addElement("myTextarea", "my text area", new TextareaControl(), new StringData(), true);

    //Filling in select control (which is under a composite element)
    FormElement mySelectElement = hierarchyTest.addElement("mySelect", "my drop down", new SelectControl(), new LongData(), true);
    SelectControl mySelect = (SelectControl) mySelectElement.getControl();
    mySelect.addItem(new DisplayItem("1", "one"));
    mySelect.addItem(new DisplayItem("2", "two"));
    mySelect.addItem(new DisplayItem("3", "three"));
    mySelect.addItem(new DisplayItem("4", "four"));
View Full Code Here

  /**
   * Testing reading from valid request.
   */
  public void testFormRequestHandling() throws Exception {

    FormWidget testForm = makeUsualForm();
   
    Widget currentWidget = testForm;
   
    MockHttpServletRequest validRequest = new MockHttpServletRequest();

    validRequest.addParameter("testForm.__present", "true");
    validRequest.addParameter("testForm.myCheckBox", "true");
    validRequest.addParameter("testForm.myLongText", "108");
    validRequest.addParameter("testForm.myDateTime.date", "11.10.2015");
    validRequest.addParameter("testForm.myDateTime.time", "01:01");
    validRequest.addParameter("testForm.hierarchyTest.myTextarea", "blah");
    validRequest.addParameter("testForm.hierarchyTest.mySelect", "2");   
   
   
    MockUiLibUtil.emulateHandleRequest(currentWidget, "testForm", validRequest);
    currentWidget._getWidget().process();             

    assertTrue(((StringArrayRequestControl.ViewModel) testForm.getControlByFullName("myCheckBox")._getViewable().getViewModel()).getSimpleValue().equals("true"));
    assertTrue(((StringArrayRequestControl.ViewModel) testForm.getControlByFullName("myLongText")._getViewable().getViewModel()).getSimpleValue().equals("108"));
    assertTrue(((StringArrayRequestControl.ViewModel) testForm.getControlByFullName("hierarchyTest.myTextarea")._getViewable().getViewModel()).getSimpleValue().equals("blah"));
    assertTrue(((StringArrayRequestControl.ViewModel) testForm.getControlByFullName("hierarchyTest.mySelect")._getViewable().getViewModel()).getSimpleValue().equals("2"));    
  }
View Full Code Here

TOP

Related Classes of org.araneaframework.uilib.form.FormWidget

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.