Oracle神谕

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  284 随笔 :: 9 文章 :: 106 评论 :: 0 Trackbacks

#

The JBoss server configuration directory structure
conf   The conf dirctory contains the jboss-service.xml bootstrap descriptor file for a given server configuration. This defines the core services that fixed for the lifetime of the server.
data   The data directory is avaliable for use by services that want to store cotent in the file system.
deploy  The delploy dirctory is the default location the hot deployment service looks to for dynamic deployment content. This may be overridden through the URLDeployScanner URLs attribute.
log     The log directory is the directory log files are wrriten to. Thie may be overridden through the conf/log4j.xml configuration file.
tmp     The tmp directory is used by JBoss to store temporarily files such as unpacked deployments.
posted @ 2006-03-23 13:36 java世界畅谈 阅读(522) | 评论 (0)编辑 收藏

A  web browser provides two input mechanisms out of the box:hyperlinks and

HTML forms.

Second, the requests themselves are asynchronous,meaning that the

contextual links, zoom control , and the other page features remain

accessible while the map is gathering new data.

The four main components of Ajax:Javascript defines business rules and

program flow. The Document Object Model and Cascading Style Sheets allow

the application to reorgnize its appearance in response to data feteched in

the background from the server by the XMLHttpRequest object or its close

cousins.

We've hightlighted a few more here , to demonstrate the breadth of concerns

to which CSS can be applied:
(1)on-screen placement
(2)texturing elements
(3)assisting in layout of elements
(4)placing text relative to accompanying graphics

The DOM presents an HTML document as a tree structure , with each element

representing a tag in the HTML markup.


Working with the DOM using Javascript

An Example:
window.onload=function(){
   var hello=document.getElementById('hello');
   hello.className='declared';

   var empty = document.getElementById('empty');
   addNode(empty,"reader of");
   addNode(empty,"Ajax in action");

   var children = empty.childNodes;
   for (var i=0;i<children.length;i++){
      children[i].className='programmed';
   }
  
   empty.style.border='solid green 2px';
   empty.style.width='200px';
}

function addNode(el,text){
   var childEl = document.createElement('div'); --create new element
   el.appendChild(childEl);
   var txtNode=document.createTextNode(txt); --create text element
   childEl.appendChild(txtNode);
}

A third method worth mentioning allows us to make a shortcut through

documets that we haven't tagged with unique IDs. DOM nodes can also be
searched for based on their HTML tag type,usinf getElementByTagName(). For

example , document.getElementByTagName('UL') will return an array of all

<UL> tags in the document.

FINDING A DOM NODE
CREATING A DOM NODE

Adding styles to your document:
hello.className='declared';
empty.style.border="solid green 2px";


innerHTML

refactoring 重构

Working with DOM elements
A web page is exposed to Javascript through the Document Object Model

(DOM),a tree-like structure whose elements correspond to the tags of an

HTML document. When manipulating a DOM tree progarmmatically ,it is quite

common to want to find out an element's position on the page.

Unfortunately,browser vendors have provided various nonstandard methods for

doing so over the years,making it diffcult to write fail-safe cross-browser

code to accommplish the task.

window.onloadListeners = new Array();
window.addOnLoadListener(listener){
   window.onloadListener[window.onloadListeners.length]=listener;
}

window.onload=function(){
   for(var i=0;i<window.onloadListeners.length;i++){
     var func = window.onloadListeners[i];
  }
}

//------------------------------------------
Reusing user action handlers:命令模式

function buttonOnClickHandler(event){
  var data = new Array();
  data[0]=6;
  data[1]=data[0]/3;
  data[2]=data[0]*data[1]+7;
  var newRow = createTableRow(dataTable);
  for (var i=0;i<data.length;i++){
     createTableCell(newRow,data[i]);
  }
}
buttonDiv.onclick=buttonOnClickHandler;

//------------------------------------
Keeping only one reference to a resource:Singleton pattern

function TradingMode(){
  this.mode=MODE_RED;
}

TradingMode.prototype.setMode=function(){

}

TradingMode.instance = new TradingMode();

var TradingMode={
   mode:MODE_RED,
   setMode:function(){
    ...
   }
};

基于模板的系统:


Prototype:
Prototype是一个为Javascript编程提供多用途的助手类库,使用一个导向扩展

Javascript语言自己支持一个OO编程方式。Prototype有一个有特色的Javascript编码

样式,基于这些已经增加的语言特性。虽然Prototype编码自身很难阅读,从Java/C#/

样式中被移除存在很久了,使用Prototype,和内建在它上的,是直接的。Prototype

可以考虑为类开发者提供类。AJax应用程序作者更多希望使用类建立类而不是使用

Prototype自身。我们将查询这些类在下面的部分中。在期间,一个主要的关于

Prototype核心的特性讨论将帮助介绍它自身的编码的样式和将在我们讨论

Scriptaculous、Rico和Rubt on Rail.
  Prototype允许一个对象扩展通过复制所有的父对象的属性和方法给子其他。这个

特性是最好的举个例子,让我们看一下定义的Vehicle父类
function Vehicle(numWheels,maxSpeed){
  this.numWheels = numWheels;
  this.maxSpeed = maxSpeed;
}

对此我们想要定义一个精确的实例来表现一个乘客列车。在我们的子类中我们也想表

现客车的数量并支持增加或减少的机制。在常用的Javascript中,我们可能这样写:

var passTrain = new Vehicle(24,100);
passTrain.carriageCount = 12;
passTrain.addCarriage = function(){
  this.carriageCount++;
}
passTrain.removeCarriage=function(){
  this.carriageCount--;
}

这为我们的PassTrain对象提供需要的功能性。从设计的视图的查看这些代码,虽然它

有点掩饰了扩展扩展性功能性到一个连贯的单元。Prototyp可以在这里帮助我们,通

过允许我们定义扩展行为作为一个对象并且接着使用它扩展基础对象。首先,我们作

为一个对象定义扩展的功能性:

function CarriagePuller(carriageCount){
  this.carriageCount = carriageCount;
  this.addCarriage=function(){
    this.carriageCount++;
  }
  this.removeCarriage=function(){
   this.carriageCount--;
 }
}

接着我们合并这两个来支持一个对象包含所有的需要的行为:
var parent = new Vehicle(24,100);
var extension = new CarriagePuller(12);
var passTrain = Object.extend(parent,extension);

注意我们分别在开始后来定义父和扩展对象,接着将他们进行混合。这父子关系存在

这些例中,不在Vehicle和CarriagePuller类中。当它不是正确的经典的面向对象,它

允许我们保持我们代码与系统功能进行关联,在这个拉车按例中,在一个地方,通过

在我们更容易进行复用。我们做这个例子看起来似乎没有什么用处,在大的项目中,

用这种方法封装功能性是非常有用的。

Prototype也以AJax对象的方式提供对Ajax支持,这可以解决超平台XMLHttpRequest对

象。Ajax是被Ajax.Request类型扩展,它可以使用XMLHttpRequest向服务器发送请求

,例如: var req = new Ajax.Request('myData.xml');

这个构造子使用一个我们也将要看到的在很多Prototype-based类库中的样式。它使用

结合的数组来作为一个可选的参数,允许一个宽范围的按照需要进行配置。

Ajax.Updater


The View in an Ajax application
Keepling the logic out of the View 将View分离出logic
间接使用CSS增加事件
绑定事件控制代码


The Rico framework has a concept of Behavior objects that target specific

sections of a DOM tree and add interactivity to them.

Keeping the view out of logic

 

posted @ 2006-02-22 18:55 java世界畅谈 阅读(608) | 评论 (0)编辑 收藏

10条通向快速Web 站点现实的步骤
1.确定瓶颈
 1.1文件大小
   在需要使用这个页面时用户需要加载多少数据。、
   60-100K 页面大小 保持教小的文件
 1.2反应时间
   你向服务器发送请求和数据到达PC的时间间隔
   网络反应时间
2.减少文件大小
  100K以上
  大量的文件当前主要是由巨大的Javascript类库。
  巨大的图片
  老的HTML样式也会产生大文件,尽可能地使用XHTML和CSS
  压缩
3.查找什么导致了很高的反应
  如上我们所提到的,反应时间主要由两个主要的元素
  3.1网络反应时间
  3.2是否花费了太长的时间来产生页面
  3.3性能
4.确定绝缘组件
5.编译缓存
6.查看DB查询
  避免join. 查询缓存
7.发送正确的已修改数据
8.考虑组件缓存
9.减少服务加载
  9.1使用相反的代理
  9.2采用轻量级的HTTP服务器
10. 增加服务器
posted @ 2006-02-11 13:48 java世界畅谈 阅读(404) | 评论 (0)编辑 收藏

原文地址:http://www.bobbyvandersluis.com/articles/goodpractices.php

Ten good practices for writing JavaScript in 2005

1. Make sure your JavaScript code is in balance with its environment

Web Standards are a three-legged stool, or without metaphors(暗喻), a threesome(三人一组) of technologies that should live together in harmony(和睦相处). (X)HTML adds structure and semantics to your content, CSS is responsible for (为...负责)its presentation, and the DOM provides an interface to add behavior. You keep your Web pages flexible (or: easier to understand, maintain, restyle<改变样式> and update behavior) by separating all three layers; structure and content from presentation, structure and content from behavior and presentation from behavior. To accomplish this, try to avoid inline behavior and use unobtrusive techniques instead.

主要表述了三种技术的综合使用,html为细节结构和语法 css为表现负责  dom支持增加事件行为的接口。

When you attach behavior on page load, you may have to work around some known issues. First, you may encounter differences in cross-browser event handling. Second, make sure you don't overwrite existing onload handlers. Last, but not least, you may encounter a delay in the attachment of your behavior. The underlying (潜在的)problem is that a window onload event will only execute after the whole document, including all page assets like images and objects, is loaded. If your script needs to respond immediately after an element has loaded or if you work with a lot of content, a series of images or a slow server, you may be forced to look for a solution. You can either hide your content until the behavior is attached or attach the behavior via a script call after your elements are loaded, like at the end of the body element.
介绍在页面开发中主要遇到的问题!

Choose your markup wisely, so you can take full advantage of the power of the DOM.<充分利用dom的力量> For example, when you use nested lists to build a navigation bar, you can use the structure of the DOM tree instead of a replicated(复制) structure in arrays.<list dom tree> Scripting should be avoided in some cases where you can use markup or CSS to create behavior. This may sound a bit contradictory(反对), however built-in behavior enabled by (X)HTML attributes (e.g. disabling a form field or setting a max length on an input field) and CSS pseudo-classes (e.g. when building rollovers or drop downs) are regarded to be wider supported and easier to implement than using JavaScript. ToughQuiz on Quirksmode illustrates the discussion and the fine line between the uses of CSS generated content and regular markup and behavior.

In those cases where CSS currently lacks<缺乏> cross-browser support or is missing features for adding presentation, DOM based scripting can supplement<补充> CSS. Presentational scripting will probably be replaced in a few years, when browsers have better CSS2.1 compliance<顺从> and with the support of CSS3. Please realize that, because of the interrelationship<相互影响> of the different Web Standards and because both Web Standards and Web clients are constantly evolving<进化>, some good practices for using the DOM and JavaScript will change over time<随着时间的过去>.

2. Create accessible<可理解的、易受影响的> JavaScript

JavaScript is accessible when a page's navigation, content and main functionality (e.g. submitting a form) is available to your whole target audience, independent of their Web client or input device. This includes:

  • People who use assistive<帮助> technologies, like screen readers
  • People who don't use a mouse for navigation
  • People who have no JavaScript support (e.g. some mobile clients), have JavaScript disabled, or have partial<部分的> DOM or JavaScript support
  • Machines, like search engines

The most common way to create accessible JavaScript is to use unobtrusive techniques that are mouse independent and enhance your already accessible markup with behavior. Progressive enhancement and its predecessor graceful degradation are good strategies to create Web pages that are accessible to the most common denominator, while providing a better user experience for a smaller group of people with more advanced devices or Web clients. No matter what strategy you use, make sure that you always design for multiple scenarios.

3. Create usable(便于使用的) JavaScript

The usability of a Web page is often determined by a good information architecture, clear and intuitive(直觉的) visual design and well designed functionality. One of the main arguments to enhance your markup using unobtrusive JavaScript is to improve the usability of a Web page by supporting these usability attributes. If you add JavaScript and don't enhance the usability of a Web page, you should rethink if you should apply it at all.

4. Create easy applicable(可适用的) JavaScript

Unobtrusive scripting bridges the gap between 'designers' and 'coders'. There is a big group of people in today's industry that does know how to write (X)HTML and CSS but doesn't feel very comfortable with the DOM and JavaScript. Unobtrusive behavior introduced a mechanism to easily apply small portable scripts to a Web page: "Just make sure your markup looks like A, include this script B, and as a result you have a page that can do C".

Try to create small pieces of independent code. The disadvantages of a lot of existing JavaScript code libraries are that you often have to include a lot more code than you really need and that they are harder to understand and maintain if you didn't create them yourself. Because the functions in these libraries are often grouped and reused by other scripts, it often feels like they are spaghetti-coded. A library with small unobtrusive scripts has the advantage of being light-weight, easy to be understood and easy to be adjusted for more specific implementations.

Create reusable code. If you find yourself duplicating code snippets(片段), create functions. If you find yourself duplicating(复制) similar code snippets, try to abstract your code to the level that you can reuse it for multiple purposes.

Document your code well. If you work together with other people, like to share your code with others, or still want to know why you did certain things one year from now, good documentation is key.

5. Create future-proof JavaScript

Avoid browser detection, because it is almost impossible to maintain in the future. Feature testing or object detection offers a browser independent and future-proof technique to test to what extent your Web client supports JavaScript.

XHTML (if not used in backwards-compatible mode) introduces media type application/xhtml+xml (currently unsupported by Internet Explorer), which has a huge impact on how we write JavaScript code:

  • The HTML DOM is case-insensitive, the XML DOM is case-sensitive (区分大小写)
  • Elements need to be referenced in lowercase, e.g. document.getElementsByTagName("p")
  • document.body is deprecated, instead reference it by id or use document.getElementsByTagName("body").item(0)
  • Collections like document.images, document.applets, document.links, document.forms and document.anchors do not exist when serving XHTML as XML, instead use document.getElementsByTagName()
  • innerHTML and document.write cannot be used anymore, instead use DOM methods, e.g. document.createElementNS("http://www.w3.org/1999/xhtml", "div")

If you want to keep yourself up-to-date with the latest developments, there are a lot of initiatives from different organisations that will impact the ways we use JavaScript and the DOM in the near future:

  • W3C
    • DOM 3 provides further XML and XPath integration
    • XHTML 2 includes XML Events, which introduces a declarative way to hook up event observers via markup, and XForms, which will change the way how we add behavior to forms
    • CSS3 introduces new pseudo-elements
  • ECMA
  • Browser vendors
    • Standards support, e.g. at the moment it is still a big question if Microsoft will ever fully support existing Web Standards and is going to support future standards
    • The addition of proprietary methods and attributes, e.g. innerHTML, Microsoft.XMLHTTP and XMLHttpRequest
    • Collaborations like the WHAT WG aimed to create new standards in shorter timeframes, e.g. the submission of Web Forms 2 to become a W3C recommendation and Web Applications, which in the future may standardise XMLHttpRequest

6. Know JavaScript's weaknesses(弱点), limitations(限制) and bugs

Although JavaScript is generally well supported by most modern Web clients, support still remains its biggest weakness. Because from the first days of the Web users were often harassed(疲倦的) by all kinds of annoying(讨厌的) behavior, browser makers decided to make it easy to switch JavaScript off (Windows XP Service Pack 2 even disables some JavaScript by default, because it regards it as active scripting). If you compare JavaScript with its little stepbrother ActionScript (which is supported when the Flash plug-in is installed and cannot be switched off), you will find that the main difference is that you can rely on its behavior to accomplish certain tasks. Because it is just too easy to switch JavaScript off, simple tasks like form validation always need to be duplicated at the server side. It will be for this reason that in the future most client-side form validation will be replaced by markup and 'built-in behavior'.

As mentioned earlier, the onload event handler is insufficient to get the best out of unobtrusive techniques. I hope that the people of the W3C will respond to this feedback from the JavaScript community and add new handlers like onElementLoad and onDOMLoad to future DOM specifications.

The JavaScript implementations of Internet Explorer and Safari suffer from memory leaks when using circular references like closures. When using circular references, make sure you remove event handlers when a page is unloaded.

7. Often there is more than one good solution

JavaScript is a very flexible language and as a result you often have multiple ways of doing things. You could choose for either a procedural(程序上) or an object oriented way of coding. For your unobtrusive behavior you can either use custom attributes or use class attributes as triggers to fully control the behavior of your site. Flexibility implies that you have to make certain choices, however often one solution is not necessarily better or worse than another. Base your decisions on the context in which you have to use your scripts and your own philosophy or taste and try to use a consistent coding style.

8. Write your own scripts or reuse code from trusted places

Currently a lot of outdated(过期的) and badly written code is available on the Internet. Many scripts are plagued by browser detection, are using proprietary features that don't work cross-browser, are inaccessible or are not separating behavior from structure, because they rely on inline event handlers and scripts. It seems that Web Standards, Web clients and the practice of writing good JavaScript have evolved so quickly in the past two years, that it is hard to keep up with the latest good practices. This on its turn makes it hard to reuse code from others or reuse code you wrote yourself a year ago. Because some parts of older scripts may still contain valid code constructs, it is best to review them and rewrite the parts that don't suffice anymore. You will probably often find that a complete rewrite will do best.

So how do less experienced DOM and JavaScript users tell the difference between good and bad code on the Internet? There are some experts on the Internet that advocate modern ways of scripting and there are communities that discuss and rate new scripts and techniques. Some examples are:

DHTML Utopia: Modern Web Design Using JavaScript & DOM is the first title of a new range of books focusing on the application of modern JavaScript and unobtrusive scripting techniques.

9. Optimize your JavaScript code for performance

Optimize your scripts for both download speed and execution speed. <下载速度和执行速度>Some tips:

  • Avoid fat code libraries and make sure your scripts stay lean and mean (or: small, independent and straightforward)
  • Write efficient code and avoid constructs that execute slow
  • Keep developer versions of your scripts that include full comments and use a compression<压缩> tool (like JavaScript cruncher or JavaScript Crunchinator) to strip out all comments and white-spaces to create a version for deployment.

10. Use tools to optimize your work process

A selection of tools that make life much easier:

  • Mozilla or Firefox browser
    • Includes the good old Netscape JavaScript console by default (Tools > Web Development > JavaScript Console for Mozilla and Tools > JavaScript Console for Firefox), e.g. to view errors and warnings that make sense
    • The Web Developer Toolbar extension, e.g. to quickly enable or disable your scripts
    • The Mozilla DOM Inspector and the Firefox DOM Inspector extension, to inspect and edit the live DOM of any Web document
    • Venkman, the JavaScript debugger (the Venkman extension for Firefox)
  • JSDoc, a tool that parses inline documentation in JavaScript source files, and produces an HTML summary
  • JSLint, a JavaScript verifier to check for syntax and programming errors.

Back

posted @ 2006-02-08 23:06 java世界畅谈 阅读(528) | 评论 (0)编辑 收藏

产品经理的角色是这样的:
to help software teams build products that customers want to buy.

Take:
2 parts requirements management
1 part development expricence
1 part commerical practices
1 part marketing(measure close carefully)

从上面可以看出,需求管理、开发经验、商业经验、市场经验,作为一个产品经理是必须的。
  如果不能把握客户的需求,开发出来的东西肯定不能为客户所接受的。把握需求是非常重要的。
  开发经验,如果把握了客户的需求,将其所需要的东西也理解了,但是没有系统开发经验肯定也是不行的,系统设计开发经验是非常重要的。
  然后是商业经验,如果没有商业经验,一味的从技术的角度看问题,这个产品肯定也很难达到理想的结果。
  最后是市场经验。

posted @ 2006-01-25 16:01 java世界畅谈 阅读(333) | 评论 (1)编辑 收藏

The Navigator object (named after the Netscape web browser, of course) has variables that specify the name and version of the browser that is running, as well as variables that identify the platform on which it is running. These variables allow scripts to customize their behavior based on browser or platform, so that they can take advantage of extra capabilities supported by some versions or work around bugs that exist on some platforms.

userAgent
   The string that the browser sends in its USER-AGENT HTTP header.This property typically contains all the information in both appName and appVersion.

eg.
 this.isIE = navigator.userAgent.toLowerCase().indexOf("msie") >= 0;

posted @ 2006-01-14 09:55 java世界畅谈 阅读(360) | 评论 (0)编辑 收藏

name: Function.bindAsEventListener

This provides a new method to the core class Function. The method,called bindAsEventListener(),is used to do bind methods to event handlers.

这为核心class 函数支持了一个新的方法。这个方法叫bindAsEventListener(),是用来绑定方法给事件处理器的。
var obj = new SomeClass();
var closure = obj.someMethod.bindAsEventListener(this);
element.onclick = closure;

posted @ 2006-01-14 09:35 java世界畅谈 阅读(724) | 评论 (0)编辑 收藏

在server.xml配置文件中:
<Connector port="8080"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="utf-8"/>
    <!-- Note : To disable connection timeouts, set connectionTimeout value
     to 0 -->
    
    
     其中关键是增加:URIEncoding="utf-8" 这样中文名也就支持了
posted @ 2005-12-30 18:57 java世界畅谈 阅读(299) | 评论 (0)编辑 收藏

  这些天在细看《J2EE Development without EJB》书,感受颇多。说起来做J2EE方面开发也有几年,自己认为自己还是有一定实力的。但是看完以后,再针对我们项目的开发感觉很多地方做的确实有很多问题。因为一直都这样做,没有人提出异议。闷着头做事情,有时候确实不好,要交流,特别是要倾听那些经验丰富的前辈的教诲。
  OO,接触开发也这么多年了,确实很少有项目,真正做到OO的。看看我们的项目,POJO做成伪对象,只是负责了值的传递,只有可怜的setter和getter,其中没有任何业务逻辑操作的代码(没有任何行为)。我们所谓的业务逻辑是引入一个Manager进行综合处理。
  1年前,也是看了jPetStore收益很多。今天再次看这个代码。又引发了更多的思考。
  先看jPetstore的处理:
  在org.springframework.sample.jpetstore包中:
  Account类:比较简单,普通的JavaBean。
  Cart类和CarItem类:从关系模型中,可以看到这是一个主从关系的对象。其中Cart(购物车)中有不少行为。例如:新增、删除购物车项目;计算总金额。一般来说,我们项目中一般这样的逻辑是写在Manager类中的。
  在Order类中,也采用一些业务行为,例如初始化订单等等。
  

posted @ 2005-10-19 23:47 java世界畅谈 阅读(956) | 评论 (2)编辑 收藏

  已经很晚了,刚刚玩了一把魔兽。我不是一个职业玩家,也很少找人拼杀。不过今天晚上的玩的过程中,有一些小小的体会。
  玩魔兽,要积极主动。刚开始的时候,要派一个农民去找一下敌人在什么位置,这是你进攻的目标,如果一开始仅仅是不断升级,和我做开发一样,不知道做一个东西的目标的是什么,只是在一味的追求技术的先进性。结果到最后,敌人(对我来说主要是疯狂的电脑)已经升级到终极的装备,等它打到我的老家的时候,我已经无力抵抗了。
  还有,在进行过程中,要随时关注你的敌人发展到什么程度了。今天晚上之所以能够赢就是因为,我观察到敌人在进行升级时候,丧失了很多血,给我一个很好的机会。
  还有,我及时进行补充血,当然微操也是很重要的,我在即将失去英雄的时候,及时进行了回城。做人何尝不是这样,有时候力量对比相差太远的时候,要学会退让。
  不过最终的胜利还是在于积极主动的心态。玩游戏如此,做人也是如此的。
posted @ 2005-10-16 23:49 java世界畅谈 阅读(865) | 评论 (5)编辑 收藏

仅列出标题
共29页: First 上一页 19 20 21 22 23 24 25 26 27 下一页 Last