Posted by puras | Posted in jQuery | Posted on 13-07-2010
在项目中,遇到了一个需求,是按照要求来隐藏table中的某一列,
写了一个小的例子程序,来演示这个功能:
<script language="javascript">
var bVisible = true;
function DisplayColumn(nCol) {
var rows = document.all("tbl").rows;
for (var i=0; i < rows.length; i++)
if (rows[i].cells.length > nCol)
rows[i].cells[nCol].style.display = bVisible ? "none" : "";
bVisible = !bVisible ;
}
</script>
<table id="tbl" border="1" cellspacing="0" cellpaddin="0">
<thead><th>head 1</th><th>head 2</th><th>head 3</th></thead>
<tbody>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
</tbody>
</table>
<input type="button" value="Show/Hide Column 2" onclick="DisplayColumn(1);">
使用jQuery来实现,很容易……
Posted by puras | Posted in Java, Spring | Posted on 12-05-2010
在Sping的MVC中,如果想要使用REST式的URL,
需要对URLMapping对行如下设置:
oem-portal
/
由于这种设置,会对所有的URL请求进行处理,
那么静态文件,比如说图片,CSS文件,或是JS文件,
也会经由这个Servlet,那样就会出现找不到文件的情况,
怎么处理呢?
这里提供一种方式,对静态文件的URL进行重写,
利用一个Jetty、Tomcat等容器提供的一个默认的Servlet来处理:
default
/public/*
这样,就可以解决这个问题啦。
当然,不一定非要使用这个Servlet,
其他的方式也可以,比如说URLRewrite等也可以。
Posted by puras | Posted in Java, iBatis | Posted on 29-04-2010
iBatis3已经发布了,
但是Spring3却没有相应的ORM包,
在网上查了一下,
发现有人已经为Spring3增加了这一部分的功能,
使iBatis3可以在通过Spring3来管理和使用,
下载此Jar包 ,并将其放到你的classpath中,
之后在Spring的配置文件中,进行如下配置:
classpath:conf/spring/jdbc.properties
其中,jdbc.properties是数据库的配置文件:
database.driver=com.mysql.jdbc.Driver
database.password=123456
database.url=jdbc\:mysql\://localhost/oem
database.username=puras
配置好DataSource之后,接下来则需要配置iBatis的相关文件了,
首先是ibatis-config.xml:
这里添加了一个Mapper,下面是User_mapper.xml的内容:
这里没有像iBatis2中那么多的配置,
只有一个mapper,
而namespace则是必须要写的,
下面再来看看UserMapper,你会发现,与iBatis2的区别:
/*******************************************************************************
* @(#)UserMapper.java 2010-4-28
*
* Copyright 2010 Neusoft Group Ltd. All rights reserved.
* Neusoft PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*******************************************************************************/
package org.mooko.yushu.persistence.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Select;
import org.mooko.yushu.domain.user.User;
/**
* @author Puras.He
* @version $Revision 1.1 $ 2010-4-28 下午03:49:28
*/
public interface UserMapper {
@Select("select id, email, passwd, created_at as createdAt, updated_at as updatedAt from user where email=#{email} and passwd=#{passwd}")
User getUser(User user);
@Select("select * from user")
List getUsers();
}
看到了么?以前在XML中的SQL语句,全部在Java中通过注解的方式来实现了
现在需要做的,就是在Spring中声明这个Mapper了,
再将这个Mapper注入到Service中:
这样,你就可以在Service中使用这个Mapper了。
PS:厌烦了XML的配置,
现在换成注解的方式来写SQL,
是不是有种不一样的感觉呢?
Posted by puras | Posted in Play! Framework, 技海拾贝 | Posted on 20-04-2010
之前的文章里提到了,
Play!中提供的GAE命令,
使用的是appcfg.sh,
从而导致在Windows的系统里,
无法使用这个命令来进行提交,
虽然之前按照比较土的方式,
也提交成功了,
但是无法借助Play!提供的命令,
还是让人颇为不爽的,
查看了一下命令的代码,
发现要让其在Windows下运行,
还是蛮容易的,
废话了这么多,
其实真正有用的,仅仅是一句话,
哈。
打开%PLAY_HOME%/modules/gae-path/commands.py这个文件,
找到os.system(‘%s/bin/appcfg.sh update %s’ % (gae_path, war_path))这一行,
将其修改为os.system(‘%s/bin/appcfg.cmd update %s’ % (gae_path, war_path))
保存,之后你再运行
play gae:deploy
你会发现,应用成功的上传咧,
O了,问题解决!
Posted by puras | Posted in Play! Framework, 技海拾贝 | Posted on 19-04-2010
在开发Play!应用的时候,
经常会使用到Module,
这时可能会遇到无法找到Module中的类的情况,
因为什么呢?
哈,是因为类路径设置的有问题,
不过Play!做的还是蛮不错的,
你只需要重新执行一下:play eclipsify myApp
之后再在Eclipse中刷新一下,
你会发现,相应的Module已经被链接到应用中了,
这样你再使用Module中的类,
就不会有编译错误啦!
嗯呐
Posted by puras | Posted in Java, 技海拾贝 | Posted on 19-04-2010
SiteMesh自身可以扩展来支持XML、WML、PDF等格式的文件。但是SiteMesh本身仅实现了HTML装饰的功能。如果要在WML中使用SiteMesh,需要自己来进行扩展。
下面是用SiteMesh来装饰WML页面的步骤:
1、扩展SiteMesh,下载此Jar包(稍后提供,公司不能上传文件);
2、修改应用的WEB-INF下的sitemesh.xml文件:
在 下增加一行对WML的解析器的设置:
这样,SiteMesh就可以解析WML的页面了。
Posted by puras | Posted in CodeIgniter, PHP, 技海拾贝 | Posted on 14-04-2010
/admin/controller/id // instead of /controller/admin/id
/admin/controller/create // instead of /controller/create
/admin/controller/detail/id // instead of /controller/detail/id
/admin/controller/update/id // instead of /controller/update/id
/admin/controller/delete/id // instead of /controller/delete/id
My current routes work perfectly for detail, create, update, delete
$route['admin/(:any)/detail'] = “$1/detail”; // WORKS!!!
$route['admin/(:any)/detail/(:num)'] = “$1/detail/$2″; // WORKS!!!
$route['admin/(:any)/create'] = “$1/create”; // WORKS!!!
$route['admin/(:any)/create/(:num)'] = “$1/create/$2″; // WORKS!!!
$route['admin/(:any)/update'] = “$1/update”; // WORKS!!!
$route['admin/(:any)/update/(:num)'] = “$1/update/$2″; // WORKS!!!
$route['admin/(:any)/delete'] = “$1/delete”; // WORKS!!!
$route['admin/(:any)/delete/(:num)'] = “$1/delete/$2″; // WORKS!!!
Posted by puras | Posted in Play! Framework, 技海拾贝 | Posted on 13-04-2010
Play!Framework提供了对Google App Engine应用开发的支持,
要使用它开发GAE程序,首先要做的就是下载GAE的Module,
可以使用play install gae来进行安装,
当然,你也可以从官网下载GAE的压缩包,
自己手动的解压,放到Play的modules目录下,
安装好Module之后,
则是配置应用了,
修改应用的application.conf文件,在文件中添加
module.gae=${play.path}/modules/gae-1.0.2
(注意:这里写的是GAE的Module的路径,如果你的路径带版本号,不要少写了)
之后执行一下
play run
它会在你的war文件夹中,生成一个application-web.xml文件,
这里需要提醒的是,在开发的时候,没有什么问题,但是当你提交到GAE之前,
一定要记得修改application-web.xml文件,将你的GAE的应用ID添加进去。
之后说的便是部署应用了,
我试了一下,发现Play1.0.2中带的开发命令,
会默认调用appcfg.sh,而这个在Win中是无法执行的,
没办法,只能按照Play1.0的方法进行部署了。
先进行WAR的生成:
play war app -o app.war
之后使用app engine的命令来提交应用,这个就和正常的app engine开发一样了
appcfg update app.war
O了!
PS:不知道为什么老外写的东西,都不喜欢支持Win呢?
看来以后真的换系统了,呼~~~~~
Posted by puras | Posted in 技海拾贝 | Posted on 09-04-2010
Play!框架,可使用命令生成Eclipse配置文件,从而使用Eclipse来开发Play!
步骤:
1、play new app
创建Play!应用
2、play eclipsify app
生成Eclipse配置文件
3、在Eclipse中,导入应用,选择刚创建的app
4、通过app下的Eclipse文件夹中的配置文件,可在Eclipse中启动app应用
这里有个需要注意的地方,在创建应用的时候,Play!会提示输入应用名,这里需要使用同play new app,这行命令中同样的名称,否则在Eclipse启动时,会遇到麻烦。
PS:如果需要使用Eclipse插件,将Play_Home/support/eclipse/下的Jar包,复制到Eclipse_Home/dropins下,启动Eclipse后,你就会看到菜单栏上的Play!啦。
Posted by puras | Posted in 代码展示, 技海拾贝 | Posted on 09-04-2010
jQuery的Tiper是一个非常轻量级的jQuery工具提示,可以指定任何元素素作为工具提示。
整段代码直接贴:
Div With Tooltip
Link With Tooltip
This is some content
This is some content. This is some content. This is some content.
This is some content. This is some content. This is some content.
This is some content. This is some content. This is some content.
This is some content. This is some content. This is some content.
An image :

Here is some text with some
tooltips withing
An Iframe :
Here is a tooltip
Here is a tooltip
查看演示
点击下载