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;
}
}