diff --git a/scheme/httpd/surflets/packages.scm b/scheme/httpd/surflets/packages.scm index 53e8686..1b87d95 100644 --- a/scheme/httpd/surflets/packages.scm +++ b/scheme/httpd/surflets/packages.scm @@ -166,8 +166,8 @@ make-submit-button make-reset-button make-image-button - try-input-field-value input-field-value + raw-input-field-value input-field-binding make-address diff --git a/scheme/httpd/surflets/surflets.scm b/scheme/httpd/surflets/surflets.scm index 6853776..2887fed 100644 --- a/scheme/httpd/surflets/surflets.scm +++ b/scheme/httpd/surflets/surflets.scm @@ -575,7 +575,7 @@ ;; : '(input-field . ) ;; : #{Input-field "name"} -(define (input-field-value input-field bindings) +(define (raw-input-field-value input-field bindings) (let ((input-field (cadr input-field))) (cond ((input-field-get-bindings? input-field) @@ -587,18 +587,20 @@ (error "no such input-field" input-field bindings))))) ;; Trys to get a value for INPUT-FIELD in BINDINGS. If this fails -;; (i.e. INPUT-FIELD-VALUE returns an error), the default-value is +;; (i.e. RAW-INPUT-FIELD-VALUE returns an error), the default-value is ;; returned. The default-value defaults to #f. NOTE: If you do this ;; with input-fields whose valid values may be the same as the default ;; value, you cannot determine by the result if there was such a value -;; or not. Keep in mind, that INPUT-FIELD-VALUE returns also an error, -;; if there was not such an input field. -(define (try-input-field-value input-field bindings . maybe-default) +;; or not. Keep in mind, that RAW-INPUT-FIELD-VALUE returns also an +;; error, if there was not such an input field. This makes +;; INPUT-FIELD-VALUE working with checkbox input fields because they +;; miss if they are not checked. +(define (input-field-value input-field bindings . maybe-default) (let ((default (:optional maybe-default #f))) (with-fatal-error-handler (lambda (condition more) default) - (input-field-value input-field bindings)))) + (raw-input-field-value input-field bindings)))) (define (real-input-field-binding input-field bindings) (assoc (input-field-name input-field) bindings)) diff --git a/scheme/httpd/surflets/web-server/root/htdocs/index.html b/scheme/httpd/surflets/web-server/root/htdocs/index.html index ef187fc..ad68e63 100644 --- a/scheme/httpd/surflets/web-server/root/htdocs/index.html +++ b/scheme/httpd/surflets/web-server/root/htdocs/index.html @@ -13,6 +13,7 @@
  • Simple Calculator
  • Byte Input Widget
  • Simple Servlet
  • +
  • Spaceship builder
  • Servlet Administration
  • This file
  • @@ -23,7 +24,7 @@
    -Last modified: Sun Nov 3 15:24:22 CET 2002 +Last modified: Tue Nov 5 10:39:46 CET 2002 diff --git a/scheme/httpd/surflets/web-server/root/surflets/add2.scm b/scheme/httpd/surflets/web-server/root/surflets/add2.scm index 61186d9..e68c84d 100644 --- a/scheme/httpd/surflets/web-server/root/surflets/add2.scm +++ b/scheme/httpd/surflets/web-server/root/surflets/add2.scm @@ -27,11 +27,9 @@ (p (URL "/" "Return to main menu.") (br) (URL "add2.scm" "Start new calculation.")))))))) (if result - (with-fatal-error-handler - (lambda (condition more) - (get-number input-text "Please enter a valid number.")) - (input-field-value number-input-field - (form-query (http-url:search (request:url result))))) + (or (input-field-value number-input-field + (form-query (http-url:search (request:url result)))) + (get-number input-text "Please enter a valid number.")) (get-number input-text "Please enter a number.")))) (define (get-number1) diff --git a/scheme/httpd/surflets/web-server/root/surflets/admin-handler.scm b/scheme/httpd/surflets/web-server/root/surflets/admin-handler.scm index 997d814..ccd86b5 100644 --- a/scheme/httpd/surflets/web-server/root/surflets/admin-handler.scm +++ b/scheme/httpd/surflets/web-server/root/surflets/admin-handler.scm @@ -55,18 +55,17 @@ ((returned-via? return-address bindings) (return-to-main-page req)) ((input-field-binding submit-timeout bindings) - (with-fatal-error-handler - (lambda (condition more) - (handler-options req "Please enter a valid, positive integer number")) (let ((result (input-field-value number-field bindings))) - (if (and (integer? result) - (> result 0)) - (begin - (set-options-instance-lifetime result) - (handler-options req - (format #f "Instance lifetime changed to ~a." - (options-instance-lifetime)))) - (error "not a positive integer"))))) + (if result + (if (and (integer? result) + (> result 0)) + (begin + (set-options-instance-lifetime result) + (handler-options req + (format #f "Instance lifetime changed to ~a." + (options-instance-lifetime)))) + (error "not a positive integer")) + (handler-options req "Please enter a valid, positive integer number")))) ((input-field-binding submit-cache bindings) (let ((cache-plugins? (if (input-field-binding cache-checkbox bindings) #t diff --git a/scheme/httpd/surflets/web-server/root/surflets/admin-profiling.scm b/scheme/httpd/surflets/web-server/root/surflets/admin-profiling.scm index 7738c84..671ca9e 100644 --- a/scheme/httpd/surflets/web-server/root/surflets/admin-profiling.scm +++ b/scheme/httpd/surflets/web-server/root/surflets/admin-profiling.scm @@ -89,10 +89,7 @@ ((returned-via? reset-return-address bindings) (reset-and-return-to-main-page req)) (else - (let ((new-gnuplot-location (with-fatal-error-handler - (lambda (condition more) - #f) - (input-field-value input-field bindings)))) + (let ((new-gnuplot-location (input-field-value input-field bindings))) (if (and new-gnuplot-location (file-executable? new-gnuplot-location)) (begin diff --git a/scheme/httpd/surflets/web-server/root/surflets/admin-servlets-cb.scm b/scheme/httpd/surflets/web-server/root/surflets/admin-servlets-cb.scm index 3c76b56..485a303 100644 --- a/scheme/httpd/surflets/web-server/root/surflets/admin-servlets-cb.scm +++ b/scheme/httpd/surflets/web-server/root/surflets/admin-servlets-cb.scm @@ -58,12 +58,9 @@ (values action (filter-map (lambda (checkbox table-element) - (if(with-fatal-error-handler - (lambda (condition more) - #f) - (input-field-value checkbox bindings)) - table-element - #f)) + (if (input-field-value checkbox bindings) + table-element + #f)) checkboxes table-elements))))) diff --git a/scheme/httpd/surflets/web-server/root/surflets/admin-servlets.scm b/scheme/httpd/surflets/web-server/root/surflets/admin-servlets.scm index f94c4f4..94aa3bc 100644 --- a/scheme/httpd/surflets/web-server/root/surflets/admin-servlets.scm +++ b/scheme/httpd/surflets/web-server/root/surflets/admin-servlets.scm @@ -58,9 +58,7 @@ (values #f #f) (values action (filter-map (lambda (checkbox table-element) - (if (with-fatal-error-handler - (lambda (c m) #f) - (input-field-value checkbox bindings)) + (if (input-field-value checkbox bindings) table-element #f)) checkboxes diff --git a/scheme/httpd/surflets/web-server/root/surflets/byte-input.scm b/scheme/httpd/surflets/web-server/root/surflets/byte-input.scm index a4fd330..64ca11e 100644 --- a/scheme/httpd/surflets/web-server/root/surflets/byte-input.scm +++ b/scheme/httpd/surflets/web-server/root/surflets/byte-input.scm @@ -27,9 +27,8 @@ (if (null? checkboxes) sum (loop (+ sum (string->number - (with-fatal-error-handler - (lambda (condition decline) "0") - (input-field-value (car checkboxes) bindings)))) + (or (input-field-value (car checkboxes) bindings) + "0"))) (cdr checkboxes))))) checkboxes))) diff --git a/scheme/httpd/surflets/web-server/root/surflets/calculate-cb.scm b/scheme/httpd/surflets/web-server/root/surflets/calculate-cb.scm index e8a9dfd..be992f2 100644 --- a/scheme/httpd/surflets/web-server/root/surflets/calculate-cb.scm +++ b/scheme/httpd/surflets/web-server/root/surflets/calculate-cb.scm @@ -37,7 +37,7 @@ (make-callback (lambda (req) (change-operator - ;; This yields an error only when the browser doing wrong. + ;; This yields an error only when the browser is doing wrong. (input-field-value operator-input-field (get-bindings req)))) )) @@ -78,14 +78,8 @@ (td ,(make-submit-button '(@ (value "change operator")))))))))))) (bindings (get-bindings req))) - (let ((number1 - (with-fatal-error-handler - (lambda (c d) #f) - (input-field-value number-field1 bindings))) - (number2 - (with-fatal-error-handler - (lambda (c d) #f) - (input-field-value number-field2 bindings)))) + (let ((number1 (input-field-value number-field1 bindings)) + (number2 (input-field-value number-field2 bindings))) (if number1 (if number2 (calculate operator-pair number1 number2) diff --git a/scheme/httpd/surflets/web-server/root/surflets/calculate.scm b/scheme/httpd/surflets/web-server/root/surflets/calculate.scm index 5ef7b44..7fdc159 100644 --- a/scheme/httpd/surflets/web-server/root/surflets/calculate.scm +++ b/scheme/httpd/surflets/web-server/root/surflets/calculate.scm @@ -69,12 +69,8 @@ (hr) (p (URL "/" "Return to main menu.")))))))) (bindings (get-bindings req))) - (let ((number1 (with-fatal-error-handler - (lambda (c d) #f) - (input-field-value number-field1 bindings))) - (number2 (with-fatal-error-handler - (lambda (c d) #f) - (input-field-value number-field2 bindings)))) + (let ((number1 (input-field-value number-field1 bindings)) + (number2 (input-field-value number-field2 bindings))) (cond ((input-field-binding calculate-button bindings) (if number1