vraptor-scaffold 0.0.1.rc → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +1 -1
- data/.gitignore +1 -0
- data/Gemfile +3 -3
- data/History.txt +10 -0
- data/README.textile +32 -0
- data/Rakefile +6 -7
- data/VERSION.yml +1 -1
- data/bin/vraptor +1 -1
- data/lib/configuration.rb +31 -0
- data/lib/generators/app_generator/app_generator.rb +75 -126
- data/lib/generators/app_generator/freemarker_template_engine.rb +50 -0
- data/lib/generators/app_generator/jsp_template_engine.rb +21 -0
- data/lib/generators/app_generator/templates/build.properties.erb +16 -0
- data/lib/generators/app_generator/templates/build.xml +109 -0
- data/lib/generators/app_generator/templates/decorators.erb +7 -0
- data/lib/generators/app_generator/templates/eclipse/classpath +23 -0
- data/lib/generators/app_generator/templates/eclipse/project.erb +36 -0
- data/lib/generators/app_generator/templates/eclipse/settings/org.eclipse.jdt.core.prefs +8 -0
- data/lib/generators/app_generator/templates/eclipse/settings/org.eclipse.wst.common.component.tt +10 -0
- data/lib/generators/app_generator/templates/eclipse/settings/org.eclipse.wst.common.project.facet.core.xml +10 -0
- data/lib/generators/app_generator/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.container +1 -0
- data/lib/generators/app_generator/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.name +1 -0
- data/lib/generators/app_generator/templates/freemarker/freemarker-ivy.xml +2 -0
- data/lib/generators/app_generator/templates/freemarker/freemarker-pom.xml +6 -0
- data/lib/generators/app_generator/templates/freemarker/freemarker-web.xml +23 -0
- data/lib/generators/app_generator/templates/freemarker/infrastructure/FreemarkerPathResolver.java.tt +21 -0
- data/lib/generators/app_generator/templates/{macros → freemarker/macros}/html.ftl +0 -0
- data/lib/generators/app_generator/templates/freemarker/main.ftl +14 -0
- data/lib/generators/app_generator/templates/ivy-2.2.0-rc1.jar +0 -0
- data/lib/generators/app_generator/templates/ivy.erb +35 -0
- data/lib/generators/app_generator/templates/jsp/main.jsp +16 -0
- data/lib/generators/app_generator/templates/pom.erb +24 -3
- data/lib/generators/app_generator/templates/{messages.properties → resources-test/.empty_directory} +0 -0
- data/lib/generators/app_generator/templates/{persistence.xml → resources/META-INF/persistence.xml} +0 -0
- data/lib/generators/app_generator/templates/{log4j.properties → resources/log4j.properties} +0 -0
- data/lib/generators/app_generator/templates/resources/messages.properties +0 -0
- data/lib/generators/app_generator/templates/src-test/controllers/.empty_directory +0 -0
- data/lib/generators/app_generator/templates/src-test/models/.empty_directory +0 -0
- data/lib/generators/app_generator/templates/src-test/repositories/.empty_directory +0 -0
- data/lib/generators/app_generator/templates/src/controllers/.empty_directory +0 -0
- data/lib/generators/app_generator/templates/src/models/Entity.java.tt +45 -0
- data/lib/generators/app_generator/templates/src/repositories/Repository.java.tt +43 -0
- data/lib/generators/app_generator/templates/vraptor-scaffold.erb +2 -0
- data/lib/generators/app_generator/templates/webapp/WEB-INF/web.xml +38 -0
- data/lib/generators/app_generator/templates/webapp/images/.empty_directory +0 -0
- data/lib/generators/app_generator/templates/{index.jsp → webapp/index.jsp} +0 -0
- data/lib/generators/app_generator/templates/{javascripts → webapp/javascripts}/jquery-1.4.2.min.js +0 -0
- data/lib/generators/app_generator/templates/{stylesheets → webapp/stylesheets}/scaffold.css +0 -0
- data/lib/generators/scaffold_generator/attribute.rb +14 -6
- data/lib/generators/scaffold_generator/base_scaffold.rb +14 -10
- data/lib/generators/scaffold_generator/controller_generator/controller_generator.rb +6 -6
- data/lib/generators/scaffold_generator/controller_generator/templates/controller.erb +7 -7
- data/lib/generators/scaffold_generator/controller_generator/templates/controller_test.erb +1 -1
- data/lib/generators/scaffold_generator/freemarker_generator/freemarker_generator.rb +5 -5
- data/lib/generators/scaffold_generator/freemarker_generator/templates/index.erb +2 -3
- data/lib/generators/scaffold_generator/jsp_generator/jsp_generator.rb +22 -0
- data/lib/generators/scaffold_generator/jsp_generator/templates/edit.erb +3 -0
- data/lib/generators/scaffold_generator/jsp_generator/templates/form.erb +27 -0
- data/lib/generators/scaffold_generator/jsp_generator/templates/index.erb +36 -0
- data/lib/generators/scaffold_generator/jsp_generator/templates/new.erb +3 -0
- data/lib/generators/scaffold_generator/jsp_generator/templates/show.erb +14 -0
- data/lib/generators/scaffold_generator/model_generator/model_generator.rb +5 -5
- data/lib/generators/scaffold_generator/model_generator/templates/model.erb +1 -1
- data/lib/generators/scaffold_generator/model_generator/templates/model_test.erb +1 -1
- data/lib/generators/scaffold_generator/repository_generator/repository_generator.rb +6 -5
- data/lib/generators/scaffold_generator/repository_generator/templates/repository.erb +17 -9
- data/lib/generators/scaffold_generator/repository_generator/templates/repository_impl.erb +16 -0
- data/lib/generators/scaffold_generator/repository_generator/templates/repository_test.erb +2 -2
- data/lib/generators/scaffold_generator/scaffold_generator.rb +31 -38
- data/lib/load_paths.rb +6 -2
- data/lib/vraptor-scaffold.rb +29 -5
- data/spec/lib/configuration_spec.rb +60 -0
- data/spec/lib/generators/app_generator/app_generator_spec.rb +237 -116
- data/spec/lib/generators/app_generator/freemarker_template_engine_spec.rb +92 -0
- data/spec/lib/generators/app_generator/jsp_template_engine_spec.rb +44 -0
- data/{lib → spec/lib}/generators/app_generator/templates/Entity.java +5 -2
- data/{lib → spec/lib}/generators/app_generator/templates/FreemarkerPathResolver.java +1 -1
- data/{lib → spec/lib}/generators/app_generator/templates/Repository.java +6 -6
- data/spec/lib/generators/app_generator/templates/build.properties +16 -0
- data/spec/lib/generators/app_generator/templates/decorators-jsp.xml +7 -0
- data/{lib → spec/lib}/generators/app_generator/templates/decorators.xml +2 -2
- data/spec/lib/generators/app_generator/templates/ivy.xml +35 -0
- data/spec/lib/generators/app_generator/templates/pom.xml +24 -3
- data/spec/lib/generators/scaffold_generator/attribute_spec.rb +47 -27
- data/spec/lib/generators/scaffold_generator/base_scaffold_spec.rb +31 -27
- data/spec/lib/generators/scaffold_generator/controller_generator/controller_generator_spec.rb +11 -9
- data/spec/lib/generators/scaffold_generator/controller_generator/templates/ProductController.java +2 -2
- data/spec/lib/generators/scaffold_generator/freemarker_generator/freemarker_generator_spec.rb +16 -14
- data/spec/lib/generators/scaffold_generator/jsp_generator/jsp_generator_spec.rb +34 -0
- data/spec/lib/generators/scaffold_generator/model_generator/model_generator_spec.rb +11 -9
- data/spec/lib/generators/scaffold_generator/repository_generator/repository_generator_spec.rb +17 -9
- data/spec/lib/generators/scaffold_generator/repository_generator/templates/ProductRepository.java +15 -7
- data/spec/lib/generators/scaffold_generator/repository_generator/templates/ProductRepositoryImpl.java +16 -0
- data/spec/lib/generators/scaffold_generator/scaffold_generator_spec.rb +55 -57
- data/spec/lib/vraptor-scaffold_spec.rb +77 -24
- data/spec/resources/vraptor-scaffold.properties +2 -0
- data/spec/spec_helper.rb +13 -1
- data/vraptor-scaffold.gemspec +82 -34
- metadata +86 -42
- data/README.rdoc +0 -104
- data/TODO.txt +0 -17
- data/lib/generators/app_generator/templates/main.ftl +0 -14
- data/lib/generators/app_generator/templates/web.xml +0 -61
@@ -0,0 +1,43 @@
|
|
1
|
+
package <%= options[:package] %>.repositories;
|
2
|
+
|
3
|
+
import java.io.Serializable;
|
4
|
+
import java.lang.reflect.ParameterizedType;
|
5
|
+
import java.util.List;
|
6
|
+
|
7
|
+
import javax.persistence.EntityManager;
|
8
|
+
|
9
|
+
public abstract class Repository<T, I extends Serializable> {
|
10
|
+
|
11
|
+
protected final EntityManager entityManager;
|
12
|
+
|
13
|
+
public Repository(EntityManager entityManager) {
|
14
|
+
this.entityManager = entityManager;
|
15
|
+
}
|
16
|
+
|
17
|
+
public void create(T entity) {
|
18
|
+
entityManager.persist(entity);
|
19
|
+
}
|
20
|
+
|
21
|
+
public void update(T entity) {
|
22
|
+
entityManager.merge(entity);
|
23
|
+
}
|
24
|
+
|
25
|
+
public void destroy(T entity) {
|
26
|
+
entityManager.remove(entity);
|
27
|
+
}
|
28
|
+
|
29
|
+
public T find(I id) {
|
30
|
+
return entityManager.find(getParameterizedClass(), id);
|
31
|
+
}
|
32
|
+
|
33
|
+
@SuppressWarnings("unchecked")
|
34
|
+
public List<T> findAll() {
|
35
|
+
return entityManager.createQuery("From " + getParameterizedClass().getName()).getResultList();
|
36
|
+
}
|
37
|
+
|
38
|
+
@SuppressWarnings("unchecked")
|
39
|
+
private Class<T> getParameterizedClass() {
|
40
|
+
ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
|
41
|
+
return (Class<T>) parameterizedType.getActualTypeArguments()[0];
|
42
|
+
}
|
43
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
|
3
|
+
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
4
|
+
id="WebApp_ID" version="2.5">
|
5
|
+
|
6
|
+
<display-name>vraptor-scaffold-project</display-name>
|
7
|
+
|
8
|
+
<context-param>
|
9
|
+
<param-name>br.com.caelum.vraptor.packages</param-name>
|
10
|
+
<param-value>br.com.caelum.vraptor.util.jpa</param-value>
|
11
|
+
</context-param>
|
12
|
+
|
13
|
+
<context-param>
|
14
|
+
<param-name>br.com.caelum.vraptor.encoding</param-name>
|
15
|
+
<param-value>UTF-8</param-value>
|
16
|
+
</context-param>
|
17
|
+
|
18
|
+
<filter>
|
19
|
+
<filter-name>sitemesh</filter-name>
|
20
|
+
<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
|
21
|
+
</filter>
|
22
|
+
|
23
|
+
<filter>
|
24
|
+
<filter-name>vraptor</filter-name>
|
25
|
+
<filter-class>br.com.caelum.vraptor.VRaptor</filter-class>
|
26
|
+
</filter>
|
27
|
+
|
28
|
+
<filter-mapping>
|
29
|
+
<filter-name>sitemesh</filter-name>
|
30
|
+
<url-pattern>/*</url-pattern>
|
31
|
+
</filter-mapping>
|
32
|
+
|
33
|
+
<filter-mapping>
|
34
|
+
<filter-name>vraptor</filter-name>
|
35
|
+
<url-pattern>/*</url-pattern>
|
36
|
+
</filter-mapping>
|
37
|
+
|
38
|
+
</web-app>
|
File without changes
|
File without changes
|
data/lib/generators/app_generator/templates/{javascripts → webapp/javascripts}/jquery-1.4.2.min.js
RENAMED
File without changes
|
File without changes
|
@@ -1,30 +1,38 @@
|
|
1
1
|
class Attribute
|
2
2
|
attr_accessor :name, :type
|
3
|
-
|
3
|
+
|
4
4
|
def initialize(name, type)
|
5
5
|
@name = name
|
6
|
-
@type = type
|
6
|
+
@type = type.downcase
|
7
|
+
validate
|
7
8
|
end
|
8
|
-
|
9
|
+
|
9
10
|
def html_input
|
10
11
|
input = "text"
|
11
12
|
input = "checkbox" if boolean?
|
12
13
|
input = "textarea" if type.eql?("text")
|
13
14
|
input
|
14
15
|
end
|
15
|
-
|
16
|
+
|
16
17
|
def java_type
|
17
18
|
java = type.capitalize
|
18
19
|
java = "boolean" if boolean?
|
19
20
|
java = "String" if type.eql?("text")
|
20
21
|
java
|
21
22
|
end
|
22
|
-
|
23
|
+
|
23
24
|
def self.valid_types
|
24
25
|
%w(boolean double float short integer long string text)
|
25
26
|
end
|
26
|
-
|
27
|
+
|
27
28
|
def boolean?
|
28
29
|
type.eql? "boolean"
|
29
30
|
end
|
31
|
+
|
32
|
+
def validate
|
33
|
+
unless Attribute.valid_types.include?(@type)
|
34
|
+
puts "Attribute #{@type} is not supported. The supported attributes types are: #{Attribute.valid_types.join(", ")}"
|
35
|
+
Kernel::exit
|
36
|
+
end
|
37
|
+
end
|
30
38
|
end
|
@@ -1,31 +1,35 @@
|
|
1
1
|
class BaseScaffold < VraptorScaffold::Base
|
2
|
-
|
2
|
+
|
3
3
|
def initialize(model, attributes={})
|
4
4
|
super
|
5
5
|
@model = model
|
6
6
|
@attributes = attributes
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def class_name
|
10
10
|
@model.capitalize
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def test_class_name
|
14
14
|
"#{class_name}Test"
|
15
15
|
end
|
16
|
-
|
17
|
-
def
|
18
|
-
|
16
|
+
|
17
|
+
def repository_interface_name
|
18
|
+
"#{class_name}Repository"
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
|
+
def repository_impl_name
|
22
|
+
"#{repository_interface_name}Impl"
|
23
|
+
end
|
24
|
+
|
21
25
|
def repository_test_class_name
|
22
|
-
|
26
|
+
"#{repository_impl_name}Test"
|
23
27
|
end
|
24
|
-
|
28
|
+
|
25
29
|
def controller_class_name
|
26
30
|
"#{class_name}Controller"
|
27
31
|
end
|
28
|
-
|
32
|
+
|
29
33
|
def controller_test_class_name
|
30
34
|
"#{controller_class_name}Test"
|
31
35
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
class ControllerGenerator < BaseScaffold
|
2
|
-
|
2
|
+
|
3
3
|
def self.source_root
|
4
|
-
File.dirname(__FILE__)
|
4
|
+
File.join File.dirname(__FILE__), "templates"
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
def build
|
8
|
-
template("
|
9
|
-
template("
|
8
|
+
template("controller.erb", Configuration.main_class_path("controllers", "#{controller_class_name}.java"))
|
9
|
+
template("controller_test.erb", Configuration.test_class_path("controllers", "#{controller_test_class_name}.java"))
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def path
|
13
13
|
"/#{@model.pluralize}"
|
14
14
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
package
|
1
|
+
package <%= Configuration.package %>.controllers;
|
2
2
|
|
3
3
|
import java.util.List;
|
4
4
|
|
5
|
-
import
|
6
|
-
import
|
5
|
+
import <%= Configuration.package %>.models.<%= class_name %>;
|
6
|
+
import <%= Configuration.package %>.repositories.<%= repository_interface_name %>;
|
7
7
|
import br.com.caelum.vraptor.Delete;
|
8
8
|
import br.com.caelum.vraptor.Get;
|
9
9
|
import br.com.caelum.vraptor.Path;
|
@@ -17,10 +17,10 @@ import br.com.caelum.vraptor.Validator;
|
|
17
17
|
public class <%= controller_class_name %> {
|
18
18
|
|
19
19
|
private final Result result;
|
20
|
-
private final <%=
|
20
|
+
private final <%= repository_interface_name %> repository;
|
21
21
|
private final Validator validator;
|
22
22
|
|
23
|
-
public <%= controller_class_name %>(Result result, <%=
|
23
|
+
public <%= controller_class_name %>(Result result, <%= repository_interface_name %> repository, Validator validator) {
|
24
24
|
this.result = result;
|
25
25
|
this.repository = repository;
|
26
26
|
this.validator = validator;
|
@@ -63,13 +63,13 @@ public class <%= controller_class_name %> {
|
|
63
63
|
}
|
64
64
|
|
65
65
|
@Get
|
66
|
-
@Path("<%= "#{path}/{#{@model}.id}
|
66
|
+
@Path("<%= "#{path}/{#{@model}.id}" %>")
|
67
67
|
public <%= class_name %> show(<%= class_name %> <%= @model %>) {
|
68
68
|
return repository.find(<%= @model %>.getId());
|
69
69
|
}
|
70
70
|
|
71
71
|
@Delete
|
72
|
-
@Path("<%= path %>")
|
72
|
+
@Path("<%= "#{path}/{#{@model}.id}" %>")
|
73
73
|
public void destroy(<%= class_name %> <%= @model %>) {
|
74
74
|
repository.destroy(repository.find(<%= @model %>.getId()));
|
75
75
|
result.redirectTo(this).index();
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class FreemarkerGenerator < BaseScaffold
|
2
|
-
|
2
|
+
|
3
3
|
def self.source_root
|
4
4
|
File.dirname(__FILE__)
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
def build
|
8
8
|
create_view("index")
|
9
9
|
create_view("show")
|
@@ -11,11 +11,11 @@ class FreemarkerGenerator < BaseScaffold
|
|
11
11
|
create_view("edit")
|
12
12
|
create_view("new", "new#{class_name}")
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def create_view(template_name, file_name=template_name)
|
16
|
-
|
16
|
+
template("templates/#{template_name}.erb", "#{Configuration::WEB_INF}/views/#{@model}/#{file_name}.ftl")
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def path
|
20
20
|
"${base}/#{@model.pluralize}"
|
21
21
|
end
|
@@ -19,11 +19,10 @@
|
|
19
19
|
<%= "${#{@model}.#{att.name}?string}" if att.boolean? %>
|
20
20
|
</td>
|
21
21
|
<% end -%>
|
22
|
-
<td><a href="<%= "#{path}/${#{@model}.id}
|
22
|
+
<td><a href="<%= "#{path}/${#{@model}.id}" %>">show</a></td>
|
23
23
|
<td><a href="<%= "#{path}/${#{@model}.id}/edit" %>">edit</a></td>
|
24
24
|
<td>
|
25
|
-
<form action="<%= path %>" method="post">
|
26
|
-
<input name="<%= "#{@model}.id" %>" value="<%= "${#{@model}.id}" %>" type="hidden" />
|
25
|
+
<form action="<%= "#{path}/${#{@model}.id}" %>" method="post">
|
27
26
|
<input type="hidden" name="_method" value="delete"/>
|
28
27
|
<button type="submit" onclick="return confirm('Are you sure?')">destroy</button>
|
29
28
|
</form>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class JspGenerator < BaseScaffold
|
2
|
+
|
3
|
+
def self.source_root
|
4
|
+
File.dirname(__FILE__)
|
5
|
+
end
|
6
|
+
|
7
|
+
def build
|
8
|
+
create_view("index")
|
9
|
+
create_view("show")
|
10
|
+
create_view("form")
|
11
|
+
create_view("edit")
|
12
|
+
create_view("new", "new#{class_name}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_view(template_name, file_name=template_name)
|
16
|
+
template("templates/#{template_name}.erb", "#{Configuration::WEB_INF}/jsp/#{@model}/#{file_name}.jsp")
|
17
|
+
end
|
18
|
+
|
19
|
+
def path url=""
|
20
|
+
%Q{<c:url value="/#{@model.pluralize}#{url}"/>}
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<<%='%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%'%>>
|
2
|
+
<c:if test="${not empty errors}">
|
3
|
+
<c:forEach items="${errors}" var="error">
|
4
|
+
${error.category} - ${error.message}<br />
|
5
|
+
</c:forEach>
|
6
|
+
</c:if>
|
7
|
+
|
8
|
+
<form action="<%= path %>" method="post">
|
9
|
+
|
10
|
+
<c:if test="${not empty <%= @model %>.id}">
|
11
|
+
<input type="hidden" name="<%= @model %>.id" value="${<%=@model%>.id}"/>
|
12
|
+
<input type="hidden" name="_method" value="put"/>
|
13
|
+
</c:if>
|
14
|
+
|
15
|
+
<% @attributes.each do |att| -%>
|
16
|
+
<div class="field">
|
17
|
+
<%= att.name.capitalize %>:<br />
|
18
|
+
<input type="text" name="<%= @model %>.<%=att.name%>" value="${<%=@model%>.<%=att.name%>}"/>
|
19
|
+
</div>
|
20
|
+
<% end -%>
|
21
|
+
<div class="actions">
|
22
|
+
<button type="submit">send</button>
|
23
|
+
</div>
|
24
|
+
</form>
|
25
|
+
|
26
|
+
<a href="<%= path %>">Back</a>
|
27
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<<%='%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%'%>>
|
2
|
+
<body>
|
3
|
+
<h1>Listing <%= class_name.pluralize %></h1>
|
4
|
+
|
5
|
+
<table>
|
6
|
+
<tr>
|
7
|
+
<% @attributes.each do |att| -%>
|
8
|
+
<th><%= att.name %></th>
|
9
|
+
<% end -%>
|
10
|
+
<th></th>
|
11
|
+
<th></th>
|
12
|
+
<th></th>
|
13
|
+
</tr>
|
14
|
+
|
15
|
+
<c:forEach items="${<%=@model%>List}" var="<%=@model%>">
|
16
|
+
<tr>
|
17
|
+
<% @attributes.each do |att| -%>
|
18
|
+
<td>
|
19
|
+
<%= "${#{@model}.#{att.name}}" %>
|
20
|
+
</td>
|
21
|
+
<% end -%>
|
22
|
+
<td><a href="<%= path "/${#{@model}.id}" %>">show</a></td>
|
23
|
+
<td><a href="<%= path "/${#{@model}.id}/edit" %>">edit</a></td>
|
24
|
+
<td>
|
25
|
+
<form action="<%= path "/${#{@model}.id}" %>" method="post">
|
26
|
+
<input type="hidden" name="_method" value="delete"/>
|
27
|
+
<button type="submit" onclick="return confirm('Are you sure?')">destroy</button>
|
28
|
+
</form>
|
29
|
+
</td>
|
30
|
+
</tr>
|
31
|
+
</c:forEach>
|
32
|
+
</table>
|
33
|
+
|
34
|
+
<br />
|
35
|
+
<a href="<%= path '/new' %>">New <%= class_name %></a>
|
36
|
+
</body>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<<%='%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%'%>>
|
2
|
+
<body>
|
3
|
+
|
4
|
+
<% @attributes.each do |att| -%>
|
5
|
+
<p>
|
6
|
+
<b><%= att.name.capitalize %>:</b>
|
7
|
+
<%= "${#{@model}.#{att.name}}" %>
|
8
|
+
</p>
|
9
|
+
<% end -%>
|
10
|
+
|
11
|
+
<a href="<%= path "/${#{@model}.id}/edit" %>">Edit</a>
|
12
|
+
<a href="<%= path %>">Back</a>
|
13
|
+
|
14
|
+
</body>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class ModelGenerator < BaseScaffold
|
2
|
-
|
2
|
+
|
3
3
|
def self.source_root
|
4
|
-
File.dirname(__FILE__)
|
4
|
+
File.join File.dirname(__FILE__), "templates"
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
def build
|
8
|
-
template("
|
9
|
-
template("
|
8
|
+
template("model.erb", Configuration.main_class_path("models", "#{class_name}.java"))
|
9
|
+
template("model_test.erb", Configuration.test_class_path("models", "#{test_class_name}.java"))
|
10
10
|
end
|
11
11
|
end
|