Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 1.33 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. POJO, JPA bindings and checkboxes
  2. <input id="object_isInvoiceable" type="checkbox" name="object.isInvoiceable" />
  3. <input type="hidden" name="object.isInvoiceable" value="false" />
  4.        
  5. <input id="object_isInvoiceable" type="checkbox" name="isInvoiceableExtraParamFromHell" />
  6.        
  7. public static void save(Event object, Boolean isInvoiceableExtraParamFromHell) {
  8.     if(isInvoiceableExtraParamFromHell == null) {
  9.         object.isInvoiceable = false;
  10.     }
  11.     else {
  12.         object.isInvoiceable = true;
  13.     }
  14.  
  15.     ... validation etc ...
  16.  
  17.     object.save();
  18.  
  19.     ... render etc ...
  20. }
  21.        
  22. public class Event extends Model {
  23.  
  24.     public Boolean isInvoiceable = Boolean.FALSE;
  25.     ...
  26.     ...
  27. }
  28.        
  29. <input id="object_isInvoiceable_checkbox" type="checkbox" name="ignoredformfield" />
  30. <input id="object_isInvoiceable_formfield" type="hidden" name="object.isInvoiceable" value="false" />
  31.  
  32. <script>$("#object_isInvoiceable_checkbox").click(function(
  33.     $("object_isInvoiceable_formfield").value("$("#object_isInvoiceable_checkbox").is(":checked")");
  34. ));</script>
  35.        
  36. <input id="object_isInvoiceable" type="checkbox" name="object.isInvoiceable" />
  37.        
  38. public static void save(Event object) {
  39.     if(params.get("object.isInvoiceable") == null) {
  40.         object.isInvoiceable = false;
  41.     }
  42.  
  43.     ... validation etc ...
  44.  
  45.     object.save();
  46.  
  47.     ... render etc ...
  48. }