Changeset 29734

Show
Ignore:
Timestamp:
02/09/09 02:15:19 (4 years ago)
Author:
rikeda
Message:

編集ページと確認ページの追加。

Location:
lang/ruby/scaflute
Files:
6 added
3 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/scaflute/scaflute.rb

    r29702 r29734  
    1010    tables.each() do |table| 
    1111      $table = table 
    12       ERB.exec_file('templates/list.erb', "result/#{table.javaProperty}List.html") 
    13       ERB.exec_file('templates/list_page.erb', "result/#{table.javaClass}ListPage.java") 
     12      ERB.exec_file('templates/list.erb', "result/html/#{table.javaProperty}List.html") 
     13      ERB.exec_file('templates/list_page.erb', "result/java/#{table.javaClass}ListPage.java") 
     14      ERB.exec_file('templates/edit.erb', "result/html/#{table.javaProperty}Edit.html") 
     15      ERB.exec_file('templates/edit_page.erb', "result/java/#{table.javaClass}EditPage.java") 
     16      ERB.exec_file('templates/confirm.erb', "result/html/#{table.javaProperty}Confirm.html") 
     17      ERB.exec_file('templates/confirm_page.erb', "result/java/#{table.javaClass}ConfirmPage.java") 
    1418    end 
    1519  end 
  • lang/ruby/scaflute/templates/list.erb

    r29702 r29734  
    66</head> 
    77<body> 
     8  <span id="messages"></span> 
     9 
    810  <form id="<%= table.javaProperty %>SearchForm"> 
    911    <table> 
     
    1416          <td><label id="<%= id %>Label-search" for="<%= id %>Search"><%= id %></label></td> 
    1517          <td><input type="text" id="<%= id %>Search" maxlength="<%= column.htmlMaxLength %>"/></td> 
     18          <td><span id="<%= id %>SearchMessage"></span></td> 
    1619        </tr> 
    1720<%- end -%> 
     
    1922    </table> 
    2023    <input type="button" id="doSearch" value="Search"/> 
     24  </form> 
     25 
     26  <form id="<%= table.javaProperty %>CreateForm"> 
     27    <input type="button" id="go<%= table.javaClass %>Edit" value="Create"/> 
    2128  </form> 
    2229 
     
    3744          <td><span id="<%= id %>" te:omittag="true"><%= id %></span></td> 
    3845<%- end -%> 
     46          <td> 
     47            <input type="button" id="doView" value="View"/> 
     48            <input type="button" id="doEdit" value="Edit"/> 
     49            <input type="button" id="doDelete" value="Delete"/> 
     50          </td> 
    3951        </tr> 
    4052      </tbody> 
  • lang/ruby/scaflute/templates/list_page.erb

    r29702 r29734  
    55 
    66<%- table.columns.each() do |column| -%> 
     7    public <%= column.javaType %> <%= column.javaProperty %>Search; 
     8<%- end -%> 
     9 
     10<%- table.columns.each() do |column| -%> 
    711    public <%= column.javaType %> <%= column.javaProperty %>; 
    8     public <%= column.javaType %> <%= column.javaProperty %>Search; 
    912<%- end -%> 
    1013 
     
    4649    } 
    4750 
     51    public Class<?> doView() { 
     52        if (!isValidIndex()) { 
     53            return null; 
     54        } 
     55        initPrimaryKey(); 
     56        return <%= table.javaClass %>ConfirmPage.class; 
     57    } 
     58 
     59    public Class<?> doEdit() { 
     60        if (!isValidIndex()) { 
     61            return null; 
     62        } 
     63        initPrimaryKey(); 
     64        return <%= table.javaClass %>EditPage.class; 
     65    } 
     66 
     67    public Class<?> doDelete() { 
     68        if (!isValidIndex()) { 
     69            return null; 
     70        } 
     71        initPrimaryKey(); 
     72        return <%= table.javaClass %>ConfirmPage.class; 
     73    } 
     74 
     75    private void initPrimaryKey() { 
     76<%- table.columns.each() do |column| -%> 
     77<%- if column.primaryKey -%> 
     78        <%= column.javaProperty %> = <%= table.javaProperty %>Items.get(<%= table.javaProperty %>Index).get<%= column.javaProperty.upcase_first() %>(); 
     79<%- end -%> 
     80<%- end -%> 
     81    } 
     82 
    4883    public void doPrev() { 
    4984        if (pageNumber <= 1) { 
     
    6095    } 
    6196 
     97    private boolean isValidIndex() { 
     98        if (<%= table.javaProperty %>Items == null || <%= table.javaProperty %>Items.isEmpty()) { 
     99            return false; 
     100        } 
     101        return (0 <= <%= table.javaProperty %>Index && <%= table.javaProperty %>Index < <%= table.javaProperty %>Items.size()); 
     102    } 
     103 
    62104}