package e4s.tutorial; import java.io.*; import java.util.*; import java.text.*; import java.net.*; import java.sql.*; import e4s.html.*; import e4s.html.input.extended.*; import e4s.html.style.*; import e4s.servlet.*; /** * A simple class, that demonstrates the use of images. * * {@tutorial Example_Input_Style} * * @see e4s.html.IMG */ public class Example_Input_Style extends E4ModuleImplementation { public static E4Method styleExample = null; public static E4Method styleExample_Save = null; private final static CLASS_Name classActiveText = new CLASS_Name("ACTIVE_T"); private final static CLASS_Name classInactiveText = new CLASS_Name("INACTIVE_T"); private final static CLASS_Name classActiveNumber = new CLASS_Name("ACTIVE_N"); private final static CLASS_Name classInactiveNumber = new CLASS_Name("INACTIVE_N"); private final static CLASS_Name classActiveButton = new CLASS_Name("ACTIVE_B"); private void initStyle() { if (getServlet() != null) { try { // this part of the code is only for tutorial demo purpouses, to set // styles. Normally, styles are edited interactive and will be stored in // in a .css file. You do not need this code snipped in a real world // application, unless you want to force the use of some predefined // .css settings. E4CssFile css = getCSS()[E4CssFile.LEVEL_APPLICATION]; if (css.getStyle(new STYLE_Name(E4InputField.HTML_TAG,classActiveText)) == null) { // no styles defined for this tutorial procedure -> create them // create styles used in this module - note for editing reasons, styles are related // to the HTML tag they are used in, in this case we only use the html-tag, so // all style definitions refer to this tag, followed by a style-class name css.addStyle(E4InputField.HTML_TAG,classActiveText,"background-color:#ffffff;font-family:verdana;font-size:10pt;color:#284885;border:1px solid #d4dae7;"); css.addStyle(E4InputField.HTML_TAG,classInactiveText,"background-color:#606060;font-family:verdana;font-size:10pt;color:#284885;border:1px solid #d4dae7;"); css.addStyle(E4InputField.HTML_TAG,classActiveNumber,"text-align:right;background-color:#ffffff;font-family:verdana;font-size:10pt;color:#284885;border:1px solid #d4dae7;"); css.addStyle(E4InputField.HTML_TAG,classInactiveNumber,"text-align:right;background-color:#606060;font-family:verdana;font-size:10pt;color:#284885;border:1px solid #d4dae7;"); css.addStyle(E4InputField.HTML_TAG,classActiveButton,"background-color:#244060;font-family:verdana;font-size:10pt;color:#284885;border:1px solid #d4dae7;"); // save the file css.writeCssFile(getApplObj()); } } catch( Exception e ) { System.out.print(e); } } } public void styleExample( HTML html ) { initStyle(); BODY body = html.BODY(); body.Message(E4Message.CAPTION,"To demonstrate this function: turn E4CSS editing on and modify the styles using the style editing icon, then re-open this page once more."); FORM form = body.FORM(); FORM.setFocusBgColorDefault(null); // form.setSTYLE(new CLASS_Name("FRM")); form.setAction(styleExample_Save); TEXTFIELD tFieldA1 = form.TEXTFIELD(new E4InputFieldName("A1"),"Text Input",30); tFieldA1.setSTYLE(classActiveText,classInactiveText); form.BR(); TEXTFIELD tFieldA2 = form.TEXTFIELD(new E4InputFieldName("A2"),"Text Input (no editing)",30); tFieldA2.setReadOnly(true); tFieldA2.setSTYLE(classActiveText,classInactiveText); form.BR(); String simple_selection[] = {"Saturn","Venus","Jupiter","Mars","Earth","Pluto"}; SELECT sField = form.SELECT(new E4InputFieldName("B"),"Selection",simple_selection); sField.setSTYLE(classActiveText,classInactiveText); form.BR(); LONGFIELD lField = form.LONGFIELD(new E4InputFieldName("C"),"Number Input"); lField.setSTYLE(classActiveNumber,classInactiveNumber); form.BR(); FLOATFIELD fField = form.FLOATFIELD(new E4InputFieldName("D"),"Decimal Input"); fField.setSTYLE(classActiveNumber,classInactiveNumber); form.BR(); DATEFIELD dField = form.DATEFIELD(new E4InputFieldName("E"),"Date Input"); dField.setSTYLE(classActiveText,classInactiveText); form.BR(); CHECKBOX cField = form.CHECKBOX(new E4InputFieldName("F"),"Checkbox"); cField.setSTYLE(classActiveText,classInactiveText); form.P(); form.FORM_Submit("Submit",classActiveButton); form.P(); A href = html.A(styleExample); href.print("[reload]"); } public void styleExample_Save( HTML html, E4CgiParams params ) { params.toTable(html.TABLE()); A href = html.A(styleExample); href.print("[do it again]"); } }