Libraryless. Click here for Pure Java version (5107L/30K).
persistable sclass HTMLForm { new L<Row> rows; S tableClass = "responstableForForms"; new SS hiddenValues; bool renderForm = true; // render <form> tag S formAction; // action URL of <form> persistable asclass Row { S label; // HTML abstract O contents(); // HTML } persistable sclass LiteralRow extends Row { S contents; *(S *label, S *contents) {} O contents() { ret contents; } } S css() { ret eq(tableClass, "responstableForForms") ? hcss_responstableForForms() : ""; } S get() { ret hcss(css()) + html(); } S html() { LLS matrix = map(rows, row -> ll(row.label, strOrEmpty(row.contents()))); S table = htableRaw_valignTop(matrix, empty(tableClass) ? litparams(border := 1, cellpadding := 4) : litparams(class := tableClass)); table += hhiddenMulti(hiddenValues); ret renderForm ? hpostform(table, action := formAction) : table; } void add(S label, O contents) { rows.add(new LiteralRow(label, strOrEmpty(contents))); } void addButton(S text) { add("", hsubmit(text)); } void addHidden(S name, S value) { hiddenValues.put(name, value); } }
download show line numbers debug dex old transpilations
Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
| Snippet ID: | #1032529 | 
| Snippet name: | HTMLForm | 
| Eternal ID of this version: | #1032529/12 | 
| Text MD5: | a38bae431f49838235b8fa2ae35589b2 | 
| Transpilation MD5: | d8e1b5defa0003787d3054a6c4cfe1e4 | 
| Author: | stefan | 
| Category: | javax / html | 
| Type: | JavaX fragment (include) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2021-10-13 17:54:00 | 
| Source code size: | 1223 bytes / 47 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 443 / 680 | 
| Version history: | 11 change(s) | 
| Referenced in: | [show references] |