private String getEffectiveUrl() throws IOException { StringBuffer spec = new StringBuffer( getAction() ); if ("get".equalsIgnoreCase( getMethod() )) { URLEncodedString parameters = new URLEncodedString(); HTMLCollection controls = getElements(); for (int i = 0; i < controls.getLength(); i++) { ((HTMLControl) controls.item( i )).addValues( parameters, "us-ascii" ); } if ((spec.indexOf( "?" ) >= 0) && !(spec.toString().endsWith( "?" ))) { spec.append( '&' ); } else { spec.append( '?' ); } spec.append( parameters.getString() ); } return new URL( getDomWindow().getUrl(), spec.toString() ).toExternalForm(); }
public void setCells( HTMLCollection cells ) { Node child; int i; child = getFirstChild(); while ( child != null ) { removeChild( child ); child = child.getNextSibling(); } i = 0; child = cells.item( i ); while ( child != null ) { appendChild ( child ); ++i; child = cells.item( i ); } }
/** * Returns an array of form parameter attributes for this form. **/ private FormControl[] getFormControls() { HTMLCollection controlElements = _domElement.getElements(); FormControl[] controls = new FormControl[ controlElements.getLength() ]; for (int i = 0; i < controls.length; i++) { controls[i] = getControlForNode( controlElements.item( i ) ); } return controls; }
public Object get( String propertyName, Scriptable scriptable ) { HTMLCollection elements = getElements(); for (int i=0; i < elements.getLength(); i++) { Node node = elements.item( i ); NamedNodeMap attributes = node.getAttributes(); AttrImpl nameAttribute = (AttrImpl) attributes.getNamedItem( "name" ); if (nameAttribute != null && propertyName.equals( nameAttribute.getValue() )) return node; AttrImpl idAttribute = (AttrImpl) attributes.getNamedItem( "id" ); if (idAttribute != null && propertyName.equals( idAttribute.getValue() )) return node; } return super.get( propertyName, scriptable ); }
public HTMLCollection getElements() { ArrayList elements = new ArrayList(); String[] names = new String[]{"INPUT", "TEXTAREA", "BUTTON", "SELECT"}; for (Iterator each = preOrderIteratorAfterNode(); each.hasNext();) { Node node = (Node) each.next(); if (node instanceof HTMLFormElement) break; if (node.getNodeType() != ELEMENT_NODE) continue; String tagName = ((Element) node).getTagName(); for (int i = 0; i < names.length; i++) { if (tagName.equalsIgnoreCase( names[i] )) elements.add( node ); } } return HTMLCollectionImpl.createHTMLCollectionImpl( new NodeListImpl( elements ) ); }
public void reset() { HTMLCollection elements = getElements(); for (int i = 0; i < elements.getLength(); i++) { Node node = elements.item(i); if (node instanceof HTMLControl) ((HTMLControl) node).reset(); } }
private HTMLFormElement getPreviousForm( HTMLFormElement nextForm ) { HTMLCollection forms = getHtmlDocument().getForms(); for (int i = 0; i < forms.getLength(); i++) { if (nextForm == forms.item( i )) return i == 0 ? null : (HTMLFormElement) forms.item( i-1 ); } return null; }
public int getSelectedIndex() { HTMLCollection options = getOptions(); for (int i = 0; i < options.getLength(); i++) { if (((HTMLOptionElement)options.item(i)).getSelected()) return i; } return isMultiSelect() ? -1 : 0; }
public String getValue() { HTMLCollection options = getOptions(); for (int i = 0; i < options.getLength(); i++) { HTMLOptionElement optionElement = ((HTMLOptionElement)options.item(i)); if (optionElement.getSelected()) return optionElement.getValue(); } return (isMultiSelect() || options.getLength() == 0) ? null : ((HTMLOptionElement)options.item(0)).getValue(); }
public void setSelectedIndex( int selectedIndex ) { HTMLCollection options = getOptions(); for (int i = 0; i < options.getLength(); i++) { HTMLOptionElementImpl optionElement = (HTMLOptionElementImpl) options.item(i); optionElement.setSelected( i == selectedIndex ); } }
int getIndexOf( HTMLOptionElementImpl option ) { HTMLCollection options = getOptions(); for (int i = 0; i < options.getLength(); i++) { if (options.item(i) == option) return i; } throw new IllegalStateException( "option is not part of this select" ); }
void addValues( ParameterProcessor processor, String characterSet ) throws IOException { HTMLCollection options = getOptions(); String name = getName(); for (int i = 0; i < options.getLength();i++) { ((HTMLOptionElementImpl) options.item( i )).addValueIfSelected( processor, name, characterSet ); } }
public void reset() { HTMLCollection options = getOptions(); for (int i = 0; i < options.getLength(); i++) { HTMLControl optionElement = (HTMLControl) options.item(i); optionElement.reset(); } }
public void setChecked( boolean checked ) { if (checked) { HTMLCollection elements = getForm().getElements(); for (int i = 0; i < elements.getLength(); i++) { Node node = elements.item(i); if (!(node instanceof HTMLInputElementImpl)) continue; HTMLInputElementImpl input = (HTMLInputElementImpl) node; if (getName().equals( input.getName() ) && input.getType().equalsIgnoreCase( "radio" )) input.setState( false ); } } setState( checked ); }
/** * get Links for a given Node * @param rootNode * @return */ HTMLCollection getLinks( NodeImpl rootNode ) { ArrayList elements = new ArrayList(); for (Iterator each = rootNode.preOrderIteratorAfterNode( _iteratorMask ); each.hasNext();) { Node node = (Node) each.next(); if (node.getNodeType() != Node.ELEMENT_NODE) continue; if (ParsedHTML.isWebLink(node)) { elements.add( node ); } } return HTMLCollectionImpl.createHTMLCollectionImpl( new NodeListImpl( elements ) ); }
HTMLCollection getForms( NodeImpl rootNode ) { ArrayList elements = new ArrayList(); for (Iterator each = rootNode.preOrderIteratorAfterNode( _iteratorMask ); each.hasNext();) { Node node = (Node) each.next(); if (node.getNodeType() != Node.ELEMENT_NODE) continue; if ("form".equalsIgnoreCase( ((Element) node).getTagName() )) { elements.add( node ); } } return HTMLCollectionImpl.createHTMLCollectionImpl( new NodeListImpl( elements ) ); }
HTMLCollection getAnchors( NodeImpl rootNode ) { NodeList nodeList = rootNode.getElementsByTagName( "A" ); ArrayList elements = new ArrayList(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item( i ); if (node.getAttributes().getNamedItem( "name" ) != null) { elements.add( node ); } } return HTMLCollectionImpl.createHTMLCollectionImpl( new NodeListImpl( elements ) ); }
private void navigateImpl(final @NonNull URL href, final String target, final RequestType requestType, final Object linkObject) { if (logger.isLoggable(Level.INFO)) { logger.info("navigateImpl(): href=" + href + ",target=" + target); } // First check if target is a frame identifier. TargetType targetType; if (target != null) { final HtmlRendererContext topCtx = this.getTop(); final HTMLCollection frames = topCtx.getFrames(); if (frames != null) { final Node frame = frames.namedItem(target); if (frame instanceof FrameNode) { final BrowserFrame bframe = ((FrameNode) frame).getBrowserFrame(); if (bframe == null) { throw new IllegalStateException("Frame node without a BrowserFrame instance: " + frame); } if (bframe.getHtmlRendererContext() != this) { bframe.loadURL(href); return; } } } // Now try special target types. targetType = HtmlRendererContextImpl.getTargetType(target); } else { targetType = TargetType.SELF; } if (requestType == RequestType.CLICK) { this.clientletFrame.linkClicked(href, targetType, linkObject); } else { this.clientletFrame.navigate(href, "GET", null, targetType, requestType); } }
public HTMLCollection getFrames() { final Object rootNode = this.htmlPanel.getRootNode(); if (rootNode instanceof HTMLDocumentImpl) { return ((HTMLDocumentImpl) rootNode).getFrames(); } else { return null; } }
public HTMLCollection getImages() { // For more information see HTMLCollection#collectionMatch if ( _images == null ) _images = new HTMLCollectionImpl( getBody(), HTMLCollectionImpl.IMAGE ); return _images; }
public HTMLCollection getApplets() { // For more information see HTMLCollection#collectionMatch if ( _applets == null ) _applets = new HTMLCollectionImpl( getBody(), HTMLCollectionImpl.APPLET ); return _applets; }
public HTMLCollection getLinks() { // For more information see HTMLCollection#collectionMatch if ( _links == null ) _links = new HTMLCollectionImpl( getBody(), HTMLCollectionImpl.LINK ); return _links; }
public HTMLCollection getForms() { // For more information see HTMLCollection#collectionMatch if ( _forms == null ) _forms = new HTMLCollectionImpl( getBody(), HTMLCollectionImpl.FORM ); return _forms; }
public HTMLCollection getAnchors() { // For more information see HTMLCollection#collectionMatch if ( _anchors == null ) _anchors = new HTMLCollectionImpl( getBody(), HTMLCollectionImpl.ANCHOR ); return _anchors; }
public HTMLCollection getCells() { if ( _cells == null ) { _cells = new HTMLCollectionImpl( this, HTMLCollectionImpl.CELL ); } return _cells; }
/** * Creates a new instance of SimpleHtmlCollection. * * @param list the HTMLCollection to wrap. */ public SimpleHtmlCollection(HTMLCollection list) { if (list == null) { throw new NullPointerException(); } this.list = list; }
private void silenceSubmitButtons() { HTMLCollection controls = getElements(); for (int i = 0; i < controls.getLength(); i++) { ((HTMLControl) controls.item( i )).silenceSubmitButton(); } }
private HTMLFormElement getLastFormInDocument() { HTMLCollection forms = getHtmlDocument().getForms(); return forms.getLength() == 0 ? null : (HTMLFormElement) forms.item( forms.getLength()-1 ); }
public HTMLCollection getLinks() { return getHtmlDocument().getContainerDelegate().getLinks( this ); }
public HTMLCollection getImages() { return getHtmlDocument().getContainerDelegate().getImages( this ); }
public HTMLCollection getApplets() { return getHtmlDocument().getContainerDelegate().getApplets( this ); }
public HTMLCollection getForms() { return getHtmlDocument().getContainerDelegate().getForms( this ); }
public HTMLCollection getAnchors() { return getHtmlDocument().getContainerDelegate().getAnchors( this ); }
public HTMLCollection getOptions() { return HTMLCollectionImpl.createHTMLCollectionImpl( getElementsByTagName( getHtmlDocument().toNodeCase( "option" ) ) ); }
public HTMLCollection getCells() { return HTMLCollectionImpl.createHTMLCollectionImpl( getElementsByTagNames( new String[] { "td", "th " } ) ); }