??xml version="1.0" encoding="utf-8" standalone="yes"?>
(1)快速定?Ҏnode.id
注: EXT 树的节点如果不展开,数据是获取不到的( getNodeById() 报异?Q即使你load了数据不展开节点前,一栯取不到?/span>
var node=treepanel.getNodeById(node_id);
treepanel.getRootNode().cascade(function(n) {
]]>
具体描述Q?/span>
表格W一列(其它列也行)为类型选择列,采用ComboBox为编辑器Q当选择某一cdQ如Q类?Q时表格当前?/strong>的某些列Q如Q第2列~W?列)变Z可编辑状态,q显CZ同的样式Q类gbutton的disableQ?/p>
当选择其它cdQ如Q类?Q时表格当前?/strong>的不可编辑单元格又变成可~辑的?/p>
(1)
是否可编辑样式可以在列模型的renderer中操?nbsp;
renderer : function(data, meta){
if(xxx){
meta.css += " x-item-disabled";
}
}
(2)
是否可编辑逻辑可以在grid的beforeedit事g中拦截判?nbsp;
grid.on("beforeedit", function(e){
/*
e = {
grid: this,
record: r,
field: field,
value: r.data[field],
row: row,
column: col,
cancel:false
};
*/
if(xxx){
return false; // 中止Q不让编?nbsp;
}
});
document.write('<authz:authorize ifAnyGranted="ROLE_HRCHANGE_S"> ');
document.write('<li><a id="a1" href="#" title="我的工作">我的工作</a></li>');
document.write('</authz:authorize>');
</script>
JSP面中的面元素,URL,按钮是否可见或变灰都可通过Acegi标签库来实现Q用Acegi标签库,可设|不同的权限ID允许点击的按?讉K的URL,或隐藏无权限的功能菜单?/font>
如何配置和用标{ֺQ?/font>
打开acegi-security-<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899">1.0.3</chsdate>.jar,在META-INF目录中有一个authz.tld文gQ将此文件复制到你的web应用的WEB-INF"tld中,然后配置web.xml,增加:
<taglib>
<taglib-uri>http://acegisecurity.sf.net/authz</taglib-uri>
<taglib-location>/WEB-INF/tld/authz.tld</taglib-location>
</taglib>
然后JSP面可以通过声明<%@ taglib uri="http://acegisecurity.sf.net/authz" prefix="authz"%>来引用标{ֺ?/font>
声明了标{以后,在页面中可以按下面的格式使用acegi标签(authz标签可以嵌套使用)Q?/font>
<!--使用权限标签的例?标签可以嵌套 -->
<authz:authorize ifAnyGranted="AUTH_USER">
<td> 一般用h?/font>
</td>
<authz:authorize ifAnyGranted="AUTH_ADMIN">
<td> 用户权限
</td>
</authz:authorize>
</authz:authorize>
<authz:authorize ifAnyGranted="AUTH_SYS">
<td> pȝl护权限
</td>
</authz:authorize>
也可以在JavaScript中用document.write输出权限标签Q?/font>
<script language="JavaScript" type="text/javascript">
//订单中心
document.write('<authz:authorize ifAnyGranted="AUTH_TAG_ORDER_CENTER"> ');
new tree(TREE_ITEMS1, TREE_TPL);
document.write('</authz:authorize>');
</script>
在有javaScript脚本中有时不方便引用acegi标签Q可以从SecurityContextHolder中获得权限集合,然后判断当前d的用P其权限集合中是否有某权限Q根据判断结果来军_昄或隐藏哪些页面元素,见下面的JSP:
<%@ page contentType="text/html; charset=GBK"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="http://acegisecurity.sf.net/authz" prefix="authz"%>
<%@ page import="org.acegisecurity.Authentication" %>
<%@ page import="org.acegisecurity.context.SecurityContext" %>
<%@ page import="org.acegisecurity.context.SecurityContextHolder" %>
<%@ page import="org.acegisecurity.userdetails.UserDetails" %>
<%@ page import="org.acegisecurity.ui.AccessDeniedHandlerImpl" %>
<%@ page import="org.springframework.aop.framework.ProxyFactoryBean"%>
<%@ page import="org.springframework.context.ApplicationContext"%>
<%@ page import="org.springframework.context.support.ClassPathXmlApplicationContext"%>
<%@ page import="org.acegisecurity.GrantedAuthority"%>
<%@ page import="com.mysoft.common.ValidateAcegiAuth"%>
<%
SecurityContext ctx = SecurityContextHolder.getContext();
%>
。。?/font>
<script language="JavaScript" type="text/javascript">
//下面是调用自定义的类ValidateAcegiAuthQ输入当前登录用LSecurityContextQ及权限码,如果有AUTH_FUN_TICKET_CHKERR权限Q则执行相应的JS脚本?/font>
<%if(ValidateAcegiAuth.validate(ctx,"AUTH_FUN_TICKET_CHKERR")){%>
//hAUTH_FUN_TICKET_CHKERR 权限Q执行相应js脚本…
<%}%>
</script>
下面是ValidateAcegiAuthcȝ代码Q?/font>
package com.mysoft.common;
import org.acegisecurity.Authentication;
import org.acegisecurity.context.SecurityContext;
import org.acegisecurity.context.SecurityContextHolder;
import org.acegisecurity.userdetails.UserDetails;
import org.acegisecurity.ui.AccessDeniedHandlerImpl;
import org.springframework.aop.framework.ProxyFactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.acegisecurity.GrantedAuthority;
/**
* 验证权限集合中是否有某一权限
* @author bzwang
*
*
*/
public class ValidateAcegiAuth
{
/**
*验证权限集合中是否有某一权限
* @param ctxLoginUser SecurityContext
* @param sAuthID 权限ID
* @return boolean 是否有指定的权限
*/
public static boolean validate(SecurityContext ctxLoginUser,String sAuthID)
{
boolean bool = false;
Authentication authLoginUser = null;
GrantedAuthority[] arrayAuthorities = null;
if(ctxLoginUser!=null)
{
authLoginUser = ctxLoginUser.getAuthentication();
if(authLoginUser!=null)
{
arrayAuthorities = authLoginUser.getAuthorities();
for(int i=0;i<arrayAuthorities.length;i++)
{
if(arrayAuthorities[i].toString().equals(sAuthID))
{
bool = true;
break;
}
}
}
else
{
bool = false;
}
}
else
{
bool = false;
}
return bool;
}
}
(2)IE8 览器中,对于EXTJS TABPANEL在IE8中TAB标签选中?标签底部没有效果昄
原因:文本模式为杂?EXTJS无法判断IE览器版?也就无法?lt;a>标签中正加载CSS代码:
.ext-ie .x-tab-strip .x-tab-right{position:"relative"}
<a class="x-tab-right" id="ext-gen37" href="#">
...
</a>
HTML元素的标准事件是指mouseover、mousedown、click?blur、focus、change{。在ExtJS中,q些事g的处理如下:
ExtJS 会根据不同的览器进行相应的处理Q支持多览器。事件处理函数的参数只能参考ExtJS的文档了Q必要时q得参考源代码?/p>
2. 处理自定义事?/strong>
在ExtJS中用自定义事gQ需要从Ext.util.Observablel承Q示例代码如下:
Employee = function(name){ this.name = name; this.addEvents({ "fired" : true, "quit" : true }); } Ext.extend(Employee, Ext.util.Observable, { ... });
在这D代码中Q定义了一个Employeec,定义了fired和quit两个事g。如何触发这两个事g呢,基类 Ext.util.Observable提供了触发自定义事g的方法fireEvent(eventName, arg1, arg2, ... argn), eventName是要触发的时间的名称Q不区分大小写)Q后面的参数arg1Qarg2{是要传l事件处理函数的参数。用上面的EmployeecdCZQ触发quit事gQ?/p>
this.fireEvent('quit', this);
q行代码触发quit事gQƈEmpolyeecȝ实例传给quit事g的处理函敎ͼquit事g的订阅可以采用如下代码:
function myHandler1(empolyee){ ... } function myHandler2(empolyee){ ... } var emp = new Empolyee('tom'); emp.on('quit', myHandler1); emp.on('quit', myHandler2);
在上面的代码中,为quit事g注册了两个处理函敎ͼmyHandler1与myHandlerQ,当quit事g被激发时Q将会依ơ调?myHandler1和myHandler2两个函数?/p>
值得注意的是Q不是HTML元素的标准事件还是自定义事gQ如果ؓ某个旉注册了多个处理函敎ͼ如前面的例子Q如果myHandler1q回 false的话Q则会取消在myHandler1之后注册的处理函数的执行Q即该事件被取消Q从而停止l执行该事g的处理函敎ͼ而这个返回值false 会作Z件激发的l果Q返回给empolyeeQ即Q?/p>
var result = this.fireEvent('quit', this); if (result === false) { alert('event canceled'); //q里表示事g被某个处理函数取?/span> } else { alert('event complete'); // q里表示事g执行完毕 }
通过Ext的自定义事g的机Ӟ可以实现一对多的观察者模式,也可以实C对一的绑定模式,q一点,在ExtJS的开发中是很重要的?/p>
var store = new Ext.data.JsonStore({
url: 'get-images.php',
root: 'images',
fields: [
'name', 'url',
{name:'size', type: 'float'},
{name:'lastmod', type:'date', dateFormat:'timestamp'}
]
});
store.load();
var tpl = new Ext.XTemplate(
'<tpl for=".">',
'<div class="thumb-wrap" id="{name}">',
'<div class="thumb"><img src="{url}" title="{name}"></div>',
'<span class="x-editable">{shortName}</span></div>',
'</tpl>',
'<div class="x-clear"></div>'
);
var panel = new Ext.Panel({
id:'images-view',
frame:true,
width:535,
autoHeight:true,
collapsible:true,
layout:'fit',
title:'Simple DataView',
items: new Ext.DataView({
store: store,
tpl: tpl,
autoHeight:true,
multiSelect: true,
overClass:'x-view-over', //鼠标悬停item时的cL?defaults to undefined
itemSelector:'div.thumb-wrap', //必须?gؓitem选择?此g可ؓ.thumb-wrap e.g. div.some-class
// //(默认?defaults to 'x-view-selected',但仍必须写此cȝCSS内容
emptyText: 'No images to display'
/*
plugins: [
new Ext.DataView.DragSelector(),
new Ext.DataView.LabelEditor({dataIndex: 'name'})
],*/
prepareData: function(data){ //数据预处?x据处理前.data为原始数?cd为对?
data.shortName = Ext.util.Format.ellipsis(data.name, 15); //指定字符串ؓ15个字W?出部分用三个圆点代?
// data.sizeString = Ext.util.Format.fileSize(data.size);
// data.dateString = data.lastmod.format("m/d/Y g:i a");
return data;
},
listeners: {
selectionchange: { //l点的选择发生改变?即重新选择l点?可以更改为selectionchange:function(dv,nodes)...
fn: function(dv,nodes){
var l = nodes.length;
var s = l != 1 ? 's' : '';
panel.setTitle('Simple DataView ('+l+' item'+s+' selected)');
}
}
})
});
panel.render(document.body);
DataView 用store提供的数据流Q采用tpl的格式显C,itemSelector的gؓ数据中块的CSSc选择器,对块操作时更换其CSScL?如鼠标悬停在块上和块被选定时的CSScL?单点?是有利于对数据中的块好控制操?
tpl定义的块Q?span aria-expanded="false" class="nodeLabelBox repTarget " role="treeitem"><div id="zack_hat.jpg" class="thumb-wrap">
鼠标悬停时的块(overClassQ:<div id="zack_hat.jpg" class="thumb-wrap x-view-over">
点击被选中的块QselectedClassQ:<div id="kids_hug2.jpg" class="thumb-wrap x-view-selected">
1.当鼠标点L据流中某一块时Q块增加selectedClass定义的类样式Q如没定义类?即采用默认的cd'x-view-selected'QCSS内容依然为空,仍需手写,只是cd必须为此Q;
2.用overClass定义的CSScL式,鼠标悬停在块(div)上,更换其CSScL?
3.dataView.store.filter(f1,f2):从store中查找f1字段,与f2匚w(不完全匹配相?qo,重新本地加蝲数据.
4.dataView.store.store(f1,'asc'/'desc'):store的内Ҏf1的值排?
5.dataView.store.clearFilter():清除qo状?q原初始.
6.dataView.select(n):更换Wn个块的CSScL?
(?html:
<html>
<head>
</head>
<body id="ext-gen6" class=" ext-gecko ext-gecko3">
-->
<h1>DataView Example</h1>
<p>
</p>
<div id="images-view" class="x-panel" style="width: 535px;">
<div class="x-panel-tl">
</div>
<div id="ext-gen8" class="x-panel-bwrap">
<div class="x-panel-ml">
<div class="x-panel-mr">
<div class="x-panel-mc">
<div id="ext-gen9" class="x-panel-body" style="width: 523px; height: auto;">
<div id="ext-comp-1001" style="height: auto;">
<div id="kids_hug2.jpg" class="thumb-wrap x-view-selected ">
<div class="thumb">
<img title="kids_hug2.jpg" src="images/thumbs/kids_hug2.jpg"/>
</div>
<span class="x-editable"/>
</div>
<div id="zack_hat.jpg" class="thumb-wrap ">
</div>
<div id="zack.jpg" class="thumb-wrap ">
</div>
<div id="zack_sink.jpg" class="thumb-wrap ">
</div>
<div id="sara_pink.jpg" class="thumb-wrap">
</div>
<div id="dance_fever.jpg" class="thumb-wrap ">
<div class="thumb">
<img title="dance_fever.jpg" src="images/thumbs/dance_fever.jpg"/>
</div>
<span class="x-editable"/>
</div>
<div id="gangster_zack.jpg" class="thumb-wrap ">
</div>
<div id="zacks_grill.jpg" class="thumb-wrap">
</div>
<div id="kids_hug.jpg" class="thumb-wrap ">
</div>
<div id="zack_dress.jpg" class="thumb-wrap ">
</div>
<div id="sara_pumpkin.jpg" class="thumb-wrap">
</div>
<div id="sara_smile.jpg" class="thumb-wrap ">
</div>
<div id="up_to_something.jpg" class="thumb-wrap ">
</div>
<div class="x-clear"/>
</div>
</div>
</div>
</div>
</div>
<div class="x-panel-bl x-panel-nofooter">
</div>
</div>
</div>
</body>
<div id="_firebugConsole" style="display: none;" FirebugVersion="1.4.2"/>
</html>
(?css
#images-view .x-panel-body {
-moz-background-clip:border;
-moz-background-inline-policy:continuous;
-moz-background-origin:padding;
-x-system-font:none;
background:white none repeat scroll 0 0;
font-family:Arial,Helvetica,sans-serif;
font-size:11px;
font-size-adjust:none;
font-stretch:normal;
font-style:normal;
font-variant:normal;
font-weight:normal;
line-height:normal;
}
#images-view .thumb {
-moz-background-clip:border;
-moz-background-inline-policy:continuous;
-moz-background-origin:padding;
background:#DDDDDD none repeat scroll 0 0;
padding:3px;
}
#images-view .thumb img {
height:60px;
width:80px;
}
#images-view .thumb-wrap {
float:left;
margin:4px 0 4px 4px;
padding:5px;
}
#images-view .thumb-wrap span {
display:block;
overflow:hidden;
text-align:center;
}
#images-view .x-view-over {
-moz-background-clip:border;
-moz-background-inline-policy:continuous;
-moz-background-origin:padding;
background:#EFEFEF url(../../resources/images/default/grid/row-over.gif) repeat-x scroll left top;
border:1px solid #DDDDDD;
padding:4px;
}
#images-view .x-view-selected {
-moz-background-clip:border;
-moz-background-inline-policy:continuous;
-moz-background-origin:padding;
background:#EFF5FB url(images/selected.gif) no-repeat scroll right bottom;
border:1px solid #99BBE8;
padding:4px;
}
#images-view .x-view-selected .thumb {
-moz-background-clip:border;
-moz-background-inline-policy:continuous;
-moz-background-origin:padding;
background:transparent none repeat scroll 0 0;
}
#images-view .loading-indicator {
background-image:url(../../resources/images/default/grid/loading.gif);
background-position:left center;
background-repeat:no-repeat;
font-size:11px;
margin:10px;
padding-left:20px;
}
.menubar {
border-bottom: 1px solid #AACCF6;
color: #222222;
cursor: pointer;
display: block;
height: 20px;
width: 50px;
line-height: 17px;
outline-color: -moz-use-text-color;
outline-style: none;
outline-width: 0;
padding: 3px;
text-align: center;
text-decoration: none;
white-space: nowrap;
}
.menubar:hover { //鼠标悬停上时触发
background: #EBF3FD url(../item-over.gif) repeat-x scroll left bottom;
text-decoration: none;
}
var myNewRecord = new TopicRecord({
topic_title: 'Do my job please',
username: 'noobie',
topic_replies: 1,
post_time: new Date(),
user2: 'Animal',
post_text: 'No way dude!'
});
myStore.add(myNewRecord);
匚w中文字符的正则表辑ּQ?[\u4e00-\u9fa5]
评注Q匹配中文还真是个头疼的事,有了q个表达式就好办?/p>
匚w双字节字W?包括汉字在内)Q[^\x00-\xff]
评注Q可以用来计字W串的长度(一个双字节字符长度?QASCII字符?Q?/p>
匚wI白行的正则表达式:\n\s*\r
评注Q可以用来删除空白行
匚wHTML标记的正则表辑ּQ?lt;(\S*?)[^>]*>.*?</\1>|<.*? />
评注Q网上流传的版本太糟p,上面q个也仅仅能匚w部分Q对于复杂的嵌套标记依旧无能为力
匚w首尾I白字符的正则表辑ּQ^\s*|\s*$
评注Q可以用来删除行首行I白字符(包括I格、制表符、换늬{等)Q非常有用的表达?/p>
匚wEmail地址的正则表辑ּQ\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
评注Q表单验证时很实?/p>
匚w|址URL的正则表辑ּQ[a-zA-z]+://[^\s]*
评注Q网上流传的版本功能很有限,上面q个基本可以满需?/p>
匚w帐号是否合法(字母开_允许5-16字节Q允许字母数字下划线)Q^[a-zA-Z][a-zA-Z0-9_]{4,15}$
评注Q表单验证时很实?/p>
匚w国内电话LQ\d{3}-\d{8}|\d{4}-\d{7}
评注Q匹配Ş式如 0511-4405222 ?021-87888822
匚w腾讯QQP[1-9][0-9]{4,}
评注Q腾讯QQ号从10000开?/p>
匚w中国邮政~码Q[1-9]\d{5}(?!\d)
评注Q中国邮政编码ؓ6位数?/p>
匚ww䆾证:\d{15}|\d{18}
评注Q中国的w䆾证ؓ15位或18?/p>
匚wip地址Q\d+\.\d+\.\d+\.\d+
评注Q提取ip地址时有?/p>
匚w特定数字Q?br />
^[1-9]\d*$ //匚w正整?br />
^-[1-9]\d*$ //匚w负整?br />
^-?[1-9]\d*$ //匚w整数
^[1-9]\d*|0$ //匚w非负整数Q正整数 + 0Q?br />
^-[1-9]\d*|0$ //匚w非正整数Q负整数 + 0Q?br />
^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$ //匚w正QҎ
^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)$ //匚w负QҎ
^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$ //匚w点?br />
^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$ //匚w非负点敎ͼ正QҎ + 0Q?br />
^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0?\.0+|0$ //匚w非正点敎ͼ负QҎ + 0Q?br />
评注Q处理大量数据时有用Q具体应用时注意修正
匚w特定字符Ԍ
^[A-Za-z]+$ //匚w?6个英文字母组成的字符?br />
^[A-Z]+$ //匚w?6个英文字母的大写l成的字W串
^[a-z]+$ //匚w?6个英文字母的写l成的字W串
^[A-Za-z0-9]+$ //匚w由数字和26个英文字母组成的字符?br />
^\w+$ //匚w由数字?6个英文字母或者下划线l成的字W串
评注Q最基本也是最常用的一些表辑ּ