1、js获取当前path
2、ext下拉框通过选择数据来改变某个文本域不可用
3、ext用户名唯一性效验
4、json的运用
var contextPath = function() {
var root = window.location.href;
root = root.replace("http://","").replace("https://","").replace("//","/");
var first = root.indexOf("/");
root = root.substr(first, root.indexOf("/",first+1) - first);
return root;
}();
输入css、js
document.write("<link href='xxx.css' rel='stylesheet' type='text/css' />");
document.write("<script src='xxx.js' type='text/javascript'></script>");
2、ext下拉框通过选择数据来改变某个文本域不可用
if(id == "1")
{
var urlEl = Ext.getCmp("url").getEl().dom;
urlEl.disabled = true;
urlEl.style.background = "#eee";
}
else if(id == "2")
{
var urlEl = Ext.getCmp("url").getEl().dom;
urlEl.disabled = false;
urlEl.style.background = "#fff";
}
3、ext用户名唯一性效验
var VDALIDATE_NAME_URL = "xxx/xxx.action";
var isPersonNameOK = true;
/**
* 名称唯一性效验
* @param {Object} name
*/
function validateName(thisText)
{
if (thisText == "" || thisText == null)
{
isPersonNameOK = false;
return;
}
Ext.Ajax.request({
url : VDALIDATE_NAME_URL,
method : 'post',
params: 'name=' + thisText,
async :false, [color=red]//是关键、此功能在ext3.0的使用需要依赖ext-basex.js文件[/color]
success: function(response, options) {
var responseArray = Ext.util.JSON.decode(response.responseText);
if (typeof(responseArray) != "undefined")
{
if (responseArray.menu.result == "false" || responseArray.menu.result == false)
{
isPersonNameOK = true;
} else {
isPersonNameOK = false;
}
}
}
});
}
var textfieldname = new Ext.form.TextField({
fieldLabel : "name",
name : "name",
blankText : "required",
allowBlank: false,
maxLength : 255,
maxLengthText : 'Only allow 255 bytes',
regex: /^[^\*?\"'<>|]+$/,
regexText:"Cannot contain any of the following characters: \ / : * ? \" ' < > | ( )",
width : 230,
validator :function(thisText){
//唯一性效验
validateName(thisText);
if (isPersonNameOK == false) {
textfieldname.invalidText = "The name already exists. Please enter a new name.";
}
return isPersonNameOK;
}
});
4、json的运用
//前台
var aObj = new Array();
aObj.push({key: "id" ,value:"100"});
aObj.push({key: "name" ,value:"wjcom"});
var dataJSON = JSON.stringify(aObj, function(key, value){
return value;
});
//后台取值
JSONArray instArray = JSONArray.fromObject(dataJSON);
for (int i = 0; i < instArray.size(); i++)
{
JSONObject jsonObj = (JSONObject)instArray.get(i);
String sKey = String.valueOf(jsonObj.get("key"));
String sValue = String.valueOf(jsonObj.get("value"));
}