KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > calculator > CalcApp


1 /*
2  * calculator
3  * A sample Enhydra Application
4  * 1/99
5  * Andy John
6  * andy@enhydra.org
7  *
8  */

9 package calculator;
10
11 import com.lutris.appserver.server.*;
12 import com.lutris.appserver.server.httpPresentation.*;
13 import com.lutris.appserver.server.session.*;
14 import com.lutris.util.*;
15
16 /**
17  * This is a sample Enhydra application. It simulates a simple calculator.
18  * A scan of a real calculator is used for the front end, with an image map.<P>
19  *
20  * A global counter of the number of buttons pushed (across all users) is
21  * kept here. <P>
22  *
23  * Noramlly an Enhydra application would make note of various settings
24  * in the config file, but this application is so simple it needs no
25  * configuration.
26  */

27 public class CalcApp extends StandardApplication {
28
29   /**
30    * A hit counter for the number of buttons pressed by all users.
31    */

32   public long buttonsPushed = 0;
33
34     /*
35      * A few methods you might want to add to.
36      * See StandardApplication for more details.
37      */

38     public void startup(Config appConfig) throws ApplicationException {
39         super.startup(appConfig);
40         // Here is where you would read application-specific settings from
41
// your config file.
42
}
43     public boolean requestPreprocessor(HttpPresentationComms comms)
44                    throws Exception JavaDoc {
45         return super.requestPreprocessor(comms);
46     }
47
48     /**
49      * Show the number of buttons pressed. This will only be called by the
50      * Enhydra Multiserver (it won't show up in other servers).
51      *
52      * @return HTML that is displayed in the status page of the Multiserver.
53      */

54     public String JavaDoc toHtml() {
55         return "This is a sample Enhydra Application. " + buttonsPushed +
56                " buttons have been pushed so far.";
57     }
58
59 }
60
61
Popular Tags