Skip to content

cuzz22000/dropwizard-views-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Dropwizard View React

Implements a React view component utilizing KnisterPeter's JReact library.

Maven Central

TODO

Usage

Templates are resolved from the classpath where the templates directory root is `/react/. And path to templates match the view classes package structure.

${project.root}
 - src
  - java
   - ${package_path}
    - YourView.java
  - main
  - resources
   - react
    - ${package_path}
     - your-view.react

Example ${package_path} paths for file and template files:

# class file
org/example/dw/views/YourView.java

# View Template
org/example/dw/views/your-view.react

Simple Template.... way cooler stuff can be found @ React

var React = require('react')


var Test = React.createClass({
  render: function() {
    return (
      React.DOM.div(null, this.props.view.mess)
    );
  }
});

module.exports = Test;

View Class referencing the test.react template

package io.dropwizard.views;

public class TestView extends View {

  public TestView() {
    super("test.react");
  }

  public String getMess() {
    return MESSAGE;
  }

  public static final String MESSAGE = "Hello World!";
}

Create the resource that maps to the view and you're in business.

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.test.dropwizard.views.TestView;

@Produces(MediaType.TEXT_HTML)
@Path("/")
public class TestResource {

  @GET
  @Path("test")
  public TestView test() {
    return new TestView();
  }

}

About

React View renderer for Dropwizard

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages