Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

39
LINES

< > BotCompany Repo | #1026000 - HCRUD_Data

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (13025L/88K).

1  
sclass HCRUD_Data {
2  
  new Map<S, Renderer> renderers;
3  
  new SS fieldHelp;
4  
  
5  
  abstract sclass Renderer {}
6  
  srecord TextArea(int cols, int rows) extends Renderer {}
7  
  srecord TextField(int cols) extends Renderer {}
8  
  srecord ComboBox(LS entries) extends Renderer {}
9  
  srecord CheckBox() extends Renderer {}
10  
11  
  S itemName() { ret "object"; }
12  
  S itemNamePlural() { ret plural(itemName()); }
13  
  
14  
  //LS fields() { null; }
15  
  L<Map<S, O>> list() { null; }
16  
  S fieldNameToHTML(S name) { ret htmlencode(humanizeLabel(name)); }
17  
  S idField() { ret "id"; }
18  
  Map<S, O> emptyObject() { null; }
19  
  Map<S, O> getObject(O id) { null; }
20  
  
21  
  // return ID
22  
  O createObject(SS map) { throw unimplemented(); }
23  
  
24  
  // return text msg
25  
  S deleteObject(O id) { throw unimplemented(); }
26  
  
27  
  // return text msg
28  
  S updateObject(O id, SS map) { throw unimplemented(); }
29  
  
30  
  // return null for standard input field
31  
  Renderer getRenderer(S field) { ret renderers.get(field); }
32  
  
33  
  // returns HTML
34  
  S fieldHelp(S field) { ret fieldHelp.get(field); }
35  
  
36  
  returnSelf addRenderer(S field, Renderer renderer) { renderers.put(field, renderer); }
37  
  
38  
  returnSelf fieldHelp(S field, S help) { fieldHelp.put(field, help); }
39  
}

download  show line numbers  debug dex   

Travelled to 5 computer(s): bhatertpkbcr, mqqgnosmbjvj, pzhvpgtvlbxg, tvejysmllsmz, xrpafgyirdlv

No comments. add comment

Snippet ID: #1026000
Snippet name: HCRUD_Data
Eternal ID of this version: #1026000/12
Text MD5: 2782b124d6cf32a964706d6555e41cbc
Transpilation MD5: 01721151ffb6b403d1b0587dbb85cd4d
Author: stefan
Category: javax / html
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-02 12:30:03
Source code size: 1238 bytes / 39 lines
Pitched / IR pitched: No / No
Views / Downloads: 72 / 238
Version history: 11 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1026000 & http://1026000.tinybrain.de