static SubmitButton createFakeSubmitButton( WebForm form ) { return new SubmitButton( form, /* fake */ true ); }
public boolean equals( Object o ) { return getClass().equals( o.getClass() ) && equals( (SubmitButton) o ); }
/** * addValues if not disabled and pressed * @param processor - the ParameterProcessor used * @param characterSet - the active character set * @throws IOException if addValues fails */ protected void addValues( ParameterProcessor processor, String characterSet ) throws IOException { if (_pressed && !isDisabled()) { String buttonName = getName(); if (buttonName != null && buttonName.length() > 0 && getValue().length() > 0) { processor.addParameter( getName(), getValue(), characterSet ); } if (isValidImageButton()) { processor.addParameter( positionParameterName("x"), Integer.toString( _x ), characterSet ); processor.addParameter( positionParameterName("y"), Integer.toString( _y ), characterSet ); } } // if }
/** * Returns the current value(s) associated with this control. These values will be transmitted to the server * if the control is 'successful'. **/ protected String[] getValues() { return (isDisabled() || !_pressed) ? NO_VALUE : toArray( getValue() ); }
/** * Performs the action associated with clicking this button after running any 'onClick' script. * For a submit button this typically submits the form. * * @since 1.6 */ public void click( int x, int y ) throws IOException, SAXException { if (!isImageButton()) throw new IllegalStateException( "May only specify positions for an image button" ); doOnClickSequence(x,y); }
if (button == null) { throw new IllegalUnnamedSubmitButtonException(); } else if (button.isFake()) { } else if (!button.wasEnabled()) { button.throwDisabledException(); buttons[i].setPressed( false ); button.setPressed( true );
if (button == null) { throw new IllegalUnnamedSubmitButtonException(); } else if (button.isFake()) { button.throwDisabledException(); buttons[i].setPressed( false ); button.setPressed( true );
/** * Specifies the position at which an image button (if any) was clicked. **/ void selectImageButtonPosition( SubmitButton imageButton, int x, int y ) { if (imageButton.isValidImageButton()) { setParameter( imageButton.positionParameterName("x"), Integer.toString( x ) ); setParameter( imageButton.positionParameterName("y"), Integer.toString( y ) ); } }
private WebRequest getScriptedSubmitRequest() { SubmitButton[] buttons = getSubmitButtons(); for (int i = 0; i < buttons.length; i++) { buttons[i].setPressed( false ); } if (getMethod().equalsIgnoreCase( "post" )) { return new PostMethodWebRequest( this ); } else { return new GetMethodWebRequest( this ); } }
/** * return whether this is a validImageButton * @return true if it is an image Button */ public boolean isValidImageButton() { String buttonName = getName(); boolean valid=this.isImageButton(); if (!allowUnnamedImageButton) valid=valid && buttonName != null && buttonName.length() > 0; return valid; }
/** * get the Vector of submit buttons - will always contain at least * one button - if the original vector has none a faked submit button will be added * @return a Vector with the submit buttons */ private Vector getSubmitButtonVector() { if (_buttonVector == null) { _buttonVector = new Vector(); FormControl[] controls = getFormControls(); for (int i = 0; i < controls.length; i++) { FormControl control = controls[ i ]; if (control instanceof SubmitButton) { SubmitButton sb=(SubmitButton)control; sb.rememberEnableState(); _buttonVector.add( sb ); } } /** * make sure that there is always at least one submit button * if none is in the Vector add a faked one */ if (_buttonVector.isEmpty()) _buttonVector.addElement( SubmitButton.createFakeSubmitButton( this ) ); } return _buttonVector; }
public String getType() { return (isImageButton()?IMAGE_BUTTON_TYPE:SUBMIT_BUTTON_TYPE); }
/** * Submits this form using the web client from which it was originally obtained, ignoring any buttons defined for the form. * @since 1.6 **/ public WebResponse submitNoButton() throws SAXException, IOException { return submit( SubmitButton.createFakeSubmitButton( this /* fake */ ) ); }
/** * Specifies the position at which an image button (if any) was clicked. **/ void selectImageButtonPosition( SubmitButton imageButton, int x, int y ) { imageButton.setLocation( x, y ); }
/** * Constructs a web request from a form. * @param sourceForm - the WebForm to startFrom * @param parameterHolder - the parameter holder * @param button - the submit button * @param x - x position * @param y - y position **/ protected WebRequest( WebForm sourceForm, ParameterHolder parameterHolder, SubmitButton button, int x, int y ) { this( sourceForm, parameterHolder ); // [ 1443333 ] Allow unnamed Image input elements to submit x,y values if (button != null && button.isValidImageButton() ) { _button = button; _parameterHolder.selectImageButtonPosition( _button, x, y ); } }
protected Void scrape() throws IOException, SAXException, ProcessingException { WebResponse response = goTo(project._getURL()+"/servlets/ProjectMailingListList"); for (WebForm form : response.getForms()) { if(!form.getAction().equals("ProjectMailingListList")) continue; if(!form.getParameterValue("listName").equals(name)) continue; // found the form SubmitButton sb = form.getSubmitButtons()[0]; if(!sb.getValue().equals("Subscribe")) throw new ProcessingException("Found "+sb.getValue()+" but expected Subscribe"); // set the mode form.setParameter("subtype",mode.getNameAsWord()); checkError(form.submit(sb)); return null; } throw new ProcessingException("no subscription form found"); } }.run();
if (button == null) { throw new IllegalUnnamedSubmitButtonException(); } else if (button.isFake()) { } else if (!button.wasEnabled()) { button.throwDisabledException(); buttons[i].setPressed( false ); button.setPressed( true );
/** * Specifies the position at which an image button (if any) was clicked. **/ void selectImageButtonPosition( SubmitButton imageButton, int x, int y ) { if (imageButton.isValidImageButton()) { setParameter( imageButton.positionParameterName("x"), Integer.toString( x ) ); setParameter( imageButton.positionParameterName("y"), Integer.toString( y ) ); } }