1 13 package com.tonbeller.wcf.toolbar; 14 15 import com.tonbeller.wcf.component.Component; 16 import com.tonbeller.wcf.controller.RequestContext; 17 18 24 public class FormButtonModel implements ToolButtonModel { 25 Component comp; 26 String action; 27 String forward; 28 29 public FormButtonModel(Component comp) { 30 this.comp = comp; 31 } 32 33 36 public boolean isPressed(RequestContext context) { 37 return false; 38 } 39 40 43 public void setPressed(RequestContext context, boolean pressed) { 44 boolean success = true; 45 if (action != null) { 46 if (action.equals("revert")) 47 comp.revert(context); 48 else if (action.equals("validate")) 49 success = comp.validate(context); 50 else 51 throw new IllegalArgumentException ("invalid action: " + action); 52 } 53 if (success && forward != null && forward.length() > 0) 54 comp.setNextView(forward); 55 } 56 57 61 public void setAction(String action) { 62 this.action = action; 63 } 64 65 69 public void setForward(String forward) { 70 this.forward = forward; 71 } 72 73 } 74 | Popular Tags |