#
類代碼: /************************* * * Class:CheckItem * 2009.08.23 **************************/ //-- Contructor function CheckItem(textboxName,msg,validChar,isRequired){ this.textboxName=textboxName; this.msg=msg; this.validChar=validChar; this.isRequired=isRequired; }
/************************* * * Class:FormChecker * 2009.08.23 **************************/ //-- Contructor function FormChecker(){ this.checkItemArray=new Array; }
//-- Add a check Item to array FormChecker.prototype.addCheckItem=function(textboxName,msg,validChar,isRequired){ var checkItem=new CheckItem(textboxName,msg,validChar,isRequired); this.checkItemArray[this.checkItemArray.length]=checkItem; }
//-- Check text field in the form FormChecker.prototype.checkTextBox=function(checkItem){ var validChar=checkItem.validChar; var isRequired=checkItem.isRequired; var inputValue=$(checkItem.textboxName).value; if(isRequired!="true" && inputValue.length<1){ return true; } else{ var regexStr="^"+validChar+"$"; var regex=new RegExp(regexStr); return regex.test(inputValue); } }
//-- judge the validation of a form FormChecker.prototype.isValid=function(){ for(var i=0;i<this.checkItemArray.length;i++){ var toBeCheckedObj=this.checkItemArray[i]; var checkResult=this.checkTextBox(toBeCheckedObj); if(checkResult==true){ continue; } else{ alert(toBeCheckedObj.msg); $(toBeCheckedObj.textboxName).focus(); return false; } }
return true; }
頁面代碼:
/***************************************************** * 窗口載入時調用的啟動函數 *****************************************************/ var formChecker; window.onload=function(){ // 設置主菜單的當前菜單項 setMainmenuCurrentItem(0); // 設置側邊菜單的當前菜單項 setSidemenuCurrentItemByText("合同起草"); // 取得合同類別的數據 // 填充下拉列表框數據 new TypeListbox("contractTypeFirst","0","contractTypeSecond",""); new TypeListbox("contractTypeSecond",$("contractTypeFirst").value,"contractTypeThird",""); // var today=getToday(); // $("createTime").value=today; // 屏蔽了合同起草時間,故這里也屏蔽。何楊,2011年5月6日9:20:34 // $("maintenanceEndTime").value=today; // 初始化檢查項 formChecker=new FormChecker(); formChecker.addCheckItem("contractName","請輸入一到一百位的合同名",".{1,100}","true"); formChecker.addCheckItem("contractTypeThird","請點擊下拉列表框依次選擇合同類別",".{1,100}","true"); formChecker.addCheckItem("contractAmount","請輸入數字形式的合同總金額(金額限制百億內)","([0-9]{1})(\\d{0,9})","true"); formChecker.addCheckItem("vendorName","請點擊右邊圖標選擇合同對方名稱。",".{1,}","true"); formChecker.addCheckItem("fulfillCycle","請輸入數字形式的合同履行期限,以月為單位(最多十位數字)","([1-9]{1})(\\d{0,9})","true"); formChecker.addCheckItem("maintenanceStartTime","請點擊右邊的按鈕選擇模板選擇維保起始日期","(\\d{4})-(\\d{1,2})-(\\d{1,2})","false"); formChecker.addCheckItem("maintenanceEndTime","請點擊右邊的按鈕選擇模板選擇維保結束日期","(\\d{4})-(\\d{1,2})-(\\d{1,2})","false"); formChecker.addCheckItem("contractBriefFile","請輸入零到五百字的合同所屬項目概況或依據的文件",".{1,500}","false"); formChecker.addCheckItem("contractDecision","請輸入零到一千字的項目決策過程",".{1,1000}","false"); formChecker.addCheckItem("remark","請輸入零到兩百五十個字的補充說明",".{1,250}","false"); formChecker.addCheckItem("maintenanceDescription","請輸入零到一千個字的維保描述",".{1,1000}","false"); }
/********************************************************************* * 得到表單的檢查結果 * 何楊,2011-4-17 14:31:40 *********************************************************************/ function getCheckResult(){ // 進行頁面輸入檢查 if(formChecker.isValid()==false){ return false; } // 維保起始日期 var maintenanceStartTime=$("maintenanceStartTime").value; // 維保結束日期 var maintenanceEndTime=$("maintenanceEndTime").value; // 維保起始日期和維保結束日期做比較 if(isNotEmptyString(maintenanceStartTime)==true && isNotEmptyString(maintenanceEndTime)==true){ if(isReasonable(maintenanceStartTime,maintenanceEndTime)==false){ alert("維保結束日期必須晚于維保起始日期."); $("maintenanceEndTime").focus(); return false; } } return true; }
js類代碼:
/*************************************
*
* Class:ContractTypeListboxOne
* 2011-5-18 20:08:00
**************************************/
//-- 構造函數
function TypeListbox(id,parentId,nextId,nextParentId){
this.id=id;
this.parentId=parentId;
this.nextId=nextId;
this.nextParentId=nextParentId;
this.init();
this.fillData($(this.id),parentId);
}

//-- 初始化
TypeListbox.prototype.init=function(){
var ctrl=$(this.id);
var me=this;
ctrl.onchange=function(){
me.changeEvent();
}
}

//-- 變化事件
TypeListbox.prototype.changeEvent=function(){
var ctrl=$(this.id);
if(this.nextId.length>0 && this.nextId!="none"){
this.fillData($(this.nextId),ctrl.value);
}
}

//-- 填充數據
TypeListbox.prototype.fillData=function(myListbox,parentId){
/*if(parentId.length<1 || parentId=="none"){
return;
}*/

var url=encodeURI('GetContractType.do?parentId='+parentId);
url=encodeURI(url);
new Ajax.Request(url,{
method:'get',
onSuccess: function(ajaxObj){
// alert(ajaxObj.responseText);
var status=ajaxObj.responseXML.getElementsByTagName("status")[0].firstChild.data;
if(status=="ok"){
// 返回正確信息

// 找到所有節點放入數組,為避免麻煩,節點名統一都設置成node比較好,不用實例變了,這里就要改變一次。
var arr=ajaxObj.responseXML.getElementsByTagName("node");
var length=arr.length;

for(var i=myListbox.options.length-1;i>=0;i--){
myListbox.remove(i);
}
var newOption=new Option;
newOption.value="";
newOption.text="--請選擇--";
myListbox.add(newOption);

if(length>0){
// 遍歷這個數組
for(var i=0;i<length;i++){
var node=arr[i];
var id=node.getElementsByTagName("id")[0].firstChild.data;
var name=node.getElementsByTagName("name")[0].firstChild.data;
var newOption=new Option;
newOption.value=id;
newOption.text=name;
myListbox.add(newOption);
}
}
myListbox.selectedIndex=0;
myListbox.fireEvent("onchange");
}
else{
// 返回錯誤信息
var text=ajaxObj.responseXML.getElementsByTagName("text")[0].firstChild.data;
alert(text);
}
},
onFailure: function(){
alert("無法取得服務器的響應");
}
}
);
}頁面下拉列表框:
< tr>
<td width="100%" colspan="10">
<div class="inputText">
<label for="classOneCbo">合同類別:</label>
<select id="classOneCbo">
<option value="" selected>--請選擇--</option>
</select>
<font color="#003366">-</font>
<select id="classTwoCbo">
<option value="" selected>--請選擇--</option>
</select>
<font color="#003366">-</font>
<select id="classThreeCbo">
<option value="" selected>--請選擇--</option>
</select>
</div>
</td>
</tr>頁面JS初始化代碼:
/*****************************************************
* 窗口載入時調用的啟動函數
* 何楊,2011年4月22日16:59:16
*****************************************************/
window.onload= function(){
// 設置主菜單的當前菜單項
setMainmenuCurrentItem(0);
// 設置側邊菜單的當前菜單項
setSidemenuCurrentItemByText("待辦事項");
// 填充下拉列表框數據
new TypeListbox("classOneCbo","0","classTwoCbo","");
new TypeListbox("classTwoCbo",$("classOneCbo").value,"classThreeCbo","");
// 開始檢索初始數據
search(0);
}
<html>
<head>
<title>test</title>
</head>
<body>
<select id="mySelect">
<option value="1">地球</option>
<option value="2">火星</option>
<option value="3">木衛二</option>
<option value="4">冥王星</option>
<option value="5">參宿四</option>
<option value="6">人馬座</option>
</select>
</body>
</html>

 <script language="javascript">
<!--
 window.onload=function() {
var listBox=new ListBox("mySelect");
}

 function $(id) {
return document.getElementById(id);
}

//-- 類構造函數
 function ListBox(id) {
this.id=id;
this.init();
}
//--類的初始化函數,將控件的onchange事件交給類的changeEvent事件處理
 ListBox.prototype.init=function() {
var ctrl=$(this.id);
var me=this;
 ctrl.onchange=function() {
me.changeEvent();
}
}
// onchange事件產生時彈出下拉列表控件的值
 ListBox.prototype.changeEvent=function() {
var ctrl=$(this.id);
alert(ctrl.value);
}
//-->
</script>
一般來說,出現這種異常是因為傳遞給遠程方法的參數不能實例化所致,比如有一個參數是復合類型,里面包括Calendar,Date,BigDecimal等形式的數據,需要把這些非基本類型的數據new出來賦值,然后再調用就好辦了。基本類型和String等數據則不用理會。
Table.stock tr{
onmouseover : expression(onmouseover=function (){this.style.backgroundColor ='#b3ddfb'});
onmouseout : expression(onmouseout=function () {this.style.backgroundColor =''});
}
一.以目錄形式打開某個較深不易記憶的目錄。
explorer path
例子:explorer C:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\logs\server1
二.控制臺方式進入某個目錄。
在此目錄下建一個bat文件,里面只寫cmd三個字。然后創建快捷方式到桌面就可以了。
將程序從一個容器換到另一個容器,總會有各種意料之外的困難需要解決,近日本人需要將一個Web工程從Tomcat環境轉移到WebSphere環境,經歷了一番周折,特地將此經過記錄下來,也許它能對將要進行如此經歷的人其一點幫助作用,另外在此也向網絡同仁和工作中的同事表示感謝。
原環境:
程序:SSH
容器:Tomcat6.0
數據庫:MySql5
新環境:
程序:SSH
容器:WebSphere6.1
數據庫:Oracle10g
移植過程中的第一個困難,是WebSphere不認識Web.xml中的Struts taglib.原文字(適用于Tomcat)如下:
<!-- Struts的TLDS -->
<taglib>
<taglib-uri>/WEB-INF/tld/app.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/app.tld</taglib-location>
</taglib>
<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/tld/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location>
</taglib>
這個問題因為之前有所準備,在網絡上找到了答案,將上述文字包在<jsp-config>節點中即可,修改后(對Tomcat和WebSphere均適用)的文字如下:
<!-- Struts的TLDS -->
<jsp-config>
<taglib>
<taglib-uri>/WEB-INF/tld/app.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/app.tld</taglib-location>
</taglib>
<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/tld/struts-bean.tld</taglib-uri>
<taglib-location>
/WEB-INF/tld/struts-bean.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-html.tld</taglib-uri>
<taglib-location>
/WEB-INF/tld/struts-html.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-logic.tld</taglib-uri>
<taglib-location>
/WEB-INF/tld/struts-logic.tld
</taglib-location>
</taglib>
</jsp-config>
如此處理后,首頁顯示出來了,隨即翻頁遇到了問題,在IE中是翻頁出現404錯誤,在FF中好一點,它告訴我WebSphere無法解析struts配置文件struts-config.xml。
起初我以為是中文問題,刪除struts-config.xml中所有中文注釋問題依舊,接下來在網絡中尋找,還真有和我遇到一樣問題的難友,但沒人提出解決方案,正在撓頭之際,我們的PM忽然說是否JDK不一致,檢查一下,本機用的是1.6,而WebSphere自帶1.5的,將本機也調成1.5后,問題解決! 真是只有咒語能解開咒語。
再下來,在表單提交時遇到了亂碼問題,這是因為之前聽信網絡意見,將Web.xml中的filter都去掉了,結果自然亂碼。此時感覺網絡傳聞未必可信,于是將filter又重新加上,亂碼沒有了。看來不經親自嘗試而盲從網絡傳聞是要吃虧的。
再下來,程序要訪問數據庫了,于是在WebSphere6.1中設置了數據源,再在Spring配置文件中進行了設置,如下:
<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"
value="java:comp/env/jdbc/*******DS">
</property>
</bean>
這樣寫在Tomcat中好用,在WebSphere不好用,正在撓頭之際,PM告我別的項目有同樣的寫法,于是一看,java:comp/env/這部分是不需要的,直接把數據源JNDI名寫在Value中就可以了。
<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"
value="jdbc/*******DS">
</property>
</bean>
其它數據庫移植的問題就交給了Hibernate。至此問題全部解決。
事后來看,WebSphere6.1對中文,SSH的支持還是很好的,只是有些特定的地方和傳統的Tomcat中的項目不太一樣,注意一下就好了,未必有想象中的困難。遇到困難時,向有同樣經歷的人請教比自己在網絡上搜尋要快很多。
摘要:
第一部分:頁面中JavaScript的寫法:
function isSoleContractName(contractNameTextBox){
var&nb... 閱讀全文
|