客户的不断变更是我提高技术的动力!
实现了一个浏览回复帖的功能,回复的信息也可以回复,只要在servlet给他返回html代码了,幸好不是太麻烦。
首先是页面部分,包括了很多struts标签
<div class="left_box">
<logic:empty name="infoBean" property="infoList">
对不起,没有您想要的记录!
</logic:empty>
<logic:iterate id="info" name="infoBean" property="infoList">
<fieldset>
<table cellspacing="1" width="100%" border="1">
<tr>
<td rowspan="4" width="70">
<logic:match name="info" property="tpye" value="A">
货源信息
</logic:match>
<logic:match name="info" property="tpye" value="B">
车源信息
</logic:match>
<logic:match name="info" property="tpye" value="C">
其它信息
</logic:match>
<br/>
<img id="<bean:write name='info' property='lnid'/>" src="images/plus.gif" onClick="openList(this.id);"/>信息号<bean:write name="info" property="lnid"/><br/>
<a href="../front/infoReplayForm.shtml?pnid=<bean:write name='info' property='lnid'/>">留言</a>
</td>
<td rowspan="2" width="500" valign="top">
<bean:write name="info" property="sdty"/>
<bean:write name="info" property="nmbr"/><bean:write name="info" property="uom"/>
有效天数:<bean:write name="info" property="dkco"/>
<bean:write name="info" property="dsc"/>
</td>
<td width="80">发布公司:</td>
<td><bean:write name="info" property="dkco"/> </td>
</tr>
<tr>
<td>发布人:</td>
<td><bean:write name="info" property="bcusr"/> </td>
</tr>
<tr>
<td>起始地:<bean:write name="info" property="adss"/> <bean:write name="info" property="adssn"/></td>
<td>联系方式:</td>
<td><bean:write name="info" property="rltv"/> </td>
</tr>
<tr>
<td>终止地:<bean:write name="info" property="adse"/> <bean:write name="info" property="adsen"/></td>
<td>发布时间:</td>
<td><bean:write name="info" property="bcdat" format="yyyy-MM-dd"/> </td>
</tr>
<tbody id="s<bean:write name='info' property='lnid'/>"></tbody>
</table>
</fieldset>
</logic:iterate>
<logic:notEmpty name="infoBean" property="infoList">
<fieldset>
<table cellspacing="1" width="100%">
<tr><td><cochang:paginate name="infoBean" list="infoList"/></td></tr>
</table>
</fieldset>
</logic:notEmpty>
</div>
然后是javascript部分,比较简单,一是需要把加号替换一下,再就是请求servlet返回html代码填充到tbody中
function openList(id) {
var image = document.getElementById(id);
var imagesrc = image.src;
if(imagesrc.indexOf("plus")>0){
image.src="images/nofollow.gif";
var params = "id=" + id;
var url = '../fore/infoServlet';
var myAjax = new Ajax.Updater('s'+id, url, {method: 'get', parameters: params});
}else if(imagesrc.indexOf("nofollow")>0){
image.src="images/plus.gif";
$('s'+id).innerText="";
}
}
下面是servlet部分,一口气代码全部贴上。
public class InfoServlet extends BaseAjaxServlet {
InfoService infoService;
public void init() throws ServletException {
super.init();
this.infoService = (InfoService)CustomBeanFactory.getBean("infoService");
}
public String performTask(HttpServletRequest request, HttpServletResponse response) {
String id = request.getParameter("id");
String result = " 可能发生错误,请与管理员联系!";
if(!id.equalsIgnoreCase("")){
result = searchInfo(id);
}
return result;
}
public String searchInfo(String id) {
List infos = infoService.searchByPnid(id);
Info info = new Info();
StringBuffer string = new StringBuffer(200);
if(infos.size() == 0) {
return " 没有任何留言!";
}
string.append(" ");
for(int i=0;i<infos.size();i++) {
info = (Info)infos.get(i);
string.append("<tr><td><img id='"+info.getLnid()+"' src='images/plus.gif' onClick='openList(this.id);'/><a href='../front/infoReplayForm.shtml?pnid="+info.getLnid()+"'>留言</a></td><td>");
string.append(info.getLnid());
string.append("</td><td>");
string.append(info.getDsc());
string.append("</td></tr><tbody id='s"+info.getLnid()+"'></tbody></td></tr>");
}
string.append("</table></td></tr>");
return string.toString();
}
}
最后还是一个效果图,视觉才是最直观的。
- 描述: 展开前效果
- 大小: 25.7 KB
- 描述: 展开后效果
- 大小: 24.3 KB
分享到:
相关推荐
这个demo实现了TableViewSection的展开隐藏功能,欢迎下载使用。
添加头部和尾部,点击展开或者隐藏item部分类容 添加头部和尾部,点击展开或者隐藏item部分类容 添加头部和尾部,点击展开或者隐藏item部分类容 添加头部和尾部,点击展开或者隐藏item部分类容 添加头部和尾部,点击...
一款很好用的右侧悬浮QQ在线客服代码,支持展开和隐藏QQ客服面板,可自由添加和修改QQ号码,支持IE和火狐浏览器,兼容性较好。 QQ号码添加方法:请到http://wp.qq.com/去生成链接代码后,替换掉原有的链接即可生效。
资源绝对能够运行,主要是实现了android项目中的listview展开与隐藏的效果,拓展了listview的功能。
代码实现ListView的Item点击展开隐藏项的三个效果:(1)单条目展开(2)多条目展开(3)复杂布局的展开示例。 注:个人学习代码,发现使用。
jQuery表格行展开隐藏代码是一款基于Bootstrap.js表格插件制作的table表格行展开收缩隐藏效果代码。
1.适合网络大数据列表分次展开和隐藏 2.支持文件中嵌套文件夹并可正常显示文件夹中数据
通过引用这个,可以实现页面的左侧区域点击后隐藏和展开功能
ListView点击展开,再次点击收起这样一个效果,同时,任何一个时刻都只允许一个ListView展开,展开后,里面的button等能够获得焦点并能响应其他事件的处理。
listview的item单项展开及隐藏
易语言鼠标移动按钮展开隐藏收缩特效源码。@⑧⑧⑧。 。
可以随便添加该功能模块的数量和规定显示的字数
由John Resig在2006年1月的BarCamp NYC上发布第一个版本。目前是由 Dave Methvin 领导的开发团队进行开发。全球前10000个访问最高的网站中,... 本实例展示了网页中最常见的菜单的展开与隐藏特效,适用于JQuery初学者。
CSS JS点击展开/隐藏的折叠菜单
点击展开、点击隐藏、可用于评论、点击显示回复、收起回复
简单实用可展开隐藏导航菜单按钮js特效代码下载。这款菜单的特点是点击按钮时可以展开菜单,展开的时候带有弹性的动画特效,效果相当酷。菜单项是一些小图标,当然你也可以使用图标结合文字的方式,由于隐藏/展开的...
展开收起隐藏行
代码片段: <th>Country <th>Population <th>Area <th>Official languages </thead>
Android列表单一展开隐藏View的SignalView,代码很简单,分享给大家
QFD介绍、浅谈 质量功能展开QFD(Quality Function Deployment)是把顾客或市场的要求转化为设计要求、零部件特性、工艺要求、生产要求的多层次演绎分析方法。