Search in sources :

Example 6 with InputElement

use of org.gwtproject.dom.client.InputElement in project gwtproject by treblereel.

the class CheckBoxTest method testConstructorInputElement.

public void testConstructorInputElement() {
    InputElement elm = DOM.createInputCheck().cast();
    CheckBox box = new CheckBox(elm.<Element>cast());
    assertFalse(box.getValue());
    elm.setDefaultChecked(true);
    assertTrue(box.getValue());
}
Also used : InputElement(org.gwtproject.dom.client.InputElement)

Example 7 with InputElement

use of org.gwtproject.dom.client.InputElement in project gwtproject by treblereel.

the class CheckBoxTest method testReplaceInputElement.

public void testReplaceInputElement() {
    cb.setValue(true);
    cb.setTabIndex(1234);
    cb.setEnabled(false);
    cb.setAccessKey('k');
    cb.setFormValue("valuable");
    InputElement elm = Document.get().createCheckInputElement();
    assertFalse(elm.isChecked());
    Element asOldElement = elm.cast();
    cb.replaceInputElement(asOldElement);
    // The values should be preserved
    assertTrue(cb.getValue());
    assertEquals(1234, cb.getTabIndex());
    assertFalse(cb.isEnabled());
    assertEquals("k", elm.getAccessKey());
    assertEquals("valuable", cb.getFormValue());
    assertTrue(elm.isChecked());
    cb.setValue(false);
    assertFalse(elm.isChecked());
    elm.setChecked(true);
    assertTrue(cb.getValue());
}
Also used : InputElement(org.gwtproject.dom.client.InputElement) Element(org.gwtproject.dom.client.Element) InputElement(org.gwtproject.dom.client.InputElement)

Example 8 with InputElement

use of org.gwtproject.dom.client.InputElement in project gwtproject by treblereel.

the class CheckBoxTest method testDetachment.

/**
 * Tests that detaching and attaching a CheckBox widget retains the checked
 * state of the element. This is known to be tricky on IE.
 */
public void testDetachment() {
    InputElement elm = DOM.createInputCheck().cast();
    CheckBox box = new CheckBox(elm.<Element>cast());
    RootPanel.get().add(box);
    elm.setChecked(true);
    RootPanel.get().remove(box);
    RootPanel.get().add(box);
    assertTrue(elm.isChecked());
}
Also used : InputElement(org.gwtproject.dom.client.InputElement)

Example 9 with InputElement

use of org.gwtproject.dom.client.InputElement in project gwtproject by treblereel.

the class FormPanelTest method testNamedTargetSubmitEvent.

public void testNamedTargetSubmitEvent() {
    // Create a form and frame in the document we can wrap.
    String iframeId = Document.get().createUniqueId();
    String iframeName = Document.get().createUniqueId();
    final Element container = Document.get().createDivElement();
    container.setInnerHTML("<form method='post' target='" + iframeName + "' action='" + "formHandler?sendHappyHtml'>" + "<input type='submit' id='submitBtn'></input></form>" + "<iframe src=\"javascript:\'\'\" id='" + iframeId + "' " + "name='" + iframeName + "'></iframe>");
    Document.get().getBody().appendChild(container);
    // Wrap the form and make sure its target frame is intact.
    FormPanel form = FormPanel.wrap(container.getFirstChildElement());
    assertEquals(iframeName, form.getTarget());
    // Ensure that no synthesized iframe was created.
    assertNull(form.getSynthesizedIFrame());
    // Submit the form using the submit button and make sure the submit event fires.
    delayTestFinish(TEST_DELAY);
    form.addSubmitHandler(new SubmitHandler() {

        @Override
        public void onSubmit(SubmitEvent event) {
            finishTest();
        }
    });
    Document.get().getElementById("submitBtn").<InputElement>cast().click();
}
Also used : HTMLIFrameElement(elemental2.dom.HTMLIFrameElement) InputElement(org.gwtproject.dom.client.InputElement) Element(org.gwtproject.dom.client.Element) SubmitHandler(org.gwtproject.user.client.ui.FormPanel.SubmitHandler) SubmitEvent(org.gwtproject.user.client.ui.FormPanel.SubmitEvent)

Example 10 with InputElement

use of org.gwtproject.dom.client.InputElement in project gwtproject by treblereel.

the class RadioButtonTest method disabledTestValueChangeViaClick.

/**
 * TODO: Re-enable when we figure out how to make them work properly on IE
 * (which has the unfortunate property of not passing synthesized events on to
 * native controls, keeping the clicks created by these tests from actually
 * affecting the radio buttons' states).
 */
public void disabledTestValueChangeViaClick() {
    RadioButton r1 = new RadioButton("group1", "Radio 1");
    RadioButton r2 = new RadioButton("group1", "Radio 2");
    RootPanel.get().add(r1);
    RootPanel.get().add(r2);
    r1.setValue(true);
    Changeable c1 = new Changeable();
    r1.addValueChangeHandler(c1);
    Changeable c2 = new Changeable();
    r2.addValueChangeHandler(c2);
    // Brittle, but there's no public access
    InputElement r1Radio = getRadioElement(r1);
    InputElement r2Radio = getRadioElement(r2);
    doClick(r1Radio);
    assertEquals(null, c1.received);
    assertEquals(null, c2.received);
    doClick(r2Radio);
    assertEquals(null, c1.received);
    assertEquals(Boolean.TRUE, c2.received);
    c2.received = null;
    doClick(r1Radio);
    assertEquals(Boolean.TRUE, c1.received);
    assertEquals(null, c2.received);
}
Also used : InputElement(org.gwtproject.dom.client.InputElement)

Aggregations

InputElement (org.gwtproject.dom.client.InputElement)13 Element (org.gwtproject.dom.client.Element)6 ViewData (org.gwtproject.cell.client.EditTextCell.ViewData)2 HTMLIFrameElement (elemental2.dom.HTMLIFrameElement)1 Context (org.gwtproject.cell.client.Cell.Context)1 NativeEvent (org.gwtproject.dom.client.NativeEvent)1 SubmitEvent (org.gwtproject.user.client.ui.FormPanel.SubmitEvent)1 SubmitHandler (org.gwtproject.user.client.ui.FormPanel.SubmitHandler)1