/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nl.meine.locationservice.stripes;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.StrictBinding;
import net.sourceforge.stripes.action.UrlBinding;
import net.sourceforge.stripes.validation.Validate;

/**
 *
 * @author Meine Toonen <toonen.meine@gmail.com>
 */

@UrlBinding("/add/{id}/{x},{y}")
@StrictBinding
public class AddActionBean implements ActionBean{
    private ActionBeanContext context;
    private static final String JSP  = "/WEB-INF/jsp/view.jsp";
    
    @Validate
    private Integer id;
    
    @Validate
    private Integer x;
    
    @Validate
    private Integer y;
    
    // <editor-fold desc="Getters and Setters" defaultstate="collapsed" >
    @Override
    public void setContext(ActionBeanContext abc) {
        this.context = abc;
    }

    @Override
    public ActionBeanContext getContext() {
        return this.context;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getX() {
        return x;
    }

    public void setX(Integer x) {
        this.x = x;
    }

    public Integer getY() {
        return y;
    }

    public void setY(Integer y) {
        this.y = y;
    }
    // </editor-fold>
    
    
    @DefaultHandler
    public Resolution view(){
        return new ForwardResolution(JSP);
    }
    
    private void save(){
        
    }
}

@@ -136,16 +136,228 @@
 ripes;%0A%0A
+import java.sql.Connection;%0Aimport java.sql.DriverManager;%0Aimport java.sql.SQLException;%0Aimport java.util.Properties;%0Aimport java.util.logging.Level;%0Aimport java.util.logging.Logger;%0Aimport javax.sql.DataSource;%0A
 import n
@@ -770,16 +770,106 @@
 alidate;
+%0Aimport org.apache.commons.dbutils.DbUtils;%0Aimport org.apache.commons.dbutils.QueryRunner;
 %0A%0A/**%0A *
@@ -922,17 +922,16 @@
 om%3E%0A */%0A
-%0A
 @UrlBind
@@ -941,18 +941,19 @@
 (%22/add/%7B
-id
+key
 %7D/%7Bx%7D,%7By
@@ -1019,18 +1019,20 @@
 tionBean
+ 
 %7B%0A
+%0A
     priv
@@ -1098,17 +1098,16 @@
 ing JSP 
- 
 = %22/WEB-
@@ -1125,21 +1125,16 @@
 w.jsp%22;%0A
-    %0A
     @Val
@@ -1155,24 +1155,19 @@
 ate 
-Integer id;%0A    
+String key;
 %0A   
@@ -1200,21 +1200,16 @@
 eger x;%0A
-    %0A
     @Val
@@ -1237,20 +1237,16 @@
 eger y;%0A
-    
 %0A    // 
@@ -1522,21 +1522,21 @@
 lic 
-Integer
+String
  get
-Id
+Key
 () %7B
@@ -1551,18 +1551,19 @@
  return 
-id
+key
 ;%0A    %7D%0A
@@ -1586,21 +1586,22 @@
  set
-Id(Integer id
+Key(String key
 ) %7B%0A
@@ -1617,15 +1617,17 @@
 his.
-id = id
+key = key
 ;%0A  
@@ -1880,25 +1880,16 @@
 r-fold%3E%0A
-    %0A    
 %0A    @De
@@ -1929,17 +1929,34 @@
 n view()
-%7B
+ %7B%0A        save();
 %0A       
@@ -2001,46 +2001,849 @@
   %7D%0A
+%0A
     
-%0A    private void save()%7B%0A        
+private void save() %7B%0A        Connection conn= null;%0A        try %7B%0A            conn = getConnection();%0A%0A    // No DataSource so we must handle Connections manually%0A            QueryRunner run = new QueryRunner();%0A            run.update(conn,%22INSERT INTO location (key,x,y) VALUES (?,?,?)%22,key,x,y);%0A            int a = 0;%0A        %7D catch (SQLException ex) %7B%0A            Logger.getLogger(AddActionBean.class.getName()).log(Level.SEVERE, null, ex);%0A        %7Dfinally%7B%0A            DbUtils.closeQuietly(conn);%0A            %0A        %7D%0A    %7D%0A%0A    private Connection getConnection() throws SQLException %7B%0A        Properties props = new Properties();%0A        props.put(%22user%22, %22locationservice%22);%0A        props.put(%22password%22, %22locationservice  %22);%0A        return DriverManager.getConnection(%22jdbc:postgresql://localhost/locationservice%22, props);
 %0A   

Save first try