Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/martin-g/wicket-jquery-selectors
wicket-jquery-selectors
https://github.com/martin-g/wicket-jquery-selectors
Last synced: 2 months ago
JSON representation
wicket-jquery-selectors
- Host: GitHub
- URL: https://github.com/martin-g/wicket-jquery-selectors
- Owner: martin-g
- License: apache-2.0
- Created: 2013-09-11T05:53:33.000Z (over 11 years ago)
- Default Branch: wicket-7.x
- Last Pushed: 2024-06-04T07:25:02.000Z (7 months ago)
- Last Synced: 2024-09-13T01:53:40.997Z (4 months ago)
- Language: Java
- Size: 277 KB
- Stars: 15
- Watchers: 7
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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)
```java
WicketJquerySelectors.install(new WicketJquerySelectorsSettings().setObjectMapperFactory(new MyCustomObjectMapperFactory()));
```## Usage
The following example uses the [bootstrap typeahead](http://getbootstrap.com/2.3.2/javascript.html#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:```java
import de.agilecoders.wicket.jquery.AbstractConfig;
import de.agilecoders.wicket.jquery.IDataSource;public class TypeaheadConfig extends AbstractConfig {
private static final IKey Source = newKey("source", null);
private static final IKey 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
```java
import static de.agilecoders.wicket.jquery.JQuery.$;
public class Typeahead extends TextField {
@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:
```javascript
$('#wicketComponentId').typeahead({"dataSource" : "", "minLength": 3});
```