Examples of TextControl


Examples of org.araneaframework.uilib.form.control.TextControl

   */
  public void testPersonalIdControlSimpleValidation() throws Exception {
    MockHttpServletRequest correctValueRequest = new MockHttpServletRequest();
    correctValueRequest.addParameter("myPersonalIdInput", "38304280235");
   
    TextControl pic = new TextControl(TextType.EST_PERSONAL_ID);
    pic._getComponent().init(new MockEnviroment());
    MockUiLibUtil.emulateHandleRequest(pic, "myPersonalIdInput", correctValueRequest);
    pic.convertAndValidate();
   
    assertTrue("Personal id control must be valid.", pic.isValid());
    assertTrue("Personal id control value must be a 'String'.", pic.getRawValue() instanceof String);
    assertTrue("Personal id control value must be '38304280235'.", ((String) pic.getRawValue()).equals("38304280235"));
    
    MockHttpServletRequest incorrectValueRequest = new MockHttpServletRequest();
    incorrectValueRequest.addParameter("myPersonalIdInput", "abcd");
   
    MockUiLibUtil.emulateHandleRequest(pic, "myPersonalIdInput", incorrectValueRequest);
    pic.convertAndValidate();   
   
    assertTrue("Personal id control mustn't be valid.", !pic.isValid());
   
    pic._getComponent().destroy();
  }
View Full Code Here

Examples of org.araneaframework.uilib.form.control.TextControl

  public void testTextboxControlMinMaxValidation() throws Exception {
    //Basic
    MockHttpServletRequest correctValueRequest = new MockHttpServletRequest();
    correctValueRequest.addParameter("myTextBox", "i love me");
   
    TextControl tc = new TextControl();
    tc._getComponent().init(new MockEnviroment());
   
    tc.setMinLength(new Long(5));
    tc.setMaxLength(new Long(20));
   
    MockUiLibUtil.emulateHandleRequest(tc, "myTextBox", correctValueRequest);
    tc.convertAndValidate();
   
    assertTrue("Textbox control must be valid.", tc.isValid());   
    assertTrue("Textbox control value must be 'i love me'.", ((String) tc.getRawValue()).equals("i love me"));
    
    //Too short

    MockHttpServletRequest tooShortValueRequest = new MockHttpServletRequest();
    tooShortValueRequest.addParameter("myTextBox", "boo");
   
    MockUiLibUtil.emulateHandleRequest(tc, "myTextBox", tooShortValueRequest);
    tc.convertAndValidate();   
   
    assertTrue("Textbox control mustn't be valid.", !tc.isValid());
   
    //Too long
   
    MockHttpServletRequest tooLongValueRequest = new MockHttpServletRequest();
    tooLongValueRequest.addParameter("myTextBox", "i love myself and others very very much");
   
    MockUiLibUtil.emulateHandleRequest(tc, "myTextBox", tooLongValueRequest);  
    tc.convertAndValidate();   
   
    assertTrue("Textbox control mustn't be valid.", !tc.isValid())
         
    //min=max correct
   
    tc.setMinLength(new Long(10));
    tc.setMaxLength(new Long(10));

    correctValueRequest = new MockHttpServletRequest();
    correctValueRequest.addParameter("myTextBox", "1234567890");
   
    MockUiLibUtil.emulateHandleRequest(tc, "myTextBox", correctValueRequest);
    tc.convertAndValidate();
       
    assertTrue("Textbox control must be valid.", tc.isValid());   
    assertTrue("Textbox control value must be '1234567890'.", ((String) tc.getRawValue()).equals("1234567890"));
   
    //min=max too short

    tooShortValueRequest.addParameter("myTextBox", "123456789");
   
    MockUiLibUtil.emulateHandleRequest(tc, "myTextBox", tooShortValueRequest);
    tc.convertAndValidate();
       
    assertTrue("Textbox control mustn't be valid.", !tc.isValid());   
   
    //min=max too long

    tooShortValueRequest.addParameter("myTextBox", "12345678901");
   
    MockUiLibUtil.emulateHandleRequest(tc, "myTextBox", tooShortValueRequest);  
    tc.convertAndValidate();
       
    assertTrue("Textbox control mustn't be valid.", !tc.isValid())
   
    tc._getComponent().destroy();
 
View Full Code Here

Examples of org.araneaframework.uilib.form.control.TextControl

    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");
View Full Code Here

Examples of org.xhtmlrenderer.simple.xhtml.controls.TextControl

    }

    protected Control createSWTControl(FormControl control,
            BasicRenderer parent, LayoutContext c, CalculatedStyle style,
            UserAgentCallback uac) {
        final TextControl tc = (TextControl) control;

        int sty = SWT.BORDER;
        if (tc.isMultiLine()) {
            sty |= SWT.MULTI;
        }
        if (tc.isReadOnly()) {
            sty |= SWT.READ_ONLY;
        }
        if (tc.isPassword()) {
            sty |= SWT.PASSWORD;
        }
        final Text text = new Text(parent, sty);
        text.setText(encodeDelimiter(control.getInitialValue()));

        StringBuffer str = new StringBuffer(tc.getSize());
        for (int i = 0; i < tc.getSize(); i++) {
            str.append('M');
        }
        if (tc.isMultiLine()) {
            for (int i = 1; i < tc.getRows(); i++) {
                str.append(Text.DELIMITER);
            }
        }
        _sizeText = str.toString();

        if (tc.getMaxLength() >= 0) {
            text.setTextLimit(tc.getMaxLength());
        }

        tc.addFormControlListener(new FormControlAdapter() {
            public void changed(FormControl control) {
                if (!_noChangeText) {
                    text.setText(encodeDelimiter(control.getValue()));
                }
                _noChangeText = false;
            }
        });

        text.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent e) {
                _noChangeText = true;
                tc.setValue(decodeDelimiter(text.getText()));
            }
        });

        return text;
    }
View Full Code Here

Examples of org.xhtmlrenderer.simple.xhtml.controls.TextControl

        FormControl control;
        String name = e.getNodeName();
        if (name.equals("input")) {
            String type = e.getAttribute("type");
            if (type.equals("text") || type.equals("password")) {
                control = new TextControl(form, e);
            } else if (type.equals("hidden")) {
                control = new HiddenControl(form, e);
            } else if (type.equals("button") || type.equals("submit")
                    || type.equals("reset")) {
                control = new ButtonControl(form, e);
            } else if (type.equals("checkbox") || type.equals("radio")) {
                control = new CheckControl(form, e);
            } else {
                return null;
            }
        } else if (name.equals("textarea")) {
            control = new TextControl(form, e);
        } else if (name.equals("button")) {
            control = new ButtonControl(form, e);
        } else if (name.equals("select")) {
            control = new SelectControl(form, e);
        } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.