s c h e m a t i c s : c o o k b o o k

/ Cookbook.AToBToC

This Web


WebHome 
WebChanges 
TOC (with recipes)
NewRecipe 
WebTopicList 
WebStatistics 

Other Webs


Chicken
Cookbook
Erlang
Know
Main
Plugins
Sandbox
Scm
TWiki  

Schematics


Schematics Home
Sourceforge Page
SchemeWiki.org
Original Cookbook
RSS

Scheme Links


Schemers.org
Scheme FAQ
R5RS
SRFIs
Scheme Cross Reference
PLT Scheme SISC
Scheme48 SCM
MIT Scheme scsh
JScheme Kawa
Chicken Guile
Bigloo Tiny
Gambit LispMe
GaucheChez

Lambda the Ultimate
TWiki.org

Web_Programming

Problem

Many of the examples I've seen to date showed how to go from page A to page B to page C, by having C's page's procedure call B's which called A. A's page would display; when A was done, B's page would display; when B's page was done, A would display.

Going from A to B to C to page A (without using the Back button) is a bit trickier.

Solution

Here is a runnable module with three pages, where each page has links to the other two pages.

(module AToBToC mzscheme
  (require (lib "servlet.ss" "web-server")
           (lib "etc.ss"))

  (provide timeout interface-version start)
  (define timeout 1500)
  (define interface-version 'v1)


  (define callback-a
    (lambda (request)
      (send/suspend/callback
        `(html (head (title "page A"))
               (body (h1 "page A")
                     (p (a ((href ,callback-b)) "to page B"))
                     (p (a ((href ,callback-c)) "to page C")))))))

  (define callback-b
     (lambda (request)
      (send/suspend/callback
        `(html (head (title "page B"))
               (body (h1 "page B")
                     (p (a ((href ,callback-a)) "to page A"))
                     (p (a ((href ,callback-c)) "to page C")))))))

  (define callback-c
    (lambda (request)
      (send/suspend/callback
        `(html (head (title "page C"))
               (body (h1 "page C")
                     (p (a ((href ,callback-b)) "to page B"))
                     (p (a ((href ,callback-a)) "to page A")))))))

  (define start callback-a))

Discussion


Comments about this recipe

I would have liked to attach the full module (so people could download it and run it) but only include fragments of the code in the body of the page.

Contributors

ChrisDutchyn wrote the original code.

-- DuckySherwood - 06 Apr 2006 `

CookbookForm
TopicType: Recipe
ParentTopic: Web_Programming
TopicOrder: 999

 
 
Copyright © 2004 by the contributing authors. All material on the Schematics Cookbook web site is the property of the contributing authors.
The copyright for certain compilations of material taken from this website is held by the SchematicsEditorsGroup - see ContributorAgreement & LGPL.
Other than such compilations, this material can be redistributed and/or modified under the terms of the GNU Lesser General Public License (LGPL), version 2.1, as published by the Free Software Foundation.
Ideas, requests, problems regarding Schematics Cookbook? Send feedback.
/ You are Main.guest