Search in sources :

Example 1 with Binder

use of org.zkoss.bind.Binder in project collect by openforis.

the class NodeDefinitionVM method validateForm.

protected void validateForm(@ContextParam(ContextType.BINDER) Binder binder) {
    Component view = binder.getView();
    IdSpace currentIdSpace = view.getSpaceOwner();
    Component formComponent = Path.getComponent(currentIdSpace, FORM_CONTAINER_ID);
    Binder formComponentBinder = (Binder) formComponent.getAttribute("binder");
    formComponentBinder.postCommand("applyChanges", null);
}
Also used : Binder(org.zkoss.bind.Binder) IdSpace(org.zkoss.zk.ui.IdSpace) Component(org.zkoss.zk.ui.Component)

Example 2 with Binder

use of org.zkoss.bind.Binder in project collect by openforis.

the class BaseValidator method getVM.

@SuppressWarnings("unchecked")
protected <T extends BaseVM> T getVM(ValidationContext ctx) {
    BindContext bindContext = ctx.getBindContext();
    Binder binder = bindContext.getBinder();
    Object vmObject = binder.getViewModel();
    if (vmObject == null) {
        throw new IllegalStateException("Unable to find view model instance");
    }
    return (T) vmObject;
}
Also used : BindContext(org.zkoss.bind.BindContext) Binder(org.zkoss.bind.Binder)

Example 3 with Binder

use of org.zkoss.bind.Binder in project collect by openforis.

the class ComponentUtil method getAncestorViewModel.

@SuppressWarnings("unchecked")
public static <T> T getAncestorViewModel(Component component, Class<T> viewModelClass) {
    Component currentParent = component.getParent();
    while (currentParent != null) {
        Binder binder = getBinder(currentParent);
        if (binder != null) {
            Object vm = binder.getViewModel();
            if (vm != null && viewModelClass.isAssignableFrom(vm.getClass())) {
                return (T) vm;
            }
        }
        currentParent = currentParent.getParent();
    }
    return null;
}
Also used : Binder(org.zkoss.bind.Binder) Component(org.zkoss.zk.ui.Component) HtmlBasedComponent(org.zkoss.zk.ui.HtmlBasedComponent)

Example 4 with Binder

use of org.zkoss.bind.Binder in project collect by openforis.

the class ComponentUtil method getViewModel.

@SuppressWarnings("unchecked")
public static <T> T getViewModel(Component component) {
    Binder binder = getBinder(component);
    Object viewModel = binder.getViewModel();
    return (T) viewModel;
}
Also used : Binder(org.zkoss.bind.Binder)

Example 5 with Binder

use of org.zkoss.bind.Binder in project collect by openforis.

the class SchemaVM method applyChangesToForm.

protected void applyChangesToForm(IdSpace idSpace) {
    Binder binder = getNodeFormBinder(idSpace);
    binder.postCommand(APPLY_CHANGES_COMMAND, null);
}
Also used : Binder(org.zkoss.bind.Binder)

Aggregations

Binder (org.zkoss.bind.Binder)9 Component (org.zkoss.zk.ui.Component)4 IdSpace (org.zkoss.zk.ui.IdSpace)2 HashMap (java.util.HashMap)1 CodeListFormObject (org.openforis.collect.designer.form.CodeListFormObject)1 FormObject (org.openforis.collect.designer.form.FormObject)1 BindContext (org.zkoss.bind.BindContext)1 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)1 HtmlBasedComponent (org.zkoss.zk.ui.HtmlBasedComponent)1