首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 数据库 第二书店 程序员

Tag/ 


共5478个网摘 [ 1  2  3  4  5  6 ... 183 ]  下一页  |  

简约之美,JQuery之进度条插件

villa123收录,使用标签:Java,时间:2008-7-4 17:04:56 | 相关网摘我也收藏

JQuery Progress Bar是基于JQuery开发的进度条插件,秉承了JQuery的简约哲学。不仅容易使用,而且可以轻松定制外观。对于使用了JQuery框架的项目来说,需要使用进度条控件时这是一个不错的选择。

JQuery Progress Bar与常规插件一样,只要用选择器选择一个HTML元素后,直接调用插件的公开方法即可。它提供的公开方法名称为progressBar()。那么,当HTML页面上有一个id为progress1的元素时,可以这样初始化该控件:

$("#progress1").progressBar();

它的构造函数可以接收如下表所示的参数。


方法及参数 用途 progressBar() 按默认设置初始化一个进度条 progressBar(persent) 按默认设置初始化或更新一个进度条,设置进度条的百分比至persent%. progressBar(config) 按config中指定的设置初始化一个进度条,百分比为0%。注意不要在初始化之后使用该方法来更改进度条的设置,否则可能引起显示不正常。 progressBar(persent,config) 按config中指定的设置初始化一个进度条,百分比为persent%。注意不要在初始化之后使用该方法来更改进度条的设置,否则可能引起显示不正常。

其中,config参数是一个哈希结构对象,它包含了如下属性用于设置进度条的外观特性
属性
用途

increment
设置进度条每步的增长度。默认值为2。

speed
设置进度条初始化时动态滑动效果的速度。默认值为15。这个值越大,则滑动速度越慢。

showText
设置是否显示百分比标识文字。默认值为ture,即显示百分比文字标识。

boxImage
设置边框图片。默认值为images/progressbar.gif。如需定制边框,则修改该属性,指向要使用的图片即可。

barImage
设置进度标识图片。默认值为images/progressbg_green.gif。如需定制,则修改该属性,指向要使用的图片即可。这个图片分类两节,前半节用于标识完成进度,后半截用于标识剩余未完成进度。两节长度相等,且等于进度条的宽度。

width
设置进度条的宽度,这个值必须与barImage和boxImage所指向的图片相适应。默认值为120。

height
设置进度条的高度,这个值必须与barImage和boxImage所指向的图片相适应。默认值为12。


与服务器的交互就不在这里讲了,就只是使用ajax从服务器获取进度值,然后用progressBar(persent)更新进度即可。


jquery和prototype冲突解决

villa123收录,使用标签:Java,时间:2008-7-4 17:01:33 | 相关网摘我也收藏

问题背景: 想用 jQuery 做 AJAX 处理, 用基于 Prototype 的 EasyValidation 做表单验证, 但是二者不能共存, 因为都用了同一个方法名: $().

解决:

jquery和prototype冲突解决, 网上流传的一篇文章,我这里测试结果是错误的! http://ajaxbbs.net/blog/post/71/

另一种方式是:

jQuery.noConflict();


参考: http://www.d5s.cn/archives/6, 但我这里测试也有问题!

本人测试通过的方式:

1、将jquery.js放到prototype.js前面(这个是必须的!)。
2、在jquery.js后面将$变量重命名。
方法如下:



var jQuery=$;






3、将原来使用的$方法名一律替换为jQuery名,如$("obj")替换为jQuery("obj")。

例如下面的一段代码, 混合了 jQuery和基于Prototype的 EasyValidation:




var jQuery=$;










jQuery(document).ready(function(){
//jQuery("#contents").load("test.jsp");
jQuery("#contents").load("test.jsp?username=BeanSoft")
});




*密码:


*密码(重复):







spring学习资料和知识库集锦

villa123收录,使用标签:Java,时间:2008-7-4 16:56:19 | 相关网摘我也收藏

下面是本人学习使用spring到现在的一些资料和经验,希望对某些朋友有用。

1。学习资料部分

1。1 强烈建议学习spring下载包中doc目录下的MVC-step-by-step。sample目录下的例子也都是比较好的spring开发的例子。
1。2 appfuse:我刚刚开始学习的时候就是使用appfuse的,可以帮助快速建立项目。集成了目前最流行的几个开源轻量级框架或者工具Ant,XDoclet,Spring,Hibernate(iBATIS),JUnit,Cactus,StrutsTestCase,JSTL,Struts等。
AppFuse网站:http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuse
1.3 Spring 开发指南(夏昕)(http://www.xiaxin.net/Spring_Dev_Guide.rar)
入门书籍,里面简单介绍了反转控制和依赖注射的概念,以及spring的bean管理,spring的MVC,spring和hibernte,iBatis的结合。对于入门者来说,还是很有用的。
1.4 spring学习的中文论坛
SpringFramework中文论坛(http://spring.jactiongroup.net) 。
JavaRead开源网站(http://www.javaread.com/question/list)的问答栏目,注册简单,问题回复挺快的。
Java视线论坛(http://forum.javaeye.com)的spring栏目,有问题的讨论。
1.5 深度学习:基本掌握之后,这两本书你该去看看。这两本书是由Spring的作者Rod Johnson编写的。
Expert One on one J2EE Design and Development
Expert One on one J2EE Development Without EJB
1.6 加把劲,再研究研究spring的文档。
http://www.jactiongroup.net/reference/html/index.html

2. 知识库

2.1 如何在spring配置Quartz
配置如下:










详细可参考:http://www.javaread.com/article/show/69

2.2 在spring下怎么配置拦截器
dataSecurityAdvisor







.*get.*
.*create.*
.*update.*
.*delete.*



使用advice:在需要使用该拦截器的时候,在对应bean里添加一下代码即可。






2.3 Spring中如何实现事务管理
事务管理的控制应该放到商业逻辑层。
xml文件定义如下:
事务定制:




PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



service bean配置:








2.4 spring框架下,bean越来越多时,该如何管理
主要方法有二,
a)把bean分类,用不同的xml文件配置,再同时加载。
b)利用annotation新特性,简化配置。
更多信息:http://www.javaread.com/question/show/962.5 在spring中如何配置log4j
非常简单,在web.xml中加入以下代码即可。

log4jConfigLocation
/WEB-INF/log4j.properties





本文作者:javaread.com


dwr做comet的完整实现

villa123收录,使用标签:Java,时间:2008-7-4 16:55:46 | 相关网摘我也收藏

场景:页面comet.jsp接受服务器推送的信息并显示,页面action.jsp执行一个动作,调用DwrServer.perform方法,perform方法做某些事,并发送事件信息PerformInfo。NotifyClient监听事件,当接收到PerformInfo后,把PerformInfo的信息发送到comet.jsp页面。这个场景模拟了页面1执行了一个时间比较长或复杂的任务,任务执行情况可以反馈到页面2(比如模式窗口)。
信息载体PerformInfo.java
package application.comet;

import java.util.Date;

public class PerformInfo {
private int id;
private String msg;
private Date time;
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the msg
*/
public String getMsg() {
return msg;
}
/**
* @param msg the msg to set
*/
public void setMsg(String msg) {
this.msg = msg;
}
/**
* @return the time
*/
public Date getTime() {
return time;
}
/**
* @param time the time to set
*/
public void setTime(Date time) {
this.time = time;
}

}

package application.comet;

import java.util.Date;

public class PerformInfo {
private int id;
private String msg;
private Date time;
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the msg
*/
public String getMsg() {
return msg;
}
/**
* @param msg the msg to set
*/
public void setMsg(String msg) {
this.msg = msg;
}
/**
* @return the time
*/
public Date getTime() {
return time;
}
/**
* @param time the time to set
*/
public void setTime(Date time) {
this.time = time;
}

}
Spring的事件InfoEvent.java
package application.comet;

import org.springframework.context.ApplicationEvent;

public class InfoEvent extends ApplicationEvent {
public InfoEvent(Object source){
super(source);
}
}
DwrService.java 执行任务,就是写了100遍PerformInfo,需要实现ApplicationContextAware接口
package application.comet;

import java.util.Date;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent;

public class DwrService implements ApplicationContextAware{
private ApplicationContext ctx;
public void setApplicationContext(ApplicationContext ctx) {
this.ctx = ctx;
}
public void perform(){
for (int i=0;i<100;i++){
PerformInfo info = new PerformInfo();
info.setId(i);
info.setMsg("发送"+i+"信息");
info.setTime(new Date());
InfoEvent evt = new InfoEvent(info);
ctx.publishEvent(evt);
}
}

}

NotifyClient.java监听事件,发送信息到页面。实现ApplicationListener,ServletContextAware接口,对中文需要编码
package application.comet;

import java.io.UnsupportedEncodingException;
import java.util.Collection;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingEvent;
import org.springframework.web.context.ServletContextAware;
import org.directwebremoting.ScriptBuffer;
import org.directwebremoting.ScriptSession;
import org.directwebremoting.ServerContext;
import org.directwebremoting.ServerContextFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

public class NotifyClient implements ApplicationListener,ServletContextAware{
private ServletContext servletContext = null;
public void setServletContext( ServletContext servletContext )
{
this.servletContext = servletContext;
}

public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof InfoEvent) {
PerformInfo info = (PerformInfo)event.getSource();
System.out.println(info.getMsg());
//Collection sessions=ctx.getAllScriptSessions();
ServerContext ctx = ServerContextFactory.get(servletContext );
Collection sessions =
ctx.getScriptSessionsByPage("/dwrcomet/comet.jsp");
for (ScriptSession session : sessions) {
ScriptBuffer script = new ScriptBuffer();
String s=null;
String s2 = null;
try {
s = java.net.URLEncoder.encode(info.getMsg(),"UTF-8");
s2 = java.net.URLEncoder.encode("通知结束","UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
if (info.getId()<99){
script.appendScript("putInfo('")
.appendScript(info.getId()+":"+s)
.appendScript("');");
}else{
script.appendScript("alert(decodeURI('").
appendScript(s2).appendScript("'));");
}

System.out.println(script.toString());
session.addScript(script);
}
}
}

}

action.jsp执行任务
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String root = request.getContextPath();
%>




doing





网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
北京百联美达美数码科技有限公司 版权所有 京 ICP 证 020026 号
Copyright © 2000-2006, CSDN.NET, All Rights Reserved