Coder Social home page Coder Social logo

wicket-jquery-selectors's Introduction

wicket-jquery-selectors

Utility library for working with JQuery and Apache Wicket.

Current release version:

  • For Wicket 8.x use 2.x
  • For Wicket 7.x use 0.2.x
  • For Wicket 6.x use 0.1.x

Configuration

configure wicket-jquery-selectors in application init method (optional)

WicketJquerySelectors.install(new WicketJquerySelectorsSettings().setObjectMapperFactory(new MyCustomObjectMapperFactory()));

Usage

The following example uses the bootstrap typeahead jquery plugin:

Config classes

Create a subclass of AbstractConfig (or use one of the existing configs) to build the options object for a JQuery plugin. You can omit this step if the JQuery plugin doesn't need any options:

    import de.agilecoders.wicket.jquery.AbstractConfig;
    import de.agilecoders.wicket.jquery.IDataSource;

    public class TypeaheadConfig extends AbstractConfig {

        private static final IKey<IDataSource> Source = newKey("source", null);
        private static final IKey<Integer> MinLength = newKey("minLength", 1);

        public TypeaheadConfig withDataSource(final IDataSource<?> value) {
            put(Source, value);
            return this;
        }

        public TypeaheadConfig withMinLength(final int value) {
            put(MinLength, value);
            return this;
        }
    }

JQuery method chaining

    import static de.agilecoders.wicket.jquery.JQuery.$;

    public class Typeahead<T> extends TextField<T> {

        @Override
        public void renderHead(final IHeaderResponse response) {
            super.renderHead(response);

            // setup the options
            TypeaheadConfig config = new TypeaheadConfig();
            config.withDataSource(dataSource);
            config.withMinLength(3);

            // render the header contribution
            response.render($(this).chain("typeahead", config).asDomReadyScript());
        }
    }

The above code will generate the following javascript:

    $('#wicketComponentId').typeahead({"dataSource" : "<wicket-ajax-callback>", "minLength": 3});

wicket-jquery-selectors's People

Contributors

martin-g avatar l0rdn1kk0n avatar pulse00 avatar klopfdreh avatar dutrieux avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.