<commit_before>/*******************************************************************************
 * Panifex platform
 * Copyright (C) 2013  <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 ******************************************************************************/
package org.panifex.module.zk.api;

import org.zkoss.zk.ui.GenericRichlet;

public abstract class GenericZkPagelet extends GenericRichlet implements ZkPagelet {

}<commit_msg>Adds binder helper methods to GenericZkPagelet<commit_after>/*******************************************************************************
 * Panifex platform
 * Copyright (C) 2013  <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 ******************************************************************************/
package org.panifex.module.zk.api;

import org.zkoss.bind.DefaultBinder;
import org.zkoss.bind.impl.ValidationMessagesImpl;
import org.zkoss.bind.sys.ValidationMessages;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.GenericRichlet;

public abstract class GenericZkPagelet extends GenericRichlet implements ZkPagelet {

    private final String FX_BIND_ID = "FX";
    private final String VM_BIND_ID = "VM";
    private final String VMSGS_BIND_ID = "VMSGS";

    protected String fx(String property) {
        return new StringBuilder(FX_BIND_ID).
                append('.').
                append(property).
                toString();
    }

    protected String vm(String property) {
        return new StringBuilder(VM_BIND_ID).
                append('.').
                append(property).
                toString();
    }

    protected String vmsgs(String vmessage) {
        return new StringBuilder(VMSGS_BIND_ID).
                append('.').
                append(vmessage).
                toString();
    }

    protected DefaultBinder createBinder(Component parent, Object viewModel) {
        DefaultBinder binder = new DefaultBinder();
        binder.init(parent, viewModel, null);
        parent.setAttribute(VM_BIND_ID, binder.getViewModel());
        return binder;
    }

    protected ValidationMessages createValidationMessages(Component parent, DefaultBinder binder) {
        ValidationMessages vmessages = new ValidationMessagesImpl();
        binder.setValidationMessages(vmessages);
        parent.setAttribute(VMSGS_BIND_ID, vmessages);
        return vmessages;
    }
}
{'fraction_non_alphanumeric': 0.14889067094359798, 'fraction_numerical': 0.0090884790163058, 'mean_word_length': 3.6254635352286773, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1467819', 'n_tokens_mistral': 953, 'n_tokens_neox': 888, 'n_words': 354}