| 1 package org.sapia.gumby.view.binding; 2 3 import javax.swing.text.JTextComponent ; 4 5 import org.apache.commons.jxpath.JXPathContext; 6 import org.sapia.gumby.view.View; 7 8 23 public class TextBinding extends AbstractJXPathBinding { 24 25 29 public void onBound(View owner, Object model) { 30 JXPathContext ctx = JXPathContext.newContext(model); 31 ctx.setLenient(true); 32 Object value = _expr.getValue(ctx); 33 JTextComponent comp = (JTextComponent ) acquireWidget(owner); 34 if(value != null) { 35 comp.setText(value.toString()); 36 } 37 } 38 39 43 public void onChanged(View owner, Object model) { 44 onBound(owner, model); 45 } 46 47 51 public void onUpdated(View owner, Object model) { 52 onBound(owner, model); 53 } 54 55 59 public void updateModel(View owner, Object model) { 60 JXPathContext ctx = JXPathContext.newContext(model); 61 ctx.setLenient(true); 62 JTextComponent comp = (JTextComponent ) acquireWidget(owner); 63 _expr.setValue(ctx, comp.getText()); 64 } 65 66 } 67 | Popular Tags |