/** * Submit the form that contains this input. Only a couple of the inputs * support this method so it is made protected here. Those subclasses * that wish to expose it will override and make it public. * * @return the Page that is the result of submitting this page to the server * @exception IOException If an IO error occurs */ @Override @SuppressWarnings("unchecked") public Page click() throws IOException { return click(0, 0); }
/** * {@inheritDoc} */ @Override public NameValuePair[] getSubmitKeyValuePairs() { final String name = getNameAttribute(); final String prefix; // a clicked image without name sends parameter x and y if (StringUtils.isEmpty(name)) { prefix = ""; } else { prefix = name + "."; } if (wasPositionSpecified_) { final NameValuePair valueX = new NameValuePair(prefix + 'x', String.valueOf(xPosition_)); final NameValuePair valueY = new NameValuePair(prefix + 'y', String.valueOf(yPosition_)); if (prefix.length() > 0 && getPage().getWebClient().getBrowserVersion().isFirefox()) { return new NameValuePair[] {valueX, valueY, new NameValuePair(getNameAttribute(), getValueAttribute()) }; } return new NameValuePair[] {valueX, valueY}; } return new NameValuePair[]{new NameValuePair(getNameAttribute(), getValueAttribute())}; }
/** * {@inheritDoc} Also sets the value to the new default value, just like IE. * @see SubmittableElement#setDefaultValue(String) */ @Override public void setDefaultValue(final String defaultValue) { super.setDefaultValue(defaultValue); setValueAttribute(defaultValue); } }
/** * {@inheritDoc} */ @Override public NameValuePair[] getSubmitNameValuePairs() { final String name = getNameAttribute(); final String prefix; // a clicked image without name sends parameter x and y if (StringUtils.isEmpty(name)) { prefix = ""; } else { prefix = name + "."; } if (wasPositionSpecified_) { final NameValuePair valueX = new NameValuePair(prefix + 'x', Integer.toString(xPosition_)); final NameValuePair valueY = new NameValuePair(prefix + 'y', Integer.toString(yPosition_)); if (!prefix.isEmpty() && hasFeature(HTMLIMAGE_NAME_VALUE_PARAMS) && !getValueAttribute().isEmpty()) { return new NameValuePair[] {valueX, valueY, new NameValuePair(getNameAttribute(), getValueAttribute()) }; } return new NameValuePair[] {valueX, valueY}; } return new NameValuePair[]{new NameValuePair(getNameAttribute(), getValueAttribute())}; }
if (inpt.getValueAttribute().equals(buttonValue)) { inpt.click(); return;
result = new HtmlImageInput(namespaceURI, qualifiedName, page, attributeMap);
if (btn.getValueAttribute().equals(buttonValue)) { if (form == null) { form = btn.getEnclosingFormOrDie();
/** * {@inheritDoc} * @throws IOException if an IO error occurred */ @Override protected boolean doClickStateUpdate(final boolean shiftKey, final boolean ctrlKey) throws IOException { final HtmlForm form = getEnclosingForm(); if (form != null) { form.submit(this); return false; } super.doClickStateUpdate(shiftKey, ctrlKey); return false; }
/** * <p>Downloads the image contained by this image element.</p> * <p><span style="color:red">POTENTIAL PERFORMANCE KILLER - DOWNLOADS THE IMAGE - USE AT YOUR OWN RISK</span></p> * <p>If the image has not already been downloaded, this method triggers a download and caches the image.</p> * * @throws IOException if an error occurs while downloading the image */ private void downloadImageIfNeeded() throws IOException { if (!downloaded_) { // HTMLIMAGE_BLANK_SRC_AS_EMPTY final String src = getSrcAttribute(); if (!"".equals(src) && !(hasFeature(HTMLIMAGE_BLANK_SRC_AS_EMPTY) && StringUtils.isBlank(src))) { final HtmlPage page = (HtmlPage) getPage(); final WebClient webclient = page.getWebClient(); final URL url = page.getFullyQualifiedUrl(src); final String accept = webclient.getBrowserVersion().getImgAcceptHeader(); final WebRequest request = new WebRequest(url, accept); request.setCharset(page.getCharset()); request.setAdditionalHeader(HttpHeader.REFERER, page.getUrl().toExternalForm()); imageWebResponse_ = webclient.loadWebResponse(request); } if (imageData_ != null) { imageData_.close(); imageData_ = null; } downloaded_ = hasFeature(JS_IMAGE_COMPLETE_RETURNS_TRUE_FOR_NO_REQUEST) || (imageWebResponse_ != null && imageWebResponse_.getContentType().contains("image")); } }
HtmlImageInput btn = (HtmlImageInput) o; if (form == null) { form = btn.getEnclosingFormOrDie();
private boolean isSubmitElement(HtmlElement element) { HtmlElement candidate = null; if (element instanceof HtmlSubmitInput && !((HtmlSubmitInput)element).isDisabled()) candidate = element; else if (element instanceof HtmlImageInput && !((HtmlImageInput)element).isDisabled()) candidate = element; else if (element instanceof HtmlButton) { HtmlButton button = (HtmlButton) element; if ("submit".equalsIgnoreCase(button.getTypeAttribute()) && !button.isDisabled()) candidate = element; } return candidate != null; }
/** * {@inheritDoc} */ @Override public NameValuePair[] getSubmitNameValuePairs() { final String name = getNameAttribute(); final String prefix; // a clicked image without name sends parameter x and y if (StringUtils.isEmpty(name)) { prefix = ""; } else { prefix = name + "."; } if (wasPositionSpecified_) { final NameValuePair valueX = new NameValuePair(prefix + 'x', Integer.toString(xPosition_)); final NameValuePair valueY = new NameValuePair(prefix + 'y', Integer.toString(yPosition_)); if (!prefix.isEmpty() && hasFeature(HTMLIMAGE_NAME_VALUE_PARAMS) && !getValueAttribute().isEmpty()) { return new NameValuePair[] {valueX, valueY, new NameValuePair(getNameAttribute(), getValueAttribute()) }; } return new NameValuePair[] {valueX, valueY}; } return new NameValuePair[]{new NameValuePair(getNameAttribute(), getValueAttribute())}; }
result = new HtmlImageInput(namespaceURI, qualifiedName, page, attributeMap);
/** * {@inheritDoc} * @throws IOException if an IO error occurred */ @Override protected boolean doClickStateUpdate(final boolean shiftKey, final boolean ctrlKey) throws IOException { final HtmlForm form = getEnclosingForm(); if (form != null) { form.submit(this); return false; } super.doClickStateUpdate(shiftKey, ctrlKey); return false; }
/** * <p>Downloads the image contained by this image element.</p> * <p><span style="color:red">POTENTIAL PERFORMANCE KILLER - DOWNLOADS THE IMAGE - USE AT YOUR OWN RISK</span></p> * <p>If the image has not already been downloaded, this method triggers a download and caches the image.</p> * * @throws IOException if an error occurs while downloading the image */ private void downloadImageIfNeeded() throws IOException { if (!downloaded_) { // HTMLIMAGE_BLANK_SRC_AS_EMPTY final String src = getSrcAttribute(); if (!"".equals(src) && !(hasFeature(HTMLIMAGE_BLANK_SRC_AS_EMPTY) && StringUtils.isBlank(src))) { final HtmlPage page = (HtmlPage) getPage(); final WebClient webclient = page.getWebClient(); final URL url = page.getFullyQualifiedUrl(src); final String accept = webclient.getBrowserVersion().getImgAcceptHeader(); final WebRequest request = new WebRequest(url, accept); request.setCharset(page.getCharset()); request.setAdditionalHeader(HttpHeader.REFERER, page.getUrl().toExternalForm()); imageWebResponse_ = webclient.loadWebResponse(request); } if (imageData_ != null) { imageData_.close(); imageData_ = null; } downloaded_ = hasFeature(JS_IMAGE_COMPLETE_RETURNS_TRUE_FOR_NO_REQUEST) || (imageWebResponse_ != null && imageWebResponse_.getContentType().contains("image")); } }
HtmlImageInput btn = (HtmlImageInput) o; if (form == null) { form = btn.getEnclosingFormOrDie();
private boolean isSubmitElement(HtmlElement element) { HtmlElement candidate = null; if (element instanceof HtmlSubmitInput && !((HtmlSubmitInput) element).isDisabled()) { candidate = element; } else if (element instanceof HtmlImageInput && !((HtmlImageInput) element).isDisabled()) { candidate = element; } else if (element instanceof HtmlButton) { HtmlButton button = (HtmlButton) element; if ("submit".equalsIgnoreCase(button.getTypeAttribute()) && !button.isDisabled()) { candidate = element; } } return candidate != null; }
/** * {@inheritDoc} */ @Override public NameValuePair[] getSubmitKeyValuePairs() { final String name = getNameAttribute(); final String prefix; // a clicked image without name sends parameter x and y if (StringUtils.isEmpty(name)) { prefix = ""; } else { prefix = name + "."; } if (wasPositionSpecified_) { final NameValuePair valueX = new NameValuePair(prefix + 'x', String.valueOf(xPosition_)); final NameValuePair valueY = new NameValuePair(prefix + 'y', String.valueOf(yPosition_)); if (prefix.length() > 0 && getPage().getWebClient().getBrowserVersion().isFirefox()) { return new NameValuePair[] {valueX, valueY, new NameValuePair(getNameAttribute(), getValueAttribute()) }; } return new NameValuePair[] {valueX, valueY}; } return new NameValuePair[]{new NameValuePair(getNameAttribute(), getValueAttribute())}; }
/** * Submit the form that contains this input. Only a couple of the inputs * support this method so it is made protected here. Those subclasses * that wish to expose it will override and make it public. * * @return the Page that is the result of submitting this page to the server * @exception IOException If an io error occurs */ @Override @SuppressWarnings("unchecked") public Page click() throws IOException { return click(0, 0); }
result = new HtmlImageInput(namespaceURI, qualifiedName, page, attributeMap);