package e4s.tutorial;
import e4s.html.*;
import e4s.html.ajax.E4AjaxData;
import e4s.html.ajax.E4AjaxData_Intf;
import e4s.html.ajax.E4AjaxElementInputValueChanger;
import e4s.html.input.extended.E4InputFieldName;
import e4s.html.input.extended.TEXTFIELD;
import e4s.servlet.E4ModuleImplementation;
import e4s.servlet.E4ServletImplementation_Intf;
import e4s.util.E4StringBufferHtml;
/**
* This example shows how Ajax can change the value of an input field.
*
* {@tutorial Example_Ajax_TEXTFIELD}
*/
public class Example_Ajax_TEXTFIELD extends E4ModuleImplementation
{
public static E4Method start = null;
private static class MyAjax extends E4AjaxData implements E4AjaxData_Intf
{
public String getDivId()
{
return getClass().getName();
}
public void toHtml(E4StringBufferHtml buf, E4CgiParams params, E4ServletImplementation_Intf servlet, boolean initialLoad) throws Exception
{
java.util.Date now = new java.util.Date();
buf.append(now.toString());
}
}
public void start( HTML html )
{
// this is our form, it will hold a TEXTFIELD later
FORM form = html.FORM();
TEXTFIELD textfield = form.TEXTFIELD(E4InputFieldName.ANY(),"Textfield",30);
MyAjax ajax = new MyAjax();
E4AjaxElementInputValueChanger ae = textfield.addAjaxChanger(form,ajax,getServlet());
BUTTON button = form.BUTTON(ae.getOnClick(form));
button.print("Get server time using Ajax");
button.setEnableMultipleClicks(true);
}
}