⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 powerroleeditform.java

📁 Struts_Spring_Hibernate实现的基于RBAC的权限管理系统
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.xaccp.struts.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

import com.xaccp.biz.po.Role;
import com.xaccp.biz.po.RolePower;
import com.xaccp.biz.po.UserPower;

/** 
 * MyEclipse Struts
 * Creation date: 09-27-2006
 * 
 * XDoclet definition:
 * @struts.form name="powerRoleEditForm"
 */
public class PowerRoleEditForm extends ActionForm {
	/*
	 * Generated fields
	 */

	/** id property */
	private int id;

	/** desc property */
	private String desc;

	/** name property */
	private String name;

	/** fatherId property */
	private int fatherId;

	/** powerStates property */
	private int[] powerStates;

	/** powerIds property */
	private int[] powerIds;

	/*
	 * Generated Methods
	 */

	/** 
	 * Method validate
	 * @param mapping
	 * @param request
	 * @return ActionErrors
	 */
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors ae = new ActionErrors();
		if (id==fatherId && id!=0) {
			ae.add("same", new ActionError("power.role.same"));
		}
		if (name==null || name.equals("")) {
			ae.add("empty", new ActionError("empty","Role name"));
		}
		if (desc==null || desc.equals("")) {
			ae.add("empty", new ActionError("empty","Role description"));
		}
		return ae;
	}

	/** 
	 * Method reset
	 * @param mapping
	 * @param request
	 */
	public void reset(ActionMapping mapping, HttpServletRequest request) {
	}

	/** 
	 * Returns the id.
	 * @return int
	 */
	public int getId() {
		return id;
	}

	/** 
	 * Set the id.
	 * @param id The id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/** 
	 * Returns the desc.
	 * @return String
	 */
	public String getDesc() {
		return desc;
	}

	/** 
	 * Set the desc.
	 * @param desc The desc to set
	 */
	public void setDesc(String desc) {
		this.desc = desc;
	}

	/** 
	 * Returns the name.
	 * @return String
	 */
	public String getName() {
		return name;
	}

	/** 
	 * Set the name.
	 * @param name The name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/** 
	 * Returns the fatherId.
	 * @return int
	 */
	public int getFatherId() {
		return fatherId;
	}

	/** 
	 * Set the fatherId.
	 * @param fatherId The fatherId to set
	 */
	public void setFatherId(int fatherId) {
		this.fatherId = fatherId;
	}

	/** 
	 * Returns the powerStates.
	 * @return int[]
	 */
	public int[] getPowerStates() {
		return powerStates;
	}

	/** 
	 * Set the powerStates.
	 * @param powerStates The powerStates to set
	 */
	public void setPowerStates(int[] powerStates) {
		this.powerStates = powerStates;
	}

	/** 
	 * Returns the powerIds.
	 * @return int[]
	 */
	public int[] getPowerIds() {
		return powerIds;
	}

	/** 
	 * Set the powerIds.
	 * @param powerIds The powerIds to set
	 */
	public void setPowerIds(int[] powerIds) {
		this.powerIds = powerIds;
	}

	public static PowerRoleEditForm createByRole(Role r) {
		PowerRoleEditForm f = new PowerRoleEditForm();
		f.setId(r.getId());
		f.setName(r.getName());
		f.setDesc(r.getDesc());
		//父角色
		if (r.getTblRole()==null) {
			f.setFatherId(0);
		} else {
			f.setFatherId(r.getTblRole().getId());
		}

		int pids[] = new int[r.getTblRolePowers().size()];
		int pss[] = new int[pids.length];
		int i=0;
		for (Object up :r.getTblRolePowers()) {
			pids[i] = ((RolePower)up).getTblPower().getId();
			pss[i++] = ((RolePower)up).getState();
		}
		f.setPowerIds(pids);
		f.setPowerStates(pss);

		return f;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -