Package org.jibeframework.core.ui.wrapper.mapprocessor

Source Code of org.jibeframework.core.ui.wrapper.mapprocessor.ModelPreprocessor

package org.jibeframework.core.ui.wrapper.mapprocessor;

import java.util.HashMap;
import java.util.Map;

import org.jibeframework.core.Context;
import org.jibeframework.core.ui.wrapper.MapWrapper;

public class ModelPreprocessor implements MapWrapperPreprocessor {

  private static final String FORM_VALIDATION = "__formValidation";
  private static final String JVALIDATION = "jvalidation";

  public boolean applies(MapWrapper wrapper) {
    return wrapper.getConfig().containsKey("jmodel");
  }

  public MapWrapper process(MapWrapper wrapper) {
    Context currentContext = Context.getCurrentContext();
    currentContext.startModelBuilding((String) wrapper.getModelScope());
    if (wrapper.getConfig().containsKey(JVALIDATION)) {
      Map<String, Object> entry = new HashMap<String, Object>();
      entry.put(JVALIDATION, wrapper.getConfig().remove(JVALIDATION));
      currentContext.addModelEntry(FORM_VALIDATION, entry);
    }
    return wrapper;
  }

}
TOP

Related Classes of org.jibeframework.core.ui.wrapper.mapprocessor.ModelPreprocessor

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.