to the main page about the tutorial  INTERACTIVE WEB SERVICES WITH JAVA back up next

Controllers in JAOO

Controllers are simply programmed as sessions. For example, the business cards interactions are implemented as:

public class Search extends Session {
  public void main() {

    read registrations.xml;
    show loginPage;
    String id = receive id;
    if (id is not in registrations.xml) exit loginErrorPage;

    read cards.xml;
    Element p;
    if (id is in cards.xml) p = information from cards.xml;
    else p = information from registrations.xml;

    String filter = "";
    while (true) {
      show searchPage<[filter=filter,cards = generate cards using filter];
      if ((receive action).equals("filter")) filter = filter;
      if ((receive action).equals("update")) {
         if ((receive pin) matches p) {
            show updatePage<[fields = values from p];
            update p with received values;        
            update cards.xml with p;