javax.mvc.View Java Examples

The following examples show how to use javax.mvc.View. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnnotationUtilsTest.java    From krazo with Apache License 2.0 6 votes vote down vote up
@Test
public void getAnnotationOnMethod() throws NoSuchMethodException {
    View view = AnnotationUtils.getAnnotation(someController.getClass().getMethod("start"), View.class);
    assertThat(view.value(), is("start.jsp"));
    NotNull notNull = AnnotationUtils.getAnnotation(someBean.getClass().getMethod("notNull"), NotNull.class);
    assertThat(notNull.message(), is("notNull"));
    assertThat(AnnotationUtils.getAnnotation(BaseController.class.getMethod("start"), View.class), is(notNullValue()));
    assertThat(AnnotationUtils.getAnnotation(InheritedController.class.getMethod("start"), View.class), is(notNullValue()));
    assertThat(AnnotationUtils.getAnnotation(ControllerImpl.class.getMethod("start"), View.class), is(notNullValue()));
    View inheritedView = AnnotationUtils.getAnnotation(InheritedControllerImpl.class.getMethod("start"), View.class);
    // Annotations on a super-class take precedence over those on an implemented interface
    assertThat(inheritedView.value(), is("start-base.jsp"));
    // if a subclass or implementation method has any MVC or JAX-RS annotations
    // then all of the annotations on the superclass or interface method are ignored
    assertThat(AnnotationUtils.getAnnotation(NoInheritanceController.class.getMethod("start"), Path.class), is(nullValue()));
}
 
Example #2
Source File: TaskController.java    From ee8-sandbox with Apache License 2.0 6 votes vote down vote up
@GET
@View("tasks.jspx")
public void allTasks() {
    log.log(Level.INFO, "fetching all tasks");

    List<Task> todotasks = taskRepository.findByStatus(Task.Status.TODO);
    List<Task> doingtasks = taskRepository.findByStatus(Task.Status.DOING);
    List<Task> donetasks = taskRepository.findByStatus(Task.Status.DONE);

    log.log(Level.INFO, "got all tasks: todotasks@{0}, doingtasks@{1}, donetasks@{2}", new Object[]{todotasks.size(), doingtasks.size(), donetasks.size()});

    models.put("todotasks", todotasks);
    models.put("doingtasks", doingtasks);
    models.put("donetasks", donetasks);

}
 
Example #3
Source File: HelloController.java    From ozark with Apache License 2.0 5 votes vote down vote up
@GET
@Controller
@Produces("text/html")
@View("hello.st")
public void hello(@QueryParam("user") String user) {
    models.put("user", user);
}
 
Example #4
Source File: GroovyController.java    From ozark with Apache License 2.0 5 votes vote down vote up
@GET
@Controller
@Produces("text/html")
@View("index.groovy")
public void index(@QueryParam("name") String name) {
    models.put("name", name);
}
 
Example #5
Source File: JythonController.java    From ozark with Apache License 2.0 5 votes vote down vote up
@GET
@Controller
@Produces("text/html")
@View("index.py")
public void index(@QueryParam("name") String name) {
    models.put("name", name);
}
 
Example #6
Source File: JadeController.java    From ozark with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/config")
@Controller
@View("config.jade")
public void getCofig(@QueryParam("article") String article) {
    models.put("pageName", "Configuration");
}
 
Example #7
Source File: BookController.java    From ozark with Apache License 2.0 5 votes vote down vote up
@GET
@Produces("text/html")
@Path("view4/{id}")
@View("book.jsp")
public void view4(@PathParam("id") String id) {
    models.put("book", catalog.getBook(id));
}
 
Example #8
Source File: BookController.java    From ozark with Apache License 2.0 5 votes vote down vote up
@GET
@Produces("text/html")
@Path("view2/{id}")
@View("book.xhtml")
public void view2(@PathParam("id") String id) {
    models.put("book", catalog.getBook(id));
}
 
Example #9
Source File: BookController.java    From ozark with Apache License 2.0 5 votes vote down vote up
/**
 * MVC controller to render a book in HTML. Uses CDI and request
 * scope to bind a book instance. The view template is specified
 * using @View.
 *
 * @param id ID of the book given in URI.
 */
@GET
@Controller
@Produces("text/html")
@Path("view2/{id}")
@View("book.jsp")
public void view2(@PathParam("id") String id) {
    book.setId(id);
    book.setTitle("Some title");
    book.setAuthor("Some author");
    book.setIsbn("Some ISBN");
}
 
Example #10
Source File: HelloController.java    From ozark with Apache License 2.0 5 votes vote down vote up
/**
 * XHTML type should override static HTML one in @Produces in this case
 * when using @View.
 */
@GET
@Path("other_produces2")
@Produces("text/html")      // overridden below
@View("hello.jsp")
public Response otherProduces2() {
    return Response.ok(new Viewable("hello.jsp"), "application/xhtml+xml").build();
}
 
Example #11
Source File: HelloController.java    From ozark with Apache License 2.0 5 votes vote down vote up
/**
 * Sets language to "es" when using @View.
 */
@GET
@Path("language2")
@Produces("text/html")      // overridden below
@View("hello.jsp")
public Response language2() {
    return Response.ok(new Viewable("hello.jsp"), "application/xhtml+xml").language("es").build();
}
 
Example #12
Source File: HelloController.java    From ozark with Apache License 2.0 5 votes vote down vote up
/**
 * Sets locale to UK when using @View.
 */
@GET
@Path("locale2")
@Produces("text/html")      // overridden below
@View("hello.jsp")
public Response locale2() {
    return Response.ok(new Viewable("hello.jsp"), "application/xhtml+xml").language(Locale.UK).build();
}
 
Example #13
Source File: HelloController.java    From ozark with Apache License 2.0 5 votes vote down vote up
@GET
@Controller
@Produces("text/html")
@View("hello2.vhtml")
@Path("v2")
public void hello2(@QueryParam("user2") String user2) {
    models.put("user2", user2);
}
 
Example #14
Source File: HelloController.java    From ozark with Apache License 2.0 5 votes vote down vote up
/**
 * Method that returns a null value. View 'hello.jsp' should be rendered.
 *
 * @return View to render.
 */
@GET
@Path("null")
@View("hello.jsp")
public String nullController() {
    return null;
}
 
Example #15
Source File: HelloController.java    From ozark with Apache License 2.0 5 votes vote down vote up
@GET
@Controller
@Produces("text/html")
@View("hello.html")
public void hello(@QueryParam("user") String user) {
    greeting.setUser(user);
}
 
Example #16
Source File: HelloController.java    From ozark with Apache License 2.0 5 votes vote down vote up
/**
 * Method that throws a ForbiddenException. View 'hello.jsp' should be rendered.
 */
@GET
@Path("string/forbidden")
@View("hello.jsp")
public String stringForbiddenException() {
    throw new ForbiddenException();
}
 
Example #17
Source File: HelloController.java    From ozark with Apache License 2.0 5 votes vote down vote up
/**
 * If HTML and XHTML are equally preferred, the latter should be chosen
 * given the lower qs on the former when using @View.
 */
@GET
@Produces({"text/html;qs=0.9", "application/xhtml+xml"})
@Path("multiple_produces2")
@View("hello.jsp")
public void multipleProduces2() {
}
 
Example #18
Source File: BookController.java    From ozark with Apache License 2.0 5 votes vote down vote up
/**
 * MVC controller to render a book in HTML. Uses the models map to
 * bind a book instance and @View to specify path to view.
 *
 * @param id ID of the book given in URI.
 */
@GET
@Controller
@Produces("text/html")
@Path("view2/{id}")
@View("book.xhtml")
public void view2(@PathParam("id") String id) {
    models.put("book", catalog.getBook(id));
}
 
Example #19
Source File: AnnotationUtilsTest.java    From krazo with Apache License 2.0 5 votes vote down vote up
@Test
public void hasAnnotationOnMethod() throws NoSuchMethodException {
    assertTrue(AnnotationUtils.hasAnnotation(someController.getClass().getMethod("start"), View.class));
    assertFalse(AnnotationUtils.hasAnnotation(someController.getClass().getMethod("start"), NotNull.class));
    assertTrue(AnnotationUtils.hasAnnotation(someBean.getClass().getMethod("notNull"), NotNull.class));
    assertFalse(AnnotationUtils.hasAnnotation(someBean.getClass().getMethod("notNull"), View.class));
    assertTrue(AnnotationUtils.hasAnnotation(BaseController.class.getMethod("start"), View.class));
    assertTrue(AnnotationUtils.hasAnnotation(InheritedController.class.getMethod("start"), View.class));
    assertTrue(AnnotationUtils.hasAnnotation(ControllerImpl.class.getMethod("start"), View.class));
    // if a subclass or implementation method has any MVC or JAX-RS annotations
    // then all of the annotations on the superclass or interface method are ignored
    assertFalse(AnnotationUtils.hasAnnotation(NoInheritanceController.class.getMethod("start"), Path.class));
}
 
Example #20
Source File: JadeController.java    From krazo with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/helper")
@Controller
@View("helper.jade")
public void getCofig() {
    models.put("pageName", "Helper");
}
 
Example #21
Source File: JadeController.java    From krazo with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/config")
@Controller
@View("config.jade")
public void getCofig(@QueryParam("article") String article) {
    models.put("pageName", "Configuration");
}
 
Example #22
Source File: JadeController.java    From krazo with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/markdown")
@Controller
@View("markdown.jade")
public void getMarkdownd(@QueryParam("article") String article) {
    models.put("pageName", "Markdown Introduction");
}
 
Example #23
Source File: JadeController.java    From krazo with Apache License 2.0 5 votes vote down vote up
@GET
@Controller
@View("main.jade")
public void get(@QueryParam("user") String user) {
    models.put("user", user);
    models.put("pageName", "Hello Jade");
}
 
Example #24
Source File: HelloController.java    From krazo with Apache License 2.0 5 votes vote down vote up
@GET
@Controller
@Produces("text/html")
@View("hello.mustache")
public void hello(@QueryParam("user") String user) {
    models.put("user", user);
}
 
Example #25
Source File: HelloController.java    From krazo with Apache License 2.0 5 votes vote down vote up
@GET
@Controller
@Produces("text/html")
@View("hello2.vhtml")
@Path("v2")
public void hello2(@QueryParam("user2") String user2) {
    models.put("user2", user2);
}
 
Example #26
Source File: HelloController.java    From krazo with Apache License 2.0 5 votes vote down vote up
@GET
@Controller
@Produces("text/html")
@View("hello.vm")
@Path("v1")
public void hello(@QueryParam("user") String user) {
    models.put("user", user);
}
 
Example #27
Source File: HelloController.java    From krazo with Apache License 2.0 5 votes vote down vote up
@GET
@Controller
@Produces("text/html")
@View("hello.st")
public void hello(@QueryParam("user") String user) {
    models.put("user", user);
}
 
Example #28
Source File: HelloController.java    From krazo with Apache License 2.0 5 votes vote down vote up
@GET
@Controller
@Produces("text/html")
@View("hello.adoc")
public void hello(@QueryParam("user") String user) {
    models.put("user", user);
}
 
Example #29
Source File: JythonController.java    From krazo with Apache License 2.0 5 votes vote down vote up
@GET
@Controller
@Produces("text/html")
@View("index.py")
public void index(@QueryParam("name") String name) {
    models.put("name", name);
}
 
Example #30
Source File: NashornController.java    From krazo with Apache License 2.0 5 votes vote down vote up
@GET
@Controller
@Produces("text/html")
@View("index.js")
public void index(@QueryParam("name") String name) {
    models.put("name", name);
}