Examples of BindingContext


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

Examples of com.et.mvc.binding.BindingContext

       
      } 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

Examples of com.et.mvc.binding.BindingContext

        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

Examples of com.palantir.ptoss.cinch.core.BindingContext

    public static String getString() {
        return "#" + i++;
    }

    public void testConstants() {
        BindingContext context = new BindingContext(this);
        assertEquals("string1", context.getBindableConstant("STRING_1"));
        assertEquals(Boolean.TRUE, context.getBindableConstant("BOOLEAN"));
        assertEquals("privateString", context.getBindableConstant("PRIVATE_STRING"));
        assertEquals("#0", context.getBindableConstant("FUNCTION_STRING"));

        assertEquals(null, context.getBindableConstant("NOT_FOUND"));
    }
View Full Code Here

Examples of com.palantir.ptoss.cinch.core.BindingContext

    }

    private final SimpleModel model = new SimpleModel();

    public void testModel() {
        BindingContext context = new BindingContext(this);
        assertEquals(model, context.getBindableModel("model"));
    }
View Full Code Here

Examples of com.palantir.ptoss.cinch.core.BindingContext

    public void testGetterIndex() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
        model1.setSimpleString("string1");
        model2.setSimpleString("string2");
        model.setOtherString("other");
        BindingContext context = new BindingContext(this);
        assertNull(context.findGetter("simpleString"));
        ObjectFieldMethod ofm = context.findGetter("model1.simpleString");
        assertEquals("string1", ofm.getMethod().invoke(ofm.getObject(), (Object[])null));
        ofm = context.findGetter("model2.simpleString");
        assertEquals("string2", ofm.getMethod().invoke(ofm.getObject(), (Object[])null));
        ofm = context.findGetter("otherString");
        assertEquals("other", ofm.getMethod().invoke(ofm.getObject(), (Object[])null));
    }
View Full Code Here

Examples of com.palantir.ptoss.cinch.core.BindingContext

        ofm = context.findGetter("otherString");
        assertEquals("other", ofm.getMethod().invoke(ofm.getObject(), (Object[])null));
    }

    public void testSetterIndex() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
        BindingContext context = new BindingContext(this);
        assertNull(context.findSetter("simpleString"));
        ObjectFieldMethod ofm = context.findSetter("model1.simpleString");
        ofm.getMethod().invoke(ofm.getObject(), new Object[] { "set1" });
        assertEquals("set1", model1.getSimpleString());

        ofm = context.findSetter("model2.simpleString");
        ofm.getMethod().invoke(ofm.getObject(), new Object[] { "set2" });
        assertEquals("set2", model2.getSimpleString());

        ofm = context.findSetter("otherString");
        ofm.getMethod().invoke(ofm.getObject(), new Object[] { "setOther" });
        assertEquals("setOther", model.getOtherString());
    }
View Full Code Here

Examples of com.sun.xml.ws.spi.db.BindingContext

                  databindingInfo.setClassLoader(classLoader);
                  databindingInfo.contentClasses().addAll(cls);
                  databindingInfo.typeInfos().addAll(types);
                  databindingInfo.properties().put("c14nSupport", Boolean.FALSE);
                  databindingInfo.setDefaultNamespace(AbstractSEIModelImpl.this.getDefaultSchemaNamespace());
                  BindingContext bc =  BindingContextFactory.create(databindingInfo);
                            if (LOGGER.isLoggable(Level.FINE))
                                LOGGER.log(Level.FINE,
                                        "Created binding context: "
                                                + bc.getClass().getName());
//                  System.out.println("---------------------- databinding " + bc);
                  return bc;
                }
            });
//          createBridgeMap(types);
View Full Code Here

Examples of com.sun.xml.ws.spi.db.BindingContext

        boolean isDoclit = binding.isDocLit();
//        Message message = portDefinitions.message().name(method.getOperation().getName().getLocalPart());
        Message message = portDefinitions.message().name(method.getRequestMessageName());
        extension.addInputMessageExtension(message, method);
        com.sun.xml.ws.wsdl.writer.document.Part part;
        BindingContext jaxbContext = model.getBindingContext();
        boolean unwrappable = true;
        for (ParameterImpl param : method.getRequestParameters()) {
            if (isDoclit) {
                if (isHeaderParameter(param))
                    unwrappable = false;

                part = message.part().name(param.getPartName());
                part.element(param.getName());
            } else {
                if (param.isWrapperStyle()) {
                    for (ParameterImpl childParam : ((WrapperParameter) param).getWrapperChildren()) {
                        part = message.part().name(childParam.getPartName());
                        part.type(jaxbContext.getTypeName(childParam.getXMLBridge().getTypeInfo()));
                    }
                } else {
                    part = message.part().name(param.getPartName());
                    part.element(param.getName());
                }
            }
        }
        if (method.getMEP() != MEP.ONE_WAY) {
            message = portDefinitions.message().name(method.getResponseMessageName());
            extension.addOutputMessageExtension(message, method);

            for (ParameterImpl param : method.getResponseParameters()) {
                if (isDoclit) {
                    part = message.part().name(param.getPartName());
                    part.element(param.getName());

                } else {
                    if (param.isWrapperStyle()) {
                        for (ParameterImpl childParam : ((WrapperParameter) param).getWrapperChildren()) {
                            part = message.part().name(childParam.getPartName());
                            part.type(jaxbContext.getTypeName(childParam.getXMLBridge().getTypeInfo()));
                        }
                    } else {
                        part = message.part().name(param.getPartName());
                        part.element(param.getName());
                    }
View Full Code Here

Examples of com.sun.xml.ws.spi.db.BindingContext

                  databindingInfo.setClassLoader(classLoader);
                  databindingInfo.contentClasses().addAll(cls);
                  databindingInfo.typeInfos().addAll(types);
                  databindingInfo.properties().put("c14nSupport", Boolean.FALSE);
                  databindingInfo.setDefaultNamespace(AbstractSEIModelImpl.this.getDefaultSchemaNamespace());
                  BindingContext bc =  BindingContextFactory.create(databindingInfo);
                            if (LOGGER.isLoggable(Level.FINE))
                                LOGGER.log(Level.FINE,
                                        "Created binding context: "
                                                + bc.getClass().getName());
//                  System.out.println("---------------------- databinding " + bc);
                  return bc;
                }
            });
//          createBridgeMap(types);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.