001    package com.khubla.pragmatach.examples.velocityexample;
002    
003    import java.util.Date;
004    
005    import com.khubla.pragmatach.framework.annotation.Controller;
006    import com.khubla.pragmatach.framework.annotation.Route;
007    import com.khubla.pragmatach.framework.annotation.RouteParameter;
008    import com.khubla.pragmatach.framework.annotation.View;
009    import com.khubla.pragmatach.framework.api.PragmatachException;
010    import com.khubla.pragmatach.framework.api.Response;
011    import com.khubla.pragmatach.plugin.velocity.VelocityController;
012    
013    @Controller(name = "IndexController")
014    @View(view = "index.vtl")
015    public class IndexController extends VelocityController {
016       /**
017        * the message
018        */
019       private final String message = "hello world";
020       /**
021        * the sum
022        */
023       private int sum = 0;
024    
025       public String getMessage() {
026          return message;
027       }
028    
029       public int getSum() {
030          return sum;
031       }
032    
033       public String getTime() {
034          return new Date().toString();
035       }
036    
037       @Override
038       @Route(uri = "/")
039       public Response render() throws PragmatachException {
040          return super.render();
041       }
042    
043       @Route(uri = "/@num")
044       public Response render(@RouteParameter(name = "num") int number) throws PragmatachException {
045          sum = number * 2;
046          return super.render();
047       }
048    
049       public void setSum(int sum) {
050          this.sum = sum;
051       }
052    }