public void setDefaultAnswer ( String variable ) { if ( ! isSubmitType ( ) ) { throw new IllegalStateException ( "Cannot set an answer if the form is not of type " + "\"submit\"" ) ; } FormField field = getField ( variable ) ; if ( field != null ) { // Clear the old values field . resetValues ( ) ; // Set the default value for ( CharSequence value : field . getValues ( ) ) { field . addValue ( value ) ; } } else { throw new IllegalArgumentException ( "Couldn't find a field for the specified variable." ) ; } }
Sets the default value as the value of a given form s field . The field whose variable matches the requested variable will be completed with its default value . If no field could be found for the specified variable then an exception will be raised .