Exemplo n.º 1
0
  protected void handleSubmitCommand() {
    Item submitItem = this.browser.getFocusedItem();
    HtmlForm form = (HtmlForm) submitItem.getAttribute(ATTR_FORM);
    while (form == null && (submitItem instanceof Container)) {
      submitItem = ((Container) submitItem).getFocusedItem();
      form = (HtmlForm) submitItem.getAttribute(ATTR_FORM);
    }
    if (form == null) {
      return;
    }

    form.submit(submitItem);
  }
Exemplo n.º 2
0
 /**
  * Retrieves the currently focused item that has specified the attribute
  *
  * @param attribute the attribute
  * @param container the container that should have focused the item
  * @return the item that contains the attribute or the focused item which is not a Container
  *     itself
  */
 protected Item getFocusedItemWithAttribute(String attribute, Container container) {
   Item item = container.getFocusedItem();
   if (item != null && item.getAttribute(attribute) == null && item instanceof Container) {
     return getFocusedItemWithAttribute(attribute, (Container) item);
   }
   return item;
 }
Exemplo n.º 3
0
  protected void handleLinkCommand() {

    Item linkItem = getFocusedItemWithAttribute(ATTR_HREF, this.browser);
    if (linkItem == null) {
      return;
    }
    String href = (String) linkItem.getAttribute(ATTR_HREF);
    if (href != null) {
      this.browser.go(this.browser.makeAbsoluteURL(href));
    }
    // #if polish.debug.error
    else {
      // #debug error
      System.out.println(
          "Unable to handle link command for item "
              + linkItem
              + ": no "
              + ATTR_HREF
              + " attribute found.");
    }
    // #endif
  }