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).

sclass HCRUD_Data {
  new Map<S, Renderer> renderers;
  new SS fieldHelp;
  
  abstract sclass Renderer {}
  srecord TextArea(int cols, int rows) extends Renderer {}
  srecord TextField(int cols) extends Renderer {}
  srecord ComboBox(LS entries) extends Renderer {}
  srecord CheckBox() extends Renderer {}

  S itemName() { ret "object"; }
  S itemNamePlural() { ret plural(itemName()); }
  
  //LS fields() { null; }
  L<Map<S, O>> list() { null; }
  S fieldNameToHTML(S name) { ret htmlencode(humanizeLabel(name)); }
  S idField() { ret "id"; }
  Map<S, O> emptyObject() { null; }
  Map<S, O> getObject(O id) { null; }
  
  // return ID
  O createObject(SS map) { throw unimplemented(); }
  
  // return text msg
  S deleteObject(O id) { throw unimplemented(); }
  
  // return text msg
  S updateObject(O id, SS map) { throw unimplemented(); }
  
  // return null for standard input field
  Renderer getRenderer(S field) { ret renderers.get(field); }
  
  // returns HTML
  S fieldHelp(S field) { ret fieldHelp.get(field); }
  
  returnSelf addRenderer(S field, Renderer renderer) { renderers.put(field, renderer); }
  
  returnSelf fieldHelp(S field, S help) { fieldHelp.put(field, help); }
}

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: 71 / 236
Version history: 11 change(s)
Referenced in: #1003674

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