Advertisement
Guest User

Untitled

a guest
Dec 16th, 2013
1,652
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. Controller Code
  2.  
  3. /**
  4. *
  5. */
  6. package com.brokensoftware.stormfall.web;
  7.  
  8. import java.util.Collection;
  9.  
  10. import org.apache.commons.logging.Log;
  11. import org.apache.commons.logging.LogFactory;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Controller;
  14. import org.springframework.web.bind.WebDataBinder;
  15. import org.springframework.web.bind.annotation.InitBinder;
  16. import org.springframework.web.bind.annotation.ModelAttribute;
  17. import org.springframework.web.bind.annotation.SessionAttributes;
  18.  
  19. import com.brokensoftware.stormfall.model.Menu;
  20. import com.brokensoftware.stormfall.service.StormfallService;
  21.  
  22. /**
  23. * @author gccrowd
  24. * @version 1.0
  25. *
  26. */
  27. @Controller
  28. @SessionAttributes(types=Menu.class)
  29. public class MenuController {
  30.  
  31. private final StormfallService stormfallService;
  32.  
  33. static Log log = LogFactory.getLog(MenuController.class.getName());
  34.  
  35. @Autowired
  36. public MenuController(StormfallService stormfallService) {
  37. this.stormfallService = stormfallService;
  38. }
  39.  
  40. @InitBinder
  41. public void setAllowedFields(WebDataBinder dataBinder) {
  42. dataBinder.setDisallowedFields("id");
  43. }
  44.  
  45. @ModelAttribute("adminMenu")
  46. public Collection<Menu> getAdminMenu() {
  47. return this.stormfallService.findMenuByType("A", "A");
  48. //return null;
  49. }
  50.  
  51. @ModelAttribute("userMenu")
  52. public Collection<Menu> getUserMenu() {
  53. return this.stormfallService.findMenuByType("U","A");
  54. }
  55.  
  56. }
  57.  
  58.  
  59. View Html:
  60.  
  61. <!DOCTYPE html>
  62.  
  63. <html lang="en">
  64. <head th:replace="layout :: headTag">
  65. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  66. <title>Stormfall :: Stormfall Statistics System</title>
  67.  
  68. <link href="../../../resources/css/common-layout.css"
  69. th:href="@{/resources/css/common-layout.css}" rel="stylesheet" />
  70.  
  71. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"
  72. th:src="@{/webjars/jquery/1.9.0/jquery.js}"></script>
  73. <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"
  74. th:src="@{/webjars/jquery-ui/1.9.2/js/jquery-ui-1.9.2.custom.js}"></script>
  75.  
  76. <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/smoothness/jquery-ui.css"
  77. th:href="@{/webjars/jquery-ui/1.9.2/css/smoothness/jquery-ui-1.9.2.custom.css}" rel="stylesheet" />
  78. </head>
  79. <body>
  80. <div class="container">
  81.  
  82. <h2 th:text="#{welcome}">Welcome!</h2>
  83.  
  84. <img src="../../resources/images/brokensoftware-thumb-image.jpg" th:src="@{/resources/images/brokensoftware-thumb-image.jpg}" />
  85.  
  86. <br>List the admin menu items</br>
  87.  
  88. <table class="table table-striped" style="width:600px;">
  89. <thead>
  90. <tr>
  91. <th style="width: 150px;">Text</th>
  92. <th style="width: 200px;">Url</th>
  93. <th style="width: 30px;">Type</th>
  94. <th style="width: 30px;">Sort Order</th>
  95. <th style="width: 30px;">Status</th>
  96. </tr>
  97. </thead>
  98. <tbody>
  99. <tr th:each="menu,rowStat : ${adminMenu}">
  100. <td th:text="${adminMenu.name}">Menu 1</td>
  101. <td th:text="${adminMenu.url}">Url 1</td>
  102. <td th:text="${adminMenu.type}">Type 1</td>
  103. <td th:text="${adminMenu.sortOrder">Sort Order 1</td>
  104. <td th:text="${adminMenu.status}">A</td>
  105. <td th:text="${rowStat.count}">1</td>
  106. <td th:text="${rowStat.index}">0</td>
  107. <td th:text="${rowStat.size}">1</td>
  108. <td th:text="${rowStat.even}">false</td>
  109. <td th:text="${rowStat.odd}">true</td>
  110. </tr>
  111. </tbody>
  112. </table>
  113.  
  114.  
  115. <table th:replace="layout :: footer" class="footer">
  116. <tr>
  117. <td></td>
  118. <td align="center">&copy; Broken Software, LLC 2013</td>
  119. </tr>
  120. </table>
  121.  
  122. </div>
  123. </body>
  124.  
  125. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement