Package com.et.mvc.binding

Examples of com.et.mvc.binding.BindingContext


        int bindCount = 0//success bind field count
       
        for(Field f: ctx.getParameterType().getDeclaredFields()){
            DataBinder binder = DataBinders.getDataBinder(f.getType());
            if (binder != null){
                BindingContext bc = new BindingContext();
                bc.setParameterName(f.getName());
                bc.setParameterType(f.getType());
                bc.setRequest(ctx.getRequest());
                bc.setPrefix(ctx.getPrefix());

                Object value = binder.bind(bc);
                if (value != null) {
                  bindCount ++;
                }
                f.setAccessible(true);
                f.set(obj, value);
            } else {
              BindingContext bc = new BindingContext();
              bc.setParameterName(f.getName());
              bc.setParameterType(f.getType());
              bc.setRequest(ctx.getRequest());
              if (ctx.getPrefix().equals("")){
                bc.setPrefix(f.getName());
              } else {
                bc.setPrefix(ctx.getPrefix() + "." + f.getName());
              }
             
              f.setAccessible(true);
              f.set(obj, bind(bc));
            }
View Full Code Here


       
      } catch (Exception ex) {
      }
     
      for(Field f : clasz.getDeclaredFields()) {
        BindingContext ctx = new BindingContext();
        ctx.setParameterName(f.getName());
        ctx.setParameterType(f.getType());
        ctx.setRequest(request);
        ctx.setPrefix(prefix);
       
        DataBinder binder = DataBinders.getDataBinder(f.getType());
        if (binder != null) {
          String pname = ctx.getParameterName();
          if (!ctx.getPrefix().equals("")) {
            pname = ctx.getPrefix() + "." + pname;
          }
          if (request.getParameterMap().containsKey(pname)) {
            f.setAccessible(true);
            f.set(model, binder.bind(ctx));
          }
        } else {
              BindingContext bc = new BindingContext();
              bc.setParameterName(f.getName());
              bc.setParameterType(f.getType());
              bc.setRequest(ctx.getRequest());
              if (ctx.getPrefix().equals("")){
                bc.setPrefix(f.getName());
              } else {
                bc.setPrefix(ctx.getPrefix() + "." + f.getName());
              }
             
          Object value = new ObjectBinder().bind(bc);
          if (value != null) {
            f.setAccessible(true);
            Object obj = f.get(model);
            if (obj != null) {
              updateModel(obj, bc.getPrefix());
              f.set(model, obj);
            } else {
              f.set(model, value);
            }
          }
View Full Code Here

        if (types.length > 0){
            Paranamer paranamer = new AdaptiveParanamer();
            String[] names = paranamer.lookupParameterNames(getActionMethod());
            for(int i=0; i<parameters.length; i++){
                BindingContext ctx = new BindingContext();
                ctx.setParameterName(names[i]);
                ctx.setParameterType(types[i]);
                ctx.setRequest(getRequest());
                Annotation[] ann = annotations[i];
                if (ann.length > 0 && ann[0] instanceof Bind){
                    Bind bind = (Bind)ann[0];
                    ctx.setPrefix(bind.prefix());
                }
                else{
                    ctx.setPrefix("");
                }
                DataBinder binder = DataBinders.getDataBinder(types[i]);
                if (binder == null){
                    binder = new ObjectBinder();
                }
View Full Code Here

TOP

Related Classes of com.et.mvc.binding.BindingContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.