br.com.caelum.vraptor:vraptor-streamable-pages

Compose your complex pages with small jsps instead of write a big one.

GroupId

GroupId

br.com.caelum.vraptor
ArtifactId

ArtifactId

vraptor-streamable-pages
Last Version

Last Version

4.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Compose your complex pages with small jsps instead of write a big one.
Source Code Management

Source Code Management

http://github.com/asouza/vraptor-streamable-pages

Download vraptor-streamable-pages

How to add to project

<!-- https://jarcasting.com/artifacts/br.com.caelum.vraptor/vraptor-streamable-pages/ -->
<dependency>
    <groupId>br.com.caelum.vraptor</groupId>
    <artifactId>vraptor-streamable-pages</artifactId>
    <version>4.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/br.com.caelum.vraptor/vraptor-streamable-pages/
implementation 'br.com.caelum.vraptor:vraptor-streamable-pages:4.0.1'
// https://jarcasting.com/artifacts/br.com.caelum.vraptor/vraptor-streamable-pages/
implementation ("br.com.caelum.vraptor:vraptor-streamable-pages:4.0.1")
'br.com.caelum.vraptor:vraptor-streamable-pages:jar:4.0.1'
<dependency org="br.com.caelum.vraptor" name="vraptor-streamable-pages" rev="4.0.1">
  <artifact name="vraptor-streamable-pages" type="jar" />
</dependency>
@Grapes(
@Grab(group='br.com.caelum.vraptor', module='vraptor-streamable-pages', version='4.0.1')
)
libraryDependencies += "br.com.caelum.vraptor" % "vraptor-streamable-pages" % "4.0.1"
[br.com.caelum.vraptor/vraptor-streamable-pages "4.0.1"]

Dependencies

compile (5)

Group / Artifact Type Version
br.com.caelum : vraptor jar 4.0.0.Final
org.jboss.weld.servlet : weld-servlet-core jar 2.1.2.Final
org.jboss.weld : weld-core-impl jar 2.1.2.Final
com.ning : async-http-client jar 1.8.4
org.scala-lang : scala-library jar 2.10.4

provided (3)

Group / Artifact Type Version
javax.inject : javax.inject jar 1
javax.servlet : javax.servlet-api jar 3.1.0
javax.servlet : jsp-api jar 2.0

test (4)

Group / Artifact Type Version
junit : junit jar 4.11
org.mockito : mockito-all jar 1.9.0
io.undertow : undertow-core jar 1.0.1.Final
io.undertow : undertow-servlet jar 1.0.1.Final

Project Modules

There are no modules declared in this project.

VRaptor streamable pages

This projects aims to enable async rendering of htmls using VRaptor. The inspiration came from this Linkedin talk(http://engineering.linkedin.com/play/composable-and-streamable-play-apps).

#Configuring

If you are using maven, simply add the following dependency:

<dependency>
    <groupId>br.com.caelum.vraptor</groupId>
    <artifactId>vraptor-streamable-pages</artifactId>
    <version>4.0.1</version>
</dependency>

#Example

Take a look on this example:

@Controller
public class IndexController {

	private final Result result;
	@Inject
	private Streamer streamer;

	/**
	 * @deprecated CDI eyes only
	 */
	public IndexController() {
		this(null);
	}

	@Inject
	public IndexController(Result result) {
		this.result = result;
	}

	@Path("/")
	public void index() throws IOException, InterruptedException, ExecutionException {
		streamer.order("http://localhost:8080/vraptor-blank-project/index/start")
				.unOrder("http://localhost:8080/vraptor-blank-project/header",
						"http://localhost:8080/vraptor-blank-project/body",
						"http://localhost:8080/vraptor-blank-project/footer")
				.order("http://localhost:8080/vraptor-blank-project/end");
		result.nothing();
	}

    @Path("/start")
	public void start() {
		result.include("variable", "VRaptor!");
	}

    @Path("/header")
	public void header() throws InterruptedException {
		Thread.sleep(2000);
	}

    @Path("/body")
	public void body() {
	}

    @Path("/footer")
	public void footer() {
	}

    @Path("/path")
	public void end() {

	}

}

Example using jsp

You can also use our taglib to achieve the same result. Suppose that your /WEB-INF/jsp/index/inidex.jsp is like this:

<%@taglib prefix="streamer" uri="http://vraptor.org/jsp/taglib/streamer" %>
<html>
    <head>
        <link src="css/styles.css" rel="stylesheet">
    </head>
    <body>
        <div id="header-pagelet"></div>
        <div id="body-pagelet"></div>
        <div id="footer-pagelet"></div>

        <streamer:stream>
            <streamer:page url="header"/>
            <streamer:page url="body"/>
            <streamer:page url="footer"/>
        </streamer:stream>
    </body>
</html>

Versions

Version
4.0.1
4.0.0