星期二, 七月 31, 2007

如何避免JSP文件产生空格或空白行(whitespace)

jsp的解析器,忠实的输出jsp文件里包含的没一个字符,如果发现一个<%%> 对,就会在解析完成后,则把<%%>解释后的结果输出。
所以,避免JSP文件产生空白行的办法,就是需要把所有的<%%>连起来书写,在jsp文件中减少手动的回车换行,就可以避免JSP文件产生空白行了。

比如.
<%@ page contentType="text/xml;" %><%@page import="com..dao.Mrp_Workload_Capacity_Calculate_DAO"%><%@ page import="com.sun.rowset.CachedRowSetImpl"%><%@ page import="com.util.DBUtil"%><%...%>

星期五, 七月 27, 2007

DHMTL Grid Paginal 语法.

http://www.nauticalworld.co.uk/jscripts/dhtmlxTreeGrid/samples/pro_paging_wt.html

<div id="gridbox" width="100%" height="250px" style="background-color:white;overflow:hidden"></div>//显示grid数据地方
<div id="recinfoArea" style="width:100%;"></div>//用来显示导航条的地方
<script>
mygrid = new dhtmlXGridObject('gridbox');
...
//should be called before init()
mygrid.enablePagingWT(true,10,3,"recinfoArea");
...
mygrid.init();
mygrid.setXMLAutoLoading("dynscroll.php");//如果想每次点击下一页的时候从服务器读取数据,必须要加入这一行,通过url参数rowsLoaded=N 在服务器段来获取下一页的数据

mygrid.loadXML("dynscroll.xml");//this sample uses static loading
</script>

星期三, 七月 25, 2007

Javascript匿名function(或无名unnamed)的申明

Anonymous function(or Unnamed function)语法:

var greet=function(){....}//可以有参数,或无参数。

调用的方法:greet();如果有参数,需要再调用的时候加入参数.

对象常量 Object Literals:

var car = {myCar:(function(){return "WIlliam";}), getCar: "Honda", special: "Sales"}
调用:
document.write(car.myCar()); // WIlliam
document.write(car.getCar); // Honda
document.write(car.special); // Sales
对象常量同匿名function 组合,可以写出非常复杂的表达

var car = {myCar:(function(){return "WIlliam";}), getCar: "Honda", special: "Sales"}
document.write(car.myCar); // WIlliam
document.write(car.getCar); // Honda
document.write(car.special); // Toyota
或另一个常用语法

var Person=function(){}
Person.prototype.name="William"
Person.prototype.age=17
who=new Person();

document.write(who.name);

Javascript的匿名function 的语法主要设计到Javascript如何对面向对象的支持。

var Person=function(){}
Person.prototype = {
initialize: function(name) {
this.name = name;
},
greet: (function() {
return("Hello from " + this.name+"");
})
};

who=new Person();
who.initialize("William");
alert(who.greet());

一个比较好的地址:http://blogs.sun.com/sundararajan/entry/java_javascript_and_jython

星期五, 七月 20, 2007

dojo TabContainer Javascript控制

<div id="mainTabContainer" selectedTab="这里是{CalendarPart,vocationPart,WorkCenterPart}之一" dojoType="TabContainer" style="width: 100%; height: 26em;">
<div id="CalendarPart" dojoType="ContentPane" href="1.jsp" refreshOnShow="true" executeScripts="true" contentCache="false" label="<b>Calendar</b>"></div>
<div id="vocationPart" dojoType="ContentPane" href="2.jsp" refreshOnShow="true" executeScripts="true" contentCache="false" label="<b>Holiday</b>"></div>
<div id="WorkCenterPart" dojoType="ContentPane" href="3.jsp" refreshOnShow="true" executeScripts="true" contentCache="false" label="<b>Work Center</b>"></div>
</div>

每个contentPane内容的改变,典型使用以下Script
<script>
var obj =dojo.widget.byId("WorkCenterPart");
//alert(obj);
obj.setUrl("");//新的动态内容url
</script>

星期二, 七月 17, 2007

WINDOWS XP Dr Watson Log file.

任务管理器,选择进程,鼠标右键选择调试,然后查看log文件

c:\Documents and Settings\All Users\Application Data\Microsoft\Dr Watson\drwtsn32.log

星期日, 七月 15, 2007

飞狐 运行VBS公式出现错误处理。

在飞狐公式中运行VBS公式出现以下错误的提示:

"脚本引擎请求位置对象信息:"Wscript"",脚本引擎请求位置对象信息:"JSProxy"

解决方法:

进入windows目录下,再进入system32目录下,运行:
regsvr32 jscript.dll
regsvr32 vbscript.dll

再启动飞狐软件或股道软件就可以了。

Java Rest框架。

https://cetia4.dev.java.net/

支持:Servlet API.

支持ROR的Java框架.

http://grails.codehaus.org/

星期五, 七月 13, 2007

XML CDATA,强大的万能标签。

CDATA

Everything inside a CDATA section is ignored by the parser.

If your text contains a lot of "<" or "&" characters - as program code often does - the XML element can be defined as a CDATA section.

A CDATA section starts with "<![CDATA[" and ends with "]]>":


<script>
<![CDATA[
function matchwo(a,b)
{
if (a < b && a < 0) then
{
return 1
}
else
{
return 0
}
}
]]>
</script>

In the example above, everything inside the CDATA section is ignored by the parser.

Notes on CDATA sections:

A CDATA section cannot contain the string "]]>", therefore, nested CDATA sections are not allowed.

Also make sure there are no spaces or line breaks inside the "]]>" string.

星期四, 七月 05, 2007

动态创建复杂form之二

方法一:

formname.document.createElement("form");
document.body.appendChild(formname); //关键语句,否则submit()方法没有实际动作

//add other node
txtObj = document.createElement("input");
//1
txtObj.setAttribute("type","hidden");
txtObj.setAttribute("name","username");
txtObj.setAttribute("value","William");
formname.appendChild(txtObj);
//2
txtObj2 = document.createElement("input");
txtObj2.setAttribute("type","hidden");
txtObj2.setAttribute("name","actionTarget");
txtObj2.setAttribute("value","VacationSetting");
formname.appendChild(txtObj2);
formname.action = target;
formname.method="post";
formname.submit();

方法二:

var f = document.createElement(’form’);
document.body.appendChild(f); //关键语句,否则submit()方法没有实际动作

f.style.display = ‘none’; this.parentNode.appendChild(f);
var h = document.createElement(’input’);
h.type = ‘hidden’; h.name = ‘act’; h.value = ‘admin’;
f.appendChild(h);

var h2 = document.createElement(’input’);
h2.type = ‘hidden’; h2.name = ’setadmin’; h2.value = ‘delcat’;
f.appendChild(h2);

f.method = ‘POST’;
f.action = ‘index.php’;
f.submit();
return false

方法三:

function doIt()
{
formname = document.createElement("form");
document.body.appendChild(formname);
//add other node
txtObj = document.createElement("");
formname.appendChild(txtObj);
//2
txtObj2 = document.createElement("");
formname.appendChild(txtObj2);
//3
txtObj3 = document.createElement("");
formname.appendChild(txtObj3);

formname.action = target;
formname.method="POST";

formname.submit();
}

星期三, 七月 04, 2007

用Javascript和DOM完全动态建立一个Form

Form Element Interfa

1.建立一个提交的Form
// Create a form
var f = document.createElement("form");

// Add it to the document body
document.body.appendChild(f);

// Add action and method attributes
f.action = "/cgi-bin/some.cgi";
f.method = "POST"

// Call the form's submit method
f.submit();