[转]CSS制作标签卡Tab效果
2005-1-31 16:45:09

CSS制作标签卡Tab效果

亚马逊网站应该不会陌生吧?对它页面上方标签卡(Tab)方式的导航条(如下图)还有印象么?

__

__amazon.com这种方式得导航引起了相当多人的效仿。那么,它是如何做到的呢?有过网页设计经验的人应该不难明白,如果不知道细节的话,通过察看源代码就能知道,它实际上是通过在表格中插入事先制作好的作为标签卡的图片来制作的,标签卡的效果通过颜色来控制,比如上图中的“YOUR STORE”这张图片和底下子栏目的颜色一致,背景都为深蓝色,这样看上就向一张卡片了。

__不过,现在网页设计的趋势是XHTML+CSS来完成。那么,如果不用图片加表格的方法,有没有办法仅仅利用CSS来制作呢?有的,可以通过项目列表的CSS设定来做到。

__

__这张图,就是利用这种方法来制作的。

__下面,我们就分别来学习CSS的标签卡制作。

利用列表元素制作标签卡

__通常情况下,项目列表的排列方式是垂直的,并在前头带有特定的项目符号,如下:

  • 项目列表一
  • 项目列表二
  • 项目列表三
  • 项目列表四

__它所对应的HTML代码是这个样子:

__<ul>
<li>项目列表一</li>
<li>项目列表二</li>
<li>项目列表三</li>
<li>项目列表四</li>
</ul>
__那是否你曾想到过,项目列表也可以不垂直排列,而是水平分布呢?在Html中无论如何是做不到这点的。可是CSS却提供了这种方法。

__首先,我们把项目列表放入到div标记中,如下:

__<div id=”horizonlist”>

__<ul>
<li>项目列表一</li>
<li>项目列表二</li>
<li>项目列表三</li>
<li>项目列表四</li>
</ul>

__</div>

__然后,我们为这个id为horizonlist的Div设定如下样式:

#horizonlist {//*设定div的Box属性*//
border: 1px solid #000;
margin: 2em;
width: 80%;
padding: 5px;
font-family: Verdana, sans-serif;
}

#horizonlist ul, #horizonlist li {//*设定限制于horizonlist的div内的ul和li的属性*//
display: inline;
margin: 0;
padding: 0;
color: #339;
font-weight: bold;
}

__此样式作用于所给项目列表的结果如下:

  • 项目列表一
  • 项目列表二
  • 项目列表三
  • 项目列表四

__可以看到,此时的项目列表成了水平放置,而且列表前的符号自动消失。之所以这样,关键在于属性display的设置值inline的作用。display用来改变元素的显示值,可以将元素类型线上,块和清单项目相互变换,其中取值inline的作用是“删除元素前后的分行符,使其并入其它元素流中”。在这里,inline取消了每个列表项目后的换行,而成为一行显示。

__顺着这个思路下去,如果我们给每个列表项目设定Box属性,那不就有了类似标签卡的效果出来了么:

  • 项目列表一
  • 项目列表二
  • 项目列表三
  • 项目列表四

__我们来看看这个例子的代码:

__<div id=”tabdemo”>
<ul>
<li>项目列表一</li>
<li>项目列表二</li>
<li class=”selected”>项目列表三</li>
<li>项目列表四</li>
</ul>
</div>

__和上面的例子不同,这里的项目列表三多了类名“selected”,用来表示当前被选中的标签卡。

__相应的CSS属性设定如下:

__#tabdemo ul li {
margin-left: 0;
margin-bottom: 0;
padding: 2px 15px 5px;
border: 1px solid #000;
list-style: none;//*不显示列表符号*//
display: inline;//*取消项目之间的分行*//
background-color: #ffc;
}

#tabdemo ul li.selected {//*设定被选中的列表的效果*//
border-bottom: 1px solid #fff;
background-color: #fff;
list-style: none;
display: inline;
}

__如果你希望每个标签卡之间有一定的距离,可以修改#tabdemo ul li此设定中的margin-left属性值,比如改为2,就可以看到类似早先给出的那张蓝色标签卡的样子。

__接下来我们来进一步修饰上面这个标签卡,先来看效果果。

__可以看到,每个标签卡之间不再紧贴一起,底下出现了一条连续的横线,当鼠标移动到每个标签卡的时候,出现了浮动的效果。

__一起来分析一下代码:

__<div id=”container”>

<ul id=”beautytab”>
<li><a xhref=”http://blogger.org.cn/blog/#” mce_href=”http://blogger.org.cn/blog/#” class=”selectedtab”>标签卡一</a></li>
<li><a xhref=”http://blogger.org.cn/blog/#” mce_href=”http://blogger.org.cn/blog/#”>标签卡二</a></li>
<li><a xhref=”http://blogger.org.cn/blog/#” mce_href=”http://blogger.org.cn/blog/#”>标签卡三</a></li>
<li><a xhref=”http://blogger.org.cn/blog/#” mce_href=”http://blogger.org.cn/blog/#”>标签卡四</a></li>
</ul>

</div>

__这个标签卡放在id为container的块div中。列表的id为beautytab,其中的列表项目标签卡一设定了一个类“selectedtab”,表示当前被选的标签卡类。

__对应的CSS设定如下:

__#container
{//*设定包含列表的div的Box属性*//
width: 500px;
padding: 30px;
border: 1px solid #ccc;
background: #fff;
}

#beautytab
{//*设定项目列表Ul元素的属性,其中background用来设定连贯于各个列表项目下的横线,否则它们会彼此分离,用了一张事先准备好的图片,让它放置在底部,水平重复*//
height: 20px;
margin: 0;
padding-left: 10px;
background: url(’/Upload/editor/bottom.gif’) repeat-x bottom;
}

#beautytab li
{//*设定各个列表项目的属性,display属性设定取消项目间的分行,list-style-type设定取消列表项目前的符号*//
margin: 0;
padding: 0;
display: inline;
list-style-type: none;
}

#beautytab a:link, #beautytab a:visited
{//*设定标签卡中超链接的文字的属性*//
float: left;
background: #f3f3f3;
font-size: 12px;
line-height: 14px;
font-weight: bold;
padding: 2px 10px 2px 10px;
margin-right: 4px;
border: 1px solid #ccc;
text-decoration: none;
color: #666;
}

#beautytab a:link.selectedtab, #beautytab a:visited.selectedtab
{//*设定当前被选中的标签卡中超链接的属性*//
border-bottom: 1px solid #fff;
background: #fff;
color: #000;
}

#beautytab a:hover
{//*设定超链接鼠标浮动效果*//
background: #fff;
}
__如果手头上有漂亮的修饰图片,我们还可以进一步制作出类似下图的漂亮雅致的标签卡来。

__

__至于如何制作,用兴趣的人可以自己动手做做看。

Struts中进行数据验证

一月 30, 2005

Developer STRUTS

Check Your Form with Validator

By James Holmes

Enabling the Validator Plug-in

配置Validator插件,也即在配置struts-config.xml,加入该插件

Configuring validator-rules.xml

大多数情况下你不需要修改预定义的验证规则,除非你希望给框架自定义验证规则。

Included Validations

默认情况下已经包含了一些常用的验证器,如required,CreditCard和email等

Creating Form Beans

为了使用验证器,应用中的Form Bean应该是验证器ActionForm的子类,
而不能是ActionFrom本身。这一子类提供了ActionForm的validate()方法的一个实现。Form Bean继承了子类之后并不需要将验证进行硬编码,完全可以将这一方法忽略掉。验证器会帮你提供验证需要的代码。
form bean在struts-config.xml中的配置也同常规的Form Bean相同验证的时候配置validation.xml。两种标准的方式创建Form Bean。一种是创建一个具体的Form Bean,另一种是创建一个动态的Form Bean,validator.xml的Form Bean的验证与struts-config.xml中的Form Bean一对一的绑定,这种机制可以适用于绝大多数的情况,但是当Form Bean在多个Action间复用(可能有的用的字段多一些有的用的少一些)时,就不适用了。为了解决这一问题,验证器有两个子类ValidatorActionForm和DynaValidatorActionForm允许将验证与action进行绑定而不是与Form Bean进行绑定。

Configuring validation.xml

Configuring ApplicationResources.properties

验证器使用Struts的资源束机制来显示错误消息。主要配置ApplicationResource.properties(添加消息文本和对应的key)文件和validation.xml(利用key引用消息文本)文件。

如果不想使用资源束机制的话,也可以在validation.xml文件中直接表明。

Enabling Client-Side Validations

除了服务端的数据验证,Struts还有机制支持客户端验证。
在validator-rules.xml中标明了在客户端用于验证的JavaScript代码(可选的标明)
为了使用客户端验证,就要在每个需要验证的JSP插入Struts HTML标签库的JavaScript标签。而无论是否使用客户端验证,服务端验证都会进行。

其他的一些文章:

Struts Validator验证器使用指南(推荐阅读)

在struts中使用validator做页面验证

Struts Validator的使用

如果只是学习一般的Struts数据验证,看本文翻译的原文即可,全面而清晰。如果要深入学习的话,可以看其他文章中的第一篇。

DriverManagerDataSource in Spring Framework

javax.sql Interface DataSource

今天看了一天的spring,想使用里面提供的JdbcTemplate,看上去非常酷的样子,不过其中涉及到了一个DataSource接口,不知道干嘛的,好不容易才找到了一个讲的比较清楚的解释。

Implementation of SmartDataSource that configures a plain old JDBC Driver via bean properties, and returns a new Connection every time.

Useful for test or standalone environments outside of a J2EE container, either as a DataSource bean in a respective ApplicationContext, or in conjunction with a simple JNDI environment. Pool-assuming Connection.close() calls will simply close the connection, so any DataSource-aware persistence code should work.

In a J2EE container, it is recommended to use a JNDI DataSource provided by the container. Such a DataSource can be exported as a DataSource bean in an ApplicationContext via JndiObjectFactoryBean, for seamless switching to and from a local DataSource bean like this class.

If you need a “real” connection pool outside of a J2EE container, consider Apache’s Jakarta Commons DBCP. Its BasicDataSource is a full connection pool bean, supporting the same basic properties as this class plus specific settings. It can be used as a replacement for an instance of this class just by changing the class name of the bean definition to “org.apache.commons.dbcp.BasicDataSource”.

“http session”的定义

一月 28, 2005

HTTP State Management Mechanism

STATE AND SESSIONS

This document describes a way to create stateful sessions with HTTP requests and responses. Currently, HTTP servers respond to each client request without relating that request to previous or subsequent requests; the technique allows clients and servers that wish to exchange state information to place HTTP requests and responses within a larger context, which we term a “session”. This context might be used to create, for example, a “shopping cart”, in which user selections can be aggregated before purchase, or a magazine browsing system, in which a user’s previous reading affects which offerings are presented.

There are, of course, many different potential contexts and thus many different potential types of session. The designers’ paradigm for sessions created by the exchange of cookies has these key attributes:

1. Each session has a beginning and an end.

2. Each session is relatively short-lived.

3. Either the user agent or the origin server may terminate a session.

4. The session is implicit in the exchange of state information.

Struts中谈到的session

2.2 JavaBeans and Scope

Within a web-based application, JavaBeans can be stored in (and accessed from) a number of different collections of “attributes”. Each collection has different rules for the lifetime of that collection, and the visibility of the beans stored there. Together, the rules defining lifetime and visibility are called the scope of those beans. The JavaServer Pages (JSP) Specification defines scope choices using the following terms (with the equivalent servlet API concept defined in parentheses):

  • page – Beans that are visible within a single JSP page, for the lifetime of the current request. (Local variables of the service method)
  • request – Beans that are visible within a single JSP page, as well as to any page or servlet that is included in this page, or forwarded to by this page. (Request attributes)
  • session – Beans that are visible to all JSP pages and servlets that participate in a particular user session, across one or more requests. (Session attributes)
  • application – Beans that are visible to all JSP pages and servlets that are part of a web application. (Servlet context attributes)

附录一篇:

Session详解

作者:郎云鹏(dev2dev ID: hippiewolf)

最近不断在看Struts方面的资料,应该说Struts已经是很成熟的一种技术了,在网上的相关介绍也是连篇累牍,但是看了能够增进理解有所帮助的还是比较难见到。下面是我觉得在Struts学习中对我有帮助的一些资料:

下面是我学习中遇到的一些困难及解决:

    • 在Tomcat上部署Struts的例子的时候碰到了问题,解决:Unable to find a javac compiler
    • 表单数据验证失败时发生错误,“No input attribute for mapping path”,原因是没有填写配置文件action中的input属性值。解决:Struts中不同的Action和ActionForm组合
    • 两次输入密码比较的验证,解决:Struts Validator: Validating Two Fields Match by Matt Raible. Howto article.开始漏看了最后一句重要的话,没看完就开始了,结果因为那个小问题浪费了两个多小时,真是不值得。
    • 实现下拉框时出现错误”Cannot find bean under name org.apache.struts.taglib.html.BEAN”。解决:JSP FAQ @ jGuru
    • 部署新的action时发生错误”No Action Instance for Path /CreateContent could be created”,开始在网上找了一下,发现大多数此类错误都是由于Action的type名称写错了,但是我仔细核对发现这里没有错,我的错误在于没有将Action的type类声明成public的!
    • 上面的数据验证的例子中采用的API调用已经被deprecated掉了,Struts 1.2用也还可以用,但是Eclipse里面会出来感叹号说不赞成使用ValidatorUtil和Resources.getActionError()方法,解决:Struts Upgrade Notes 11 to 124
    • 开了一个新的sample应用的时候,出现异常java.lang.IllegalArgumentException: Resources cannot be null.
      at org.apache.commons.validator.Validator.(Validator.java:188)
      后来发现是strut
      中没有添加validator插件,同时validation.xml文件和validator-rules.xml文件不存在
    • 使用Struts将应用分成为几个模块配置的时候,无论如何配置,一直出现找不到子模块中的action的异常,”Cannot retrieve mapping for action /mindforce/SubmitLogon”.后来发现原来是tab的链接没有通过action进行转发,而是直接写了要显示的jsp页面视图的url,因此struts进行模块间转换时无法自动识别,故action mapping找不到对应的action.正确的配置方法是:子模块中的action路径均填写模块下的相对路径,jsp页面中的action也填写相对于模块的路径而不要加上模块名称,struts会自动在模块切换时添加模块名.模块切换方法请见:5.3.3 Switching Modules

进行Struts开发时一些有用的工具:

    • Scioworks™ Camino

      Visual Modelling Tool for Struts

      Scioworks™ Camino is a visual modelling tool for Jakarta Struts Framework, the de-facto J2EE web MVC framework. Designed for rapid assembly of web applications, its unique visual drag-and-connect paradigm allows for rapid development and re-wiring of web application with minimal coding.

Exadel Struts Studio now supports Eclipse 3.0.x. This version includes design-time JSP Preview, JSP, CSS, JavaScript and XML Prompting with autocomplete functionality, Java debugging of Web applications under the Tomcat, JBoss and Sun J2EE SDK environment, and one-step adding of Struts support to J2EE projects created with other Eclipse plug-ins.

    • JamesHolmes.com

Struts Console

The Struts Console is a FREE standalone Java Swing application for developing and managing Struts-based applications. With the Struts Console you can visually edit JSP Tag Library, Struts, Tiles and Validator configuration files.

The Struts Console also plugs into multiple, popular Java IDEs for seamless management of Struts applications from one central development tool.

FWA Software’s Visual Tags Dreamweaver extension suites for JSTL and Struts enable web developers to use Macromedia’s Dreamweaver MX web design and development product to

  • Visually design, implement, and maintain web pages for JSTL and Struts-based web applications
  • Rapidly prototype web pages for JSTL and Struts-based web applications
  • Exploit open source technologies with Dreamweaver to create JSTL and Struts-based web applications

Eclipse Plugins

一月 27, 2005

Java Server Faces Resources

一月 21, 2005

Effective tools, gates, and accountability can help ensure your system’s success

 
 

Many people incorrectly judge Java/J2EE-based systems on problems associated with maintaining the codebase, the number of bugs or inconsistencies in functionality, or poor performance. Fortunately, these problems have less to do with the Java/J2EE technology itself and more to do with the lack of a process focused on the quality of the system. To ensure success of large-scale Java/J2EE projects developed by a sizeable team, or across multiple teams, a team lead must:

  • Use tools that can measure quality
  • Define a set of gates and artifacts derived from the tools
  • Stress accountability to deliver, monitor, and enforce the results

This article explains how incorporating these three tactics into your development strategy can ensure that your team consistently produces quality projects.

Importance of tools
Have you ever heard of a construction company attempting to build a house without a power saw, electric drill, or a tool as fundamental as a hammer? True, a house could be built without today’s new-fangled equipment, however, construction would take much longer, and the same level of quality would prove nearly impossible to achieve. You could build a hut with your bare hands, but you could build a mansion with the right tools.

Today’s developers are no different than a person attempting to build a house. The tools are essential to the developer, both for increasing productivity and for enhancing quality. The tools developers use must enable them to produce the highest quality code possible in the shortest amount of time, which means that today’s IDE is no longer simply a tool used to write, debug, and compile code. Instead, an IDE must help developers identify whether they are following proper coding conventions and known design patterns, if they are in compliance with industry standards such as Web services, if their code adheres to its contract, and if it performs per the requirements. In addition, when developers are not given the environments necessary to achieve continuous builds and automated testing, an IDE’s capabilities become even more important to ensuring the system’s quality.

Enter the Eclipse IDE, which provides built-in capabilities that, when used with several plug-ins, can aid in increasing the quality of both the codebase and the system. Eclipse is an open, extensible IDE built for anything and nothing in particular. Eclipse’s Java development environment is open source, free, and fully customizable. Eclipse both enables and promotes the addition of new capabilities via open source and commercially available custom-built plug-ins. By utilizing Eclipse, along with a key set of plug-ins illustrated in the Eclipse plug-in matrix shown in Figure 1, it is possible for a developer, and a team, to measure the quality of any J2EE- or Java-based system.

Figure 1. Eclipse plug-in matrix

Controlling the quality of a system is impossible if you cannot measure and monitor it. It is important to understand key areas in a system that warrant measurement. These areas include a system’s maintainability, reliability, and performance. While this list is obviously not all-inclusive, these three items are highly suited as the basic building blocks for ensuring the quality of a system.

Maintainability involves the complexity associated with understanding the code or modifying the code, whether it is a bug fix or an enhancement. Well-documented code that follows known coding standards and industry design standards is easier to maintain than code with sparse documentation that doesn’t follow any known standard development practices. Highly maintainable code allows changes to be introduced more quickly, thereby permitting the business to respond more rapidly to new requirements or change requests, and ultimately reducing the overall cost of both new features and ongoing maintenance.

Reliability indicates whether a method adheres to its contract and can be executed successfully. Unit tests are used to exercise a method’s contract, thus verifying the reliability of the code segment. The quality of the unit tests, in turn, is verified via code coverage analysis. Many approaches are available for measuring code coverage, including, but not limited to, statement, decision, condition, path, and call analysis. The type and amount of coverage necessary to provide absolute reliability of a method is a popular discussion topic. For this article’s purpose, simply note that reliability increases as the amount of code coverage increases.

Method reliability within a system is of the utmost importance as it represents, to some extent, a system’s stability. Other problems, such as performance or scalability issues, could arise, which may not be as readily found even with extensive unit testing and coverage analysis. Thus, unit testing and coverage analysis are by no means a be-all, end-all solution to ensuring system stability; however, the ability to reliably execute methods consistently represents a good measuring stick of the system’s reliability.

Performance is typically measured on a per-unit-of-time basis. A system’s ability to process numerous requests, to the amount of information sent over the wire, to the response time of a particular system call, are all performance criteria measured based on a unit of time. It is important to know, to some extent, how the system will perform. To ensure this understanding, one could measure all major service methods or potential problem areas with expected high usages, long call stacks, or those pieces that represent the most common paths through the core architecture. Each approach provides a varying level of comfort with regard to performance. For large-scale systems, performance should be continually maintained and monitored during development to identify snags early and avoid unforeseen problems in production environments.

Let’s now examine how the use of Eclipse and its plug-ins can help a development team, measure the maintainability, reliability, and performance of any Java- or J2EE-based system.

Code generation: Maintainability
Code generation is one of the best ways to ensure consistency and quality for repeatable code that differs based on type. XDoclet is currently the industry standard for generating Java source code. XDoclet is an open source, free library that parses the codebase, looking for custom Javadoc tags (metadata) that it then uses to generate other Java source files. XDoclet contains a set of Javadoc tags that may be used to generate most of the repeatable code found in the majority of Java/J2EE-based systems, such as JavaBeans and home and remote classes for Enterprise JavaBeans, even providing specific information for Borland Enterprise Server, JBoss, Orion, Resin, Sun Java System Application Server, WebLogic, and WebSphere. It also supports many other technologies such as Hibernate, JDO (Java Data Objects), and Castor. If that isn’t enough, XDoclet is extensible, allowing developers to create their own custom tags for generating homegrown code. By employing XDoclet and letting it generate code for you, you can reduce unnecessary coding errors and bugs found in repetitive code.

Code metrics: Maintainability
Due to the large size of codebases, visually monitoring the entire codebase is unachievable. Instead of walking through every line of code, metrics may be used to identify both existing and potential problems. The Metrics plug-in for Eclipse is an open source, free tool that can generate metrics on a per-class, per-package, or per-project level. The results may be exported to an XML file for historical purposes. It also contains an Ant task that can be used to generate the XML file at build time.

The Metrics Eclipse plug-in provides more than 23 types of metrics. Some of the most important metrics include number of interfaces, depth inheritance tree, number of overridden methods, McCabe’s cyclomatic complexity, afferent coupling, efferent coupling, and abstractness. By default, the Metrics view displays the compliant metrics in blue and the outliers in red. Anything in red represents a possible problem in the code that should be reviewed. The plug-in has its own view and runs in the background; thus, it can not only be used by a team lead at the end of an iteration, but also by developers as they code.

Code reviews: Maintainability
A code review is a useful exercise that helps ensure code quality, while also training and mentoring developers on coding style and coding best practices. Jupiter is an open source, free tool that allows team-based code reviews. Jupiter uses XML files to track individual team member reviews with a review ID and a reviewer ID (the review ID is shared for team-based reviews). These files are then checked into source control and made available to other developers, allowing for multiple reviews to occur simultaneously, without a server managing the reviews.

Each team member uses an XML file to check in and out of source control and see what needs fixing as well as what has been fixed by other team members. The use of Jupiter is a great way to tag required fixes without enduring the rigor that normally surrounds bug-tracking policies during new development. Jupiter frees team members to review code at their convenience, instead of forcing them to stop development at a time when they might be solving a problem to attend a code review meeting.

Standards adherence: Maintainability
Development standards exist to ensure past mistakes are not repeated. In addition, they ensure the code is consistent and more readable for the developer who must later maintain the code. Eclipse comes with a built-in code formatter that adheres to Java coding conventions. While this is a great feature, a code formatter is not enough to ensure the production of quality code.

Checkstyle builds upon Eclipse’s code-formatting capabilities, adding more than syntactical checks. It can identify noncompliant code blocks, coding problems, duplicate code, and some metrics violations. Even better, Checkstyle is extremely customizable, allowing the user to tailor the types of checks and their level of severity per the development standards within the organization. The default configuration file that comes with the Checkstyle plug-in is extremely comprehensive. Even so, I suggest developers invest their own time to customize this plug-in to match their organization’s development needs. Once customized, the Checkstyle configurations may be exported and used from project to project. The results of Checkstyle are displayed in the Problems view, which may be filtered and sorted. Results may be viewed at the folder, working-set, or resource (file) level, allowing developers to understand the quality of the overall codebase, subsystem, or individual class.

If your team is engaged in Web services development, then WSVT (Web Services Validation Tools) is a must-have plug-in. WSVT can determine if a Web service conforms to the guidelines and requirements defined in the WS-I (Web Services Interoperability) Basic Profile. Developers can right-click on a WSDL (Web Services Description Language) file, and it validates the WSDL and generates a report in a custom view that displays any violations. As an added bonus, the WSVT plug-in monitors TCP/IP traffic and observes, captures, and validates SOAP messages. The WSVT plug-in thus ensures compliance both at the interface and message level.

Functional testing: Reliability
Eclipse ships with both Ant and JUnit. Ant is the de facto industry standard for building Java-based applications. JUnit is a Java-based framework for creating unit tests.

Developers can set up individual JUnit tests to run in Eclipse, which provides a special view for the JUnit results, or use the Ant JUnit or JUnitReport task. The JUnitReport Ant task generates an HTML viewable report that may be used to represent the entire system’s tests, or specific tests, depending upon the customization. The HTML report is an excellent report to save for historical purposes as it can be used to gauge the project’s quality. By using JUnit for unit testing, developers can ensure their methods adhere to their contract, thus avoiding bugs that arise due to noncompliance.

Code coverage: Reliability
When developers write unit tests, they should understand how much codebase coverage their unit tests provide. GroboCodeCoverage is an open source coverage tool that integrates with Ant by providing an Ant task that can generate coverage reports. Individual reports may be generated, such as the Line Count Report and Function Count Report, which provide coverage percentages at the line and method level, respectively. However, the cornerstone of the tool is its Source Summary Coverage Report. This report mimics the Javadoc structure and provides a quality professional report that may be stored for historical purposes. As the project progresses, the report can be referenced to understand whether code coverage increases or decreases over time. By using GroboCodeCoverage, developers can ensure their most critical code pieces are fully exercised and pinpoint areas that lack coverage. Using this information, they may add or update existing JUnit tests, thus increasing system reliability.

Profiler: Performance
As projects near the end of the construction phase, developers tend to start thinking more about performance. Profiler for Eclipse is an open source, free profiler that provides many of the features that a developer needs for solving common performance issues. It shows the threads, the heap size, heap dump, method calls, method times, calls per package, and thread call-trees that allow a developer to see where time was spent through the flow of a call. Profiler for Eclipse helps developers understand where the application’s bottlenecks are occurring, allowing them to correct problems before releasing the application to the QA (quality assurance) department or production.

Next page >

《I Love Lucene》总结

一月 18, 2005

前几天看到了TheServerSide上面的一篇文章I Love Lucene,感到对自己很有帮助,稍微总结了一下理理思路。

I Love Lucene

by Dion Almaer January 2005

Introduction

简要介绍了TheServerSite原来使用的搜索的方案,并由此引出Lucene

High level infrastructure

从高层介绍Lucene的方案,这一方案主要分成了两大部分,一部分是建立索引,另一部分是对索引进行搜索。分别介绍了这两部分的主要的接口IndexBuilderIndexSearch

Building the Index: Details of the index building process

全文最重要的一个组成部分。该部分介绍了以下四个内容:

1. 应该索引的字段

2. 索引的方式:增量索引、批量索引

3. 索引源的类型

4. 索引结果的rank

What fields should compromise our index?

讲了一下不同的索引字段使用的数据类型的问题

What types of indexing?

采用了增量索引和批量索引结合的方式,定义了一个增量索引的间隔,每隔这一间隔进行一次批量索引,在间隔内的时间内进行增量索引。同时还介绍了一下Lucene中如何删除索引记录。

What to index?

ThreadIndexSource

介绍对不同的索引源索引的问题,如对数据库中的数据索引以及对文件系统中的文件的索引。还介绍了一下索引TheServerSide的论坛中的帖子时引出的一个小技巧。

How to tweak the ranking of records?

对不同的字段赋以不同的权值来对一个文档进行较合理的rank

Searching the index

Lucene的使用主要看来是建立索引比较复杂,搜索索引极其简单,这里稍微花了一点篇幅就讲清了都,主要介绍了IndexSearch类中的search方法和查询解析类CustomQueryParser

Configuration: One place to rule them all

这部分主要介绍如何使用XML文件对搜索中的一些参数(如索引存放位置、字段权值等)进行动态配置,和Lucene其实没什么关系,主要还是说的是IoC(控制反转)的东西,讲了一下Apache Digester的使用。

XML Configuration File

Digester Rules File

Web Tier: TheSeeeeeeeeeeeerverSide?

用户搜索使用的Web界面,MVC结构。

SearchAssembler Web Action

根据用户输入构造查询语句,并讲查询语句交给IndexSearch处理,同时还负责封装查询结果。

Search View

表示层使用JSP ( for legacy reason)。根据TheServerSide上面的帖子回复,似乎说TheServerSide以后要用ApacheTapestry

Conclusion

总结,就是说Lucene很好。

下文涵盖了所有Servlet的部署描述符文件web.xml中各个元素的含义。

web.xml Deployment Descriptor Elements

下文讲述了如何创建一个Tag Library描述符的步骤以及Tag Library描述符中各个元素的含义。

Creating a Tag Library Descriptor

The following sections describe how to create a tag library descriptor (TLD) file:

下一页 »