src/main/java/org/efaps/ui/wicket/util/DojoWrapper.java
public static CharSequence require(final CharSequence _script,
                                       final String _layer,
                                       final DojoClass... _classes)
    {
        final StringBuilder ret = new StringBuilder();
        if (_layer != null) {
            ret.append("require(['").append(_layer).append("'],function() {\n");
        }

        ret.append("require([");
        final StringBuilder paras = new StringBuilder();
        boolean first = true;
        final List<DojoClass> libs = Arrays.asList(_classes);

        final ComparatorChain<DojoClass> comparator = new ComparatorChain<>();
        comparator.addComparator(new Comparator<DojoClass>()
        {

            @Override
            public int compare(final DojoClass _arg0,
                               final DojoClass _arg1)
            {
                return _arg0.getParameterName() == null && _arg1.getParameterName() == null || _arg0
                                .getParameterName() != null && _arg1.getParameterName() != null ? 0
                                                : _arg0.getParameterName() == null ? 1 : -1;
            }
        });
        comparator.addComparator(new Comparator<DojoClass>()
        {

            @Override
            public int compare(final DojoClass _arg0,
                               final DojoClass _arg1)
            {
                return _arg0.getClassName().compareTo(_arg1.getClassName());
            }
        });
        Collections.sort(libs, comparator);
        for (final DojoClass dojoLibs : libs) {
            if (first) {
                first = false;
            } else {
                ret.append(",");
                if (dojoLibs.getParameterName() != null) {
                    paras.append(",");
                }
            }
            ret.append("\"").append(dojoLibs.getClassName()).append("\"");
            if (dojoLibs.getParameterName() != null) {
                paras.append(dojoLibs.getParameterName());
            }
        }
        if (_script == null) {
            ret.append("]);");
        } else {
            ret.append("],").append(" function(").append(paras).append(") {\n").append(_script).append("});");
        }
        if (_layer != null) {
            ret.append("});");
        }
        return ret;
    }
public static CharSequence require(final CharSequence _script,
                                       final String _layer,
                                       final DojoClass... _classes)
    {
        final StringBuilder ret = new StringBuilder();
        if (_layer != null) {
            ret.append("require(['").append(_layer).append("'],function() {\n");
        }

        ret.append("require([");
        final StringBuilder paras = new StringBuilder();
        boolean first = true;
        final List<DojoClass> libs = Arrays.asList(_classes);

        final ComparatorChain<DojoClass> comparator = new ComparatorChain<>();
        comparator.addComparator(new Comparator<DojoClass>()
        {

            @Override
            public int compare(final DojoClass _arg0,
                               final DojoClass _arg1)
            {
                return _arg0.getParameterName() == null && _arg1.getParameterName() == null || _arg0
                                .getParameterName() != null && _arg1.getParameterName() != null ? 0
                                                : _arg0.getParameterName() == null ? 1 : -1;
            }
        });
        comparator.addComparator(new Comparator<DojoClass>()
        {

            @Override
            public int compare(final DojoClass _arg0,
                               final DojoClass _arg1)
            {
                return _arg0.getClassName().compareTo(_arg1.getClassName());
            }
        });
        Collections.sort(libs, comparator);
        for (final DojoClass dojoLibs : libs) {
            if (first) {
                first = false;
            } else {
                ret.append(",");
                if (dojoLibs.getParameterName() != null) {
                    paras.append(",");
                }
            }
            ret.append("\"").append(dojoLibs.getClassName()).append("\"");
            if (dojoLibs.getParameterName() != null) {
                paras.append(dojoLibs.getParameterName());
            }
        }
        if (_script == null) {
            ret.append("]);");
        } else {
            ret.append("],").append(" function(").append(paras).append(") {\n").append(_script).append("});");
        }
        if (_layer != null) {
            ret.append("});");
        }
        return ret;
    }
Require.

@param _script the script
@param _layer the layer
@param _classes the classes
@return the char sequence