Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Controller Code
- /**
- *
- */
- package com.brokensoftware.stormfall.web;
- import java.util.Collection;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.WebDataBinder;
- import org.springframework.web.bind.annotation.InitBinder;
- import org.springframework.web.bind.annotation.ModelAttribute;
- import org.springframework.web.bind.annotation.SessionAttributes;
- import com.brokensoftware.stormfall.model.Menu;
- import com.brokensoftware.stormfall.service.StormfallService;
- /**
- * @author gccrowd
- * @version 1.0
- *
- */
- @Controller
- @SessionAttributes(types=Menu.class)
- public class MenuController {
- private final StormfallService stormfallService;
- static Log log = LogFactory.getLog(MenuController.class.getName());
- @Autowired
- public MenuController(StormfallService stormfallService) {
- this.stormfallService = stormfallService;
- }
- @InitBinder
- public void setAllowedFields(WebDataBinder dataBinder) {
- dataBinder.setDisallowedFields("id");
- }
- @ModelAttribute("adminMenu")
- public Collection<Menu> getAdminMenu() {
- return this.stormfallService.findMenuByType("A", "A");
- //return null;
- }
- @ModelAttribute("userMenu")
- public Collection<Menu> getUserMenu() {
- return this.stormfallService.findMenuByType("U","A");
- }
- }
- View Html:
- <!DOCTYPE html>
- <html lang="en">
- <head th:replace="layout :: headTag">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>Stormfall :: Stormfall Statistics System</title>
- <link href="../../../resources/css/common-layout.css"
- th:href="@{/resources/css/common-layout.css}" rel="stylesheet" />
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"
- th:src="@{/webjars/jquery/1.9.0/jquery.js}"></script>
- <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"
- th:src="@{/webjars/jquery-ui/1.9.2/js/jquery-ui-1.9.2.custom.js}"></script>
- <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/smoothness/jquery-ui.css"
- th:href="@{/webjars/jquery-ui/1.9.2/css/smoothness/jquery-ui-1.9.2.custom.css}" rel="stylesheet" />
- </head>
- <body>
- <div class="container">
- <h2 th:text="#{welcome}">Welcome!</h2>
- <img src="../../resources/images/brokensoftware-thumb-image.jpg" th:src="@{/resources/images/brokensoftware-thumb-image.jpg}" />
- <br>List the admin menu items</br>
- <table class="table table-striped" style="width:600px;">
- <thead>
- <tr>
- <th style="width: 150px;">Text</th>
- <th style="width: 200px;">Url</th>
- <th style="width: 30px;">Type</th>
- <th style="width: 30px;">Sort Order</th>
- <th style="width: 30px;">Status</th>
- </tr>
- </thead>
- <tbody>
- <tr th:each="menu,rowStat : ${adminMenu}">
- <td th:text="${adminMenu.name}">Menu 1</td>
- <td th:text="${adminMenu.url}">Url 1</td>
- <td th:text="${adminMenu.type}">Type 1</td>
- <td th:text="${adminMenu.sortOrder">Sort Order 1</td>
- <td th:text="${adminMenu.status}">A</td>
- <td th:text="${rowStat.count}">1</td>
- <td th:text="${rowStat.index}">0</td>
- <td th:text="${rowStat.size}">1</td>
- <td th:text="${rowStat.even}">false</td>
- <td th:text="${rowStat.odd}">true</td>
- </tr>
- </tbody>
- </table>
- <table th:replace="layout :: footer" class="footer">
- <tr>
- <td></td>
- <td align="center">© Broken Software, LLC 2013</td>
- </tr>
- </table>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement