📄 simpleinputformproducer.java
字号:
package com.wiley.compBooks.EJwithUML.TimecardProducers;import com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.*;import com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.Core.*;import com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.Layout.*;import com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.FormPrimitives.*;import com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.ContentElements.*;import java.util.*;/** The SimpleInputFormProducer class encapsulates the details of building the HTML * for a simple input form. */public class SimpleInputFormProducer implements IHtmlPrimitive{ private FormPrimitive form; private TablePrimitive table; private SubmitPrimitive submit; private String instructions; private int rowCtr = 0; /** Construct a SimpleInputFormProducer with the specified submit button label and target.*/ public SimpleInputFormProducer(String formTitle, String instructions, String submitLabel, String target) { submit = new SubmitPrimitive(submitLabel); SpanPrimitive titleSpan = new SpanPrimitive(TimecardStyle.FORM_TITLE, formTitle); titleSpan.addLineBreak(); SpanPrimitive instructionsSpan = new SpanPrimitive(TimecardStyle.FORM_INSTRUCTIONS, instructions); instructionsSpan.addLineBreak(); instructionsSpan.addLineBreak(); form = new FormPrimitive(target,"sip"); form.addPrimitive(titleSpan); form.addPrimitive(instructionsSpan); table = new TablePrimitive(); table.setStyle(TimecardStyle.FORM_LAYOUT_TABLE); form.addPrimitive(table); } /** Adds the HTML for this SimpleInputFormProducer to the specified buffer. */ public void buildContent(StringBuffer buffer) { table.setPrimitiveAt(rowCtr,1,submit); form.buildContent(buffer); } public void addField(String label, String dataName, String initialValue) { this.addField(label, dataName, initialValue, false); } public void addMaskedField(String label, String dataName, String initialValue) { this.addField(label, dataName, initialValue, true); } /** Add a labeled input field to this SimpleInputFormProducer. */ private void addField(String label, String dataName, String initialValue, boolean masked) { TextBoxPrimitive textBox = new TextBoxPrimitive(dataName); if (masked) { textBox.setMasked(); } textBox.setInitialValue(initialValue); table.setStyleForCells(TimecardStyle.FORM_FIELD_LABEL_CELL); table.setPrimitiveAt(rowCtr, 0, new SpanPrimitive(TimecardStyle.FORM_FIELD_LABEL,label)); table.setStyleForCells(TimecardStyle.FORM_FIELD_INPUT_CELL); table.setPrimitiveAt(rowCtr++, 1, textBox); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -