package e4s.tutorial;
import e4s.html.*;
import e4s.servlet.*;
import e4s.util.E4Images;
/**
* A very important chapter. The A-tag is fundamental in changing any content on the
* user's clicks. It can be an outside branch (new A("http://www.yahoo.com"), or it
* can involve a E4JavaScript that is provided by the servlet and declared as an
* E4EventHandlerA or - in many cases - links direct back to your Java code with
* the quite simple mechanism of the E4Method classes. A E4Method
* is a declared variable, no value will be assigned. E4S analyzes your class on startup
* and will automatically find the associated Java function, declared by the same
* name within the same module. This is very fundamental to E4S programming, you might
* like it or not, but on the end of the day your project development will be very much
* faster relying on that simple mechanism because there is no overheady, the code can
* be readden very easily and everything is on one place.
*
* {@tutorial Example_A}
*/
public class Example_A extends E4ModuleImplementation
{
public static E4Method start = null;
public static E4Method functionOne = null;
public static E4Method functionTwo = null;
public void start( HTML html )
{
A one_no_params = html.A(functionOne);
one_no_params.print("Call functionOne, pass no parameters");
html.BR();
A one_with_params = html.A(functionOne);
one_with_params.print("Call functionOne, pass some parameters");
one_with_params.addParameter("TEMPERATURE",20);
one_with_params.addParameter("WIND","South-East");
html.BR();
html.A(functionTwo).print("Call functionTwo, pass no parameters");
html.BR();
html.A("Are you sure?",functionTwo).print("Call functionTwo, ask before calling");
html.BR();
A two_ask_with_parameters = html.A("Are you sure?",functionTwo);
two_ask_with_parameters.print("Call functionTwo, ask before calling");
two_ask_with_parameters.addParameter("TEMPERATURE",13);
two_ask_with_parameters.addParameter("WIND","North-East");
html.BR();
IMG iX = html.A(functionOne).IMG("images/tutorial/Example_A/butterfly01.jpg");
iX.setAlternate("Call functionOne, no parameters, no question");
A image_two_ask_with_parameters = html.A("Are you sure?",functionTwo);
IMG iY = image_two_ask_with_parameters.IMG("images/tutorial/Example_A/butterfly02.jpg");
iY.setAlternate("Call functionTwo, ask before calling");
image_two_ask_with_parameters.addParameter("TEMPERATURE",17);
image_two_ask_with_parameters.addParameter("WIND","South");
html.P();
A google = html.A("http://www.google.com");
google.print("Google in a new window");
google.openInNewWindow();
html.BR();
A ebay = html.A("http://www.ebay.com");
ebay.print("EBay in a new window");
ebay.openInNewWindow();
html.BR();
}
public void functionOne( HTML html, E4CgiParams params )
{
html.FONT(FONT.ARIAL_larger).B().println("This is function One");
html.P();
params.toTable(html.TABLE( TABLE.E4S_DEFAULT_TABLE() ));
html.P();
html.A(start).I().print("[back]");
}
public void functionTwo( HTML html, E4CgiParams params )
{
html.FONT(FONT.ARIAL_larger).B().println("This is function Two");
html.P();
params.toTable(html.TABLE( TABLE.E4S_DEFAULT_TABLE() ));
html.P();
html.A(start).I().print("[back]");
}
}