Git Product home page Git Product logo

wicket-jade's Introduction

Wicket-Jade integration

Wicket-Jade integration. The current implementation is based on jade4j.
The Jade template/panel supports children (wicket) components, i.e. have div(wicket:id="someId") inside.

Current build status: Build Status

Components

  • JadePanel is a panel that displays the result of rendering a Jade template.

Artifacts

  • Wicket Jade wicket-jade (jar)
  • Wicket Jade Demo wicket-jade-demo (war)

Using Maven

In your pom.xml you must define the dependencies to Wicket Jade artifacts with:

<dependency>
    <groupId>ro.fortsoft.wicket.jade</groupId>
    <artifactId>wicket-jade</artifactId>
    <version>${wicket-jade.version}</version>
</dependency>    

where ${wicket-jade.version} is the last wicket-jade version.

You may want to check for the latest released version using Maven Search

How to use

It's very simple to add a jade panel in your wicket application.

Define entity (business) object - a simple POJO:

public class Book implements Serializable {
	
	private String name;
	private double price;
	private boolean available;
	
	public Book(String name, double price, boolean available) {
		this.name = name;
		this.price = price;
		this.available = available;
	}

    // getters and setters
}
public class Author implements Serializable {

	private String firstName;
	private String lastName;
	private String country;
	
	public Author(String firstName, String lastName, String country) {
		this.firstName = firstName;
		this.lastName = lastName;
		this.country = country;
	}
	
	// getters and setters
}

In your wicket page:

public class HomePage extends WebPage {

    public HomePage() {
	    super();		
    }

    @Override
    protected void onInitialize() {
	    super.onInitialize();
	
		List<Book> books = new ArrayList<Book>();
		books.add(new Book("The Hitchhiker's Guide to the Galaxy", 5.70, true));
		books.add(new Book("Life, the Universe and Everything", 5.60, false));
		books.add(new Book("The Restaurant at the End of the Universe", 5.40, true));
		
		Map<String, Object> booksModel = new HashMap<String, Object>();
		booksModel.put("books", books);
		
		JadePanel booksPanel = new BooksPanel("booksPanel", booksModel);
		booksPanel.setRenderBodyOnly(true);
		add(booksPanel);
		
		Author author = new Author("Douglas", "Adams", "England");
		
		Map<String, Object> authorModel = new MicroMap<String, Object>();
		authorModel.put("author", author);
		AuthorPanel authorPanel = new AuthorPanel("authorPanel", authorModel);
		authorPanel.setRenderBodyOnly(true);
		
		booksPanel.add(authorPanel);
    }  

}

Your jade template - BooksPanel.jade (in HomePage package or in other location):

div(wicket:id="authorPanel")
ol#books
  for book in books
    if book.available
      li #{book.name} for #{book.price} €

AuthorPanel.jade

.author
  .name #{author.firstName} #{author.lastName} from #{author.country}:

Running the above code will result in the following html output for jade file

<div class="author">
	<div class="name">Douglas Adams from England:</div>		
</div>
<ol id="books">
	<li>The Hitchhiker's Guide to the Galaxy for 5.7 €</li>
	<li>The Restaurant at the End of the Universe for 5.4 €</li>
</ol>

Demo

The demo application is in demo package. To run the demo application use:

mvn install
cd demo
mvn jetty:run

In the internet browser type http://localhost:8081/.

License

Copyright 2013 Decebal Suiu

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

wicket-jade's People

Contributors

decebals avatar wtfiwtz avatar

Watchers

 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.