Example #1
0
  /**
   * Returns <tt>true</tt> if the specified element gets submitted when this form is submitted,
   * assuming that the form is submitted using the specified submit element.
   *
   * @param element the element to check
   * @param submitElement the element used to submit the form, or <tt>null</tt> if the form is
   *     submitted by JavaScript
   * @return <tt>true</tt> if the specified element gets submitted when this form is submitted
   */
  private boolean isSubmittable(final HtmlElement element, final SubmittableElement submitElement) {
    final String tagName = element.getTagName();
    if (!isValidForSubmission(element, submitElement)) {
      return false;
    }

    // The one submit button that was clicked can be submitted but no other ones
    if (element == submitElement) {
      return true;
    }
    if (element instanceof HtmlInput) {
      final HtmlInput input = (HtmlInput) element;
      final String type = input.getTypeAttribute().toLowerCase(Locale.ENGLISH);
      if ("submit".equals(type)
          || "image".equals(type)
          || "reset".equals(type)
          || "button".equals(type)) {
        return false;
      }
    }
    if ("button".equals(tagName)) {
      return false;
    }

    return true;
  }
Example #2
0
 /**
  * Tries to set the values of all the inputs in the TablePanel to the corresponding ones in the
  * request tuple.
  *
  * @param request
  */
 @SuppressWarnings("unchecked")
 public void setValuesFromRequest(Tuple request) {
   Object object;
   List<HtmlInput<?>> inputList = new ArrayList<HtmlInput<?>>();
   fillList(inputList, this);
   for (@SuppressWarnings("rawtypes") HtmlInput input : inputList) {
     object = request.getObject(input.getName());
     if (object != null) {
       input.setValue(object);
     }
   }
 }
Example #3
0
 @Override
 /** Each input is rendered with a label and in its own div to enable scripting. */
 public String toHtml() {
   String result = "";
   for (HtmlInput<?> i : this.inputs.values()) {
     result += "<div style=\"clear:both; ";
     if (i.isHidden()) {
       result += "display:none\"";
     } else {
       result += "display:block\"";
     }
     if (i.getId() != null) {
       result += (" id=\"div" + i.getId() + "\"");
     }
     result +=
         "><label style=\"width:16em;float:left;\" for=\""
             + i.getName()
             + "\">"
             + i.getLabel()
             + "</label>"
             + i.toHtml()
             + (!i.isNillable() ? " *" : "")
             + "</div>";
   }
   return result;
 }
Example #4
0
 /** {@inheritDoc} */
 @Override
 void removeFocus() {
   super.removeFocus();
   if (!valueAtFocus_.equals(getText())) {
     HtmlInput.executeOnChangeHandlerIfAppropriate(this);
   }
   valueAtFocus_ = null;
 }
Example #5
0
 /** {@inheritDoc} */
 @Override
 public void setAttributeNS(
     final String namespaceURI, final String qualifiedName, final String attributeValue) {
   if (hasFeature(HTMLINPUT_SET_VALUE_UPDATES_DEFAULT_VALUE) && "value".equals(qualifiedName)) {
     setDefaultValue(attributeValue, false);
   }
   super.setAttributeNS(namespaceURI, qualifiedName, attributeValue);
 }
  @Override
  void removeFocus() {
    super.removeFocus();

    if (!valueAtFocus_.equals(getValueAttribute())) {
      executeOnChangeHandlerIfAppropriate(this);
    }
    valueAtFocus_ = null;
  }
  public void testAjaxTagEventAttribute() throws Exception {
    getPage("/faces/ajax/ajaxTagEventAttribute.xhtml");
    System.out.println("Start ajax tag event attribute test");

    // Check initial values
    checkTrue("out1", "0");
    checkTrue("out2", "1");
    checkTrue("out3", "");
    checkTrue("checkedvalue1", "false");
    checkTrue("checkedvalue2", "false");

    // Press Count
    HtmlSubmitInput button = (HtmlSubmitInput) lastpage.getHtmlElementById("button");
    lastpage = (HtmlPage) button.click();

    checkTrue("out1", "0");
    checkTrue("out2", "0");

    HtmlInput input = (HtmlInput) lastpage.getHtmlElementById("in1");
    lastpage = (HtmlPage) input.setValueAttribute("test");

    checkTrue("out3", "test");

    // Check ajax checkbox
    HtmlCheckBoxInput checked = ((HtmlCheckBoxInput) lastpage.getHtmlElementById("checkbox1"));
    lastpage = (HtmlPage) checked.click();

    checkTrue("checkedvalue1", "true");

    // Check ajax checkbox
    checked = ((HtmlCheckBoxInput) lastpage.getHtmlElementById("checkbox2"));
    lastpage = (HtmlPage) checked.click();

    checkTrue("checkedvalue2", "true");

    // Check ajax checkbox
    checked = ((HtmlCheckBoxInput) lastpage.getHtmlElementById("checkbox3"));
    lastpage = (HtmlPage) checked.click();

    checkTrue("checkedvalue3", "true");

    // Check that all ajax requests didn't result in a reload
    checkTrue("out4", "2");
  }
Example #8
0
 /** {@inheritDoc} */
 @Override
 protected boolean doClickStateUpdate() throws IOException {
   final HtmlForm form = getEnclosingForm();
   if (form != null) {
     form.reset();
     return false;
   }
   super.doClickStateUpdate();
   return false;
 }
Example #9
0
 /**
  * Removes the given inputs from the TablePanel.
  *
  * @param HtmlInput ... inputs
  */
 public void remove(HtmlInput<?>... inputs) {
   for (HtmlInput<?> input : inputs) {
     this.inputs.remove(input.getName());
   }
 }
Example #10
0
 /**
  * Adds the given inputs to the TablePanel.
  *
  * @param HtmlInput ... inputs
  */
 public void add(HtmlInput<?>... inputs) {
   for (HtmlInput<?> input : inputs) {
     this.inputs.put(input.getName(), input);
   }
 }
 /** {@inheritDoc} */
 @Override
 public void focus() {
   super.focus();
   // store current value to trigger onchange when needed at focus lost
   valueAtFocus_ = getValueAttribute();
 }
Example #12
0
  /**
   * Sets the new value of this text area.
   *
   * <p>Note that this acts like 'pasting' the text, but to simulate characters entry you should use
   * {@link #type(String)}.
   *
   * @param newValue the new value
   */
  public final void setText(final String newValue) {
    initDefaultValue();
    setTextInternal(newValue);

    HtmlInput.executeOnChangeHandlerIfAppropriate(this);
  }