package e4s.tutorial; import e4s.html.*; import e4s.html.input.extended.*; import e4s.servlet.E4ModuleImplementation; /** * This is an example how to deal with E4Methods. * E4Method cover the messaging of your application and each * E4Method is associated with a Java function. So we can treat * them as "normal" arguments in our application, for example if we * want an Anchor () tag to call another function. It is typically * for web applications, that either a form (
) or an anchor will * make branches to other functions. This example does not make * use of E4CSS definitions, so font attributes are included in the * application now. */ public class Example_Method extends E4ModuleImplementation { /** * This a placeholder for a Java function called "start". You can * find it below. From the tutorial framework, this is also the entry * into our module. Please note, that the variable is not initialized * (so it has a value of null) unless it will be initialized by the * E4S framework during servlet startup. */ public static E4Method start = null; /** * This is another placehold for another function. */ public static E4Method foo = null; /** * This is another placehold for another function. */ public static E4Method buh = null; /** * This defines our first input field, we do not care it's name. */ private final static E4InputFieldName PARAM_UNNAMED = E4InputFieldName.ANY(); /** * This is another input field, we named it "ALPHA". */ private final static E4InputFieldName PARAM_NAMED = new E4InputFieldName("ALPHA"); /** * Our first function, becoming involved by the tutorial framework either * or when you click on that anchor tag generated in function buh. * * @param html the HTML object where we can let E4S render output * @param params an object containing all CGI parameters passed to that URL */ public void start(HTML html, E4CgiParams params) throws Exception { // create a form with two input fields and function "foo" as receiver FORM form = html.FORM(foo); form.TEXTFIELD(PARAM_UNNAMED,"Enter a value here",20); form.BR(); form.TEXTFIELD(PARAM_NAMED,"Enter another value here",20); form.BR(); form.BUTTON_Submit("Send"); // set any previous values to that form form.setValue(params); html.P(); } /** * This function receives data from the form defined in function start above. * We display the parameters, and call another function called "buh" using * an anchor tag. * * @param html the HTML object where we can let E4S render output * @param params an object containing all CGI parameters passed to that URL */ public void foo( HTML html, E4CgiParams params ) { html.FONT(FONT.ARIAL).SMALL().println("The value you have entered was: " + params.get(PARAM_UNNAMED) + " and " + params.get(PARAM_NAMED)); html.BR(); A href = html.A(buh); href.FONT(FONT.ARIAL).SMALL().print("Click here to call another function now"); href.addParameter(params); } /** * Offer an back button to function "start" here, pass the parameters. * * @param html the HTML object where we can let E4S render output * @param params an object containing all CGI parameters passed to that URL */ public void buh( HTML html, E4CgiParams params ) { A href = html.A(start); href.FONT(FONT.ARIAL).SMALL().print("Click here to go back to the beginning"); href.addParameter(params); } }