Git Product home page Git Product logo

voya's Introduction

Voya Framework

Voya Framework is an integrated full-stack Java framework for rapid web development. It's a simple but powerful dispatch action with no configuration required (convention over configuration).

Get Started!

Use the VoyaServlet in the web.xml configuration file and you're good to go. The url are mapped over conventions.

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <servlet>
        <servlet-name>VelocityView</servlet-name>
        <servlet-class>org.apache.velocity.tools.view.VelocityViewServlet</servlet-class>
    </servlet>
    
    <servlet>
        <servlet-name>VoyaServlet</servlet-name>
        <servlet-class>org.voya.core.VoyaServlet</servlet-class>
        <init-param>
            <param-name>ControllerClassesPackage</param-name>
            <param-value>org.voya.example</param-value> <!-- Tells the framework where to find the controller classes -->
        </init-param>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>VelocityView</servlet-name>
        <url-pattern>*.vm</url-pattern>
    </servlet-mapping>
    
    <servlet-mapping>
            <servlet-name>default</servlet-name>
            <url-pattern>/resources/*</url-pattern>
    </servlet-mapping>
    
    <servlet-mapping>
        <servlet-name>VoyaServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>    
    
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
</web-app>

/ExampleController/method?name=john&year=1... This url maps to a controller class method.

class MyBean
{
  private String name;
  private Integer year;
  
  set's...
  get's...
}


class ExampleController
{
  private HttpServletRequest request;
  private HttpServletResponse response;

  public ExampleController()
  {
  }
  
  public ExampleController(HttpServletRequest r, HttpServletResponse res)
  {
    this.request = r;
    this.response = res;
  }


  public String method(MyBean b)
  {
    ...
    request.setAttribute("myVar", "<h2>Any text or object can go here</h2>");
    request.setAttribute("object", b);
    return "WEB-INF/templates/method.vm";
  }
}

Once the controller is done, you can redirect the flow to the next view. Whatever you put in the request gets to the view (templates). Voya uses Apache Velocity as the template engine. So, in method.vm you'll have:

<html>
  ...
  <body>
    <h1>Hello $object.name</h1>
    $myVar
  </body>
</html>

This is it! Any variables you pass to the request can also be accessed from the template.

voya's People

Contributors

lfdajr avatar

Stargazers

 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.