Dynamic output, and two columns with a menu of

2009-07-08  来源:本站原创  分类:Web  人气:253 

Achieved under the first thought that: first, using a sorted linked list to store the menu in a column and its two sections, and then output in the foreground make the most use the entire list outside the loop, to do with the list of key values of the internal loop to the output of the 1 menu 2 menu. Much that Kanxia bar code implementation

FunctionAction.java is to obtain data in action

 * copyright (c) by eyinbao 2009
package com.ybms.ui.action.manage.function;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.ybms.domain.adminuser.AdminUser;
import com.ybms.domain.adminuser.Role;
import com.ybms.domain.adminuser.RolePermission;
import com.ybms.domain.adminuser.RolePermissionRepository;
import com.ybms.domain.function.FunctionModule;
import com.ybms.domain.function.FunctionModuleCategory;
import com.ybms.domain.function.FunctionModuleCategoryRepository;
import com.ybms.domain.function.FunctionModuleRepository;
import com.ybms.ui.action.ActionBase;
import com.ybms.utils.CurrentUserUtils;

 *  Add background left menu
 * @author:cxc
 * @E-mail: [email protected]
 * @since:2010-2-25  Afternoon  03:56:26
public class FunctionAction extends ActionBase {
        private FunctionModuleRepository functionModuleRepository = FunctionModuleRepository

        private FunctionModuleCategoryRepository categoryRepository = FunctionModuleCategoryRepository

        //Map The key holds the name of the parent menu  ,value Holds the collection below second-level menu
        public Map<String, List<FunctionModule>> menuMap = new LinkedHashMap<String, List<FunctionModule>>();
        //  The current logged-on user is a member of role has permissions list
        private List<RolePermission> perList;
        private HttpServletRequest request;

        private RolePermissionRepository permissionRepository = RolePermissionRepository

        public String execute() throws Exception {
                AdminUser user = CurrentUserUtils.getCurrentUser(ServletActionContext.getRequest().getSession());
                Role role = new Role();
                role = user.getRole();
                perList = this.permissionRepository.getRolePermissions(role);
                        ServletActionContext.getRequest().getSession().setAttribute("permissions", perList);
                //  Gets a large menu list
                List<FunctionModuleCategory> categoryList = this.categoryRepository
                List<FunctionModule> funModuleList = null;
                if (categoryList != null) {
                        Iterator<FunctionModuleCategory> iterator = categoryList.iterator();
                        while (iterator.hasNext()) {
                                FunctionModuleCategory category = iterator.next();

                                // According to the first-level menu gets it beneath second-level menu
                                funModuleList = this.functionModuleRepository
                                if (funModuleList != null) {
                                        menuMap.put(category.getName(), funModuleList);
                return SUCCESS;

        public Map<String, List<FunctionModule>> getMenuMap() {
                return menuMap;

        public void setMenuMap(Map<String, List<FunctionModule>> menuMap) {
                this.menuMap = menuMap;

        public List<RolePermission> getPerList() {
                return perList;

        public void setPerList(List<RolePermission> perList) {
                this.perList = perList;

        public HttpServletRequest getRequest() {
                return request;

        public void setRequest(HttpServletRequest request) {
                this.request = request;


The output of the corresponding front page

                        <s:iterator value="menuMap" status="index">
                                                <img src="${ctx}/images/icon_01.gif" alt=""

                                                <!-- The name of the parent menu  -->
                                                <s:property value="key" />
                                                        <s:iterator value="value">
                                                                                <a href="<s:property value='url' />" target="mainFrame"><s:property
                                                                                                value="#secMenu.name" /> </a>
  • Dynamic output, and two columns with a menu of 2009-07-08

    Achieved under the first thought that: first, using a sorted linked list to store the menu in a column and its two sections, and then output in the foreground make the most use the entire list outside the loop, to do with the list of key values of th

  • Dynamic add rows and columns form filling value Hibernate Spring dwr 2010-07-25

    Dynamic add rows and columns of the table, and add value to a small example of using a Hibernate Spring dwr. dwr configuration file <allow> <create creator="spring" javascript="userlogin" > <param name="beanName&quo

  • Dynamic output with the first and second sections of the menu 2010-03-13

    First to achieve that idea: the first with an ordered list to store the menu of a part and its second part, then the output at the front desk to do with the list the most external loop, with a list of key values within the loop do to the output of th

  • JSP dynamic output Excel and Chinese garbled solution-JSP tutorial, Jsp / Servlet 2010-03-29

    Recently seen on the Internet to manipulate an excel using java's open source, tried clicking on the weblogic, I feel very good, hereby recommend to you about. First, go to http://www.andykhan.com/jexcelapi/index.html download the latest jexcelapi, p

  • Log4j dynamic output log 2010-08-27

    Projects have such a demand, request should specify the package of all packages under a separate category for the log. To the lower-level packets on package1 log isolation, then there package1.subpackage1, package1.subpackage2 ........ other packages

  • android dynamic menu 2010-07-21

    From: http://www.mobilesdn.com/?action-viewnews-itemid-107 / / Create three menu @ Override public boolean onCreateOptionsMenu (Menu menu) ( super.onCreateOptionsMenu (menu); / / Game into the menu interface needs to display the menu items menu.add (

  • how to manage menu in drupal 2010-04-22

    1.callback mapping 2.visit permission 3.menu include / menu.inc menu.module http://www.example.com/?q=cats http://www.example.com/?q=node/3 they are same how to create mymenu mymenu.info ; $ Id $ name = "Mymenu Module" descrption = "Adds a

  • Write a dynamic load from the back-end database tools Ext.tree the json data 2010-11-04

    Total of two class (TreeLoader.java, TreeNode.java) an interface (TreeNodeConfig.java), when used: for example, to call TreeLoader.loadTree (..), TreeLoader Action callback interface TreeNodeConfig further implementation of the specific look at the c

  • How to use nice menu in drupal 2011-03-31

    way 1: function theme_nice_menu_build($menu) { $output = ''; // $backgroundColor = '#000000'; $backgroundColor = 'transparent'; foreach ($menu as $menu_item) { $mlid = $menu_item['link']['mlid']; // Check to see if it is a visible menu item. if ($men

  • Bash string manipulation (control and Java) - 4 string output 2011-09-08

    Bash string manipulation (control and Java) - 4 string output In Java Output to the standard output device (console, screen) System.out.println (s); Output to the standard error device (the console screen) System.err.println (s); Output to a file Pri

  • How you learn faster extjs, (including 1.0,2.0,3.0.3 version) 2010-07-12

    Chapter 1 flashing it! Look at those beautiful example extjs 1.1. All release packages start from extjs very fortunate that we can download free of charge to extjs.com ext release package, inside the source code, api documentation, examples ranging.

  • Ext production of various forms 2010-08-17

    Whether interface beauty or function strength of, ext forms controls topped. Radio row, checkbox line highlight selected rows, pushing drag change column width, by column sort, these basic functions we not mention. Automatically generated line number

  • javascript methods and techniques Daquan 1 (turn) 2008-11-10

    javascript methods and techniques Daquan (change) JavaScript that's all one: the basics Create a script block 1: <script language="JavaScript"> 2: JavaScript code goes here 3: </ script> Hide the script code 2 1: <script language=

  • Regular expression from the foundation to learn the 2010-03-21

    [Edit this paragraph] 1, what is the regular expression a regular expression is a pattern to match with a string of a formula for a class. Many more people because they look so strange and complex not to use - unfortunately, this article will not be

  • Oracle notes for beginners 2010-06-06

    / / Reserved Oracle notes for beginners Oracle beginners Notes (1) Key words: - → 〓 ☆ ★ ☆ 〓 ← - SQL plus landing: 1, the program group: user name: scott or system Password: tiger Host string: only when the remote landing; 2, run: sqlplusw Scott / Tig

  • The TSO commands used 2010-06-12

    TSO TSO command from the TSO user environment issue (as in the main menu, select P.6 can enter TSO command processing tools). Used to start, stop software, check, set the operation of the system software and hardware equipment, operating system opera

  • <Wutou JavaScript> the nectar Model 2 2010-08-04

    You can, because the-M parameter that, when making packages do not add the JAR MANIFEST list, then the only goal of JAR files in the specified areas will be. Jar extension to. Zip extension is to create a letter of ZIP files, such as the previous sec

  • php background write / download xls report 2010-09-04

    Support for excel csv and xls format report, has been generated that xls more difficult, because only a multi-line to csv "," separated text file, to be read after the excel spreadsheet can be displayed on the inside, but the results do not supp

  • Complete 2 javascript functions used 2010-10-09

    JavaScript That's all 1: Basics Create a script block <script language="JavaScript"> JavaScript code goes here </script> Hide the script code <script language="JavaScript"> <! - document.write("Hello"); /

  • debugging js Performance Optimization 2011-05-16

    Client data and dynamic output table showing the form is more common in web applications work. For the cycle printout tr, td itself is a very rigid and violent programming approach, coupled with the binding element innerHTML last character stream out