dwr a ajax 提交,ajax – Does Java offer a timestamp??…..DWR – Stack Overflow

dwr a ajax 提交,ajax – Does Java offer a timestamp??…..DWR – Stack OverflowImusingDWR,whichimfairlynewto…IusingajaxtosubmitacommenttothepageandIgotrequesttoseeIficanshowatmestampwhenthecommentissubmitted:Inanutshell—Thebeanhasavaria…

大家好,又见面了,我是你们的朋友全栈君。

Im using DWR, which im fairly new to…I using ajax to submit a comment to the page and I got request to see If i can show a tmestamp when the comment is submitted:

In a nutshell—The bean has a variable called auditable…which doesnt get populated with a timestamp until it hits the database. Thats fine. My question…can I pass something to auditable on the fly with ajax that is a sort of “timestamp” to pass back to the page????

Thanx in advance!!!!

heres the code:

JSP

You have ${const[‘COMMENT_MAX_LENGTH’] – fn:length(commentForm.comment)} characters left.

οnkeypress=”characterCounter(‘commentsCounter’,${const[‘COMMENT_MAX_LENGTH’]}, this)”

οnkeydοwn=”characterCounter(‘commentsCounter’,${const[‘COMMENT_MAX_LENGTH’]}, this)”

οnkeyup=”characterCounter(‘commentsCounter’,${const[‘COMMENT_MAX_LENGTH’]}, this)”>

Add

DWR JAVASCRIPT:

function addComment()

{

$(“#commentErrors”).css(“visibility”, “hidden”);

var obj = {comment:null};

WhatIfDataAction.addComment(dwr.util.getValues(obj),

{

callback:addCommentCallback,

timeout:60000,

exceptionHandler:function(msg, e)

{

alert(“Error submitting form. ” + msg);

}

}

);

}

function addCommentCallback( comment )

{

if (comment.messages.length > 0)

{

//Convert the error messages into an HTML string.

var html = “”;

for (var i = 0; i < comment.messages.length; i++)

{

html += “

” + comment.messages[i] + “”;

}

$(“#commentErrors”).html(html);

$(“#commentErrors”).css(“visibility”, “visible”);

}

else

{

// Build HTML for new row.

var html = “

” + comment.comment + “” +

” + comment.id + “” +

“; // three empty TDs for the three actuals fields

$(“#commentRow”).before(html);

WHATIFDATAACTION.JAVA:

public CommentForm addComment(Map properties) throws Exception

{

CommentForm form = new CommentForm(properties);

if (form.validate(this))

{

CommentBean bean = form.toBean();

EntryBean entry = WhatifCache.fetchEntryFromCache(getSession());

entry.addComment(bean);

form.setId(bean.getId());

bean = form.toBean();

}

return form;

}

And finally…commentBean:

public final class CommentBean

extends AbstractBean

implements Auditable,

BeanCache.CacheableBean

{

private long id;

private long entryId;

private String comment;

private AuditableBean auditable;

/** Description character max length, matches size of description field in db **/

public static final Integer COMMENT_MAX_LENGTH = 250;

public CommentBean()

{

}

@Override

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

{

id = in.readLong();

entryId = in.readLong();

comment = in.readUTF();

auditable = (AuditableBean)in.readObject();

}

@Override

public void writeExternal(ObjectOutput out) throws IOException

{

out.writeLong(id);

out.writeLong(entryId);

out.writeUTF((comment == null) ? “” : comment);

out.writeObject( auditable );

}

@Override

public void readSQL(SQLInput in, String typeName) throws SQLException

{

id = in.readLong();

entryId = in.readLong();

comment = in.readString();

auditable = (AuditableBean)in.readObject();

}

@Override

public void writeSQL(SQLOutput out) throws SQLException

{

out.writeLong(id);

out.writeLong(entryId);

out.writeString(comment);

out.writeObject( auditable );

}

public long getId()

{

return id;

}

public void setId(long id)

{

this.id = id;

}

public long getEntryId()

{

return entryId;

}

public void setEntryId(long entryId)

{

this.entryId = entryId;

}

public String getComment()

{

return comment;

}

public void setComment(String comment)

{

this.comment = comment;

}

public AuditableBean getAuditable()

{

return auditable;

}

public void setAuditable(AuditableBean bean)

{

auditable = bean;

}

public boolean isActive()

{

return true;

}

public String getKey()

{

return “”+id;

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/150671.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 【已解决】Win10系统点击ikbc机械键盘win键无效的解决方法

    【已解决】Win10系统点击ikbc机械键盘win键无效的解决方法一、问题描述今天周一,早上一来上班,打开电脑操作一段时间后,我想按Win+L来锁屏,发现win键按了没有任何反应,只响应了L键。设备信息描述一下:系统:Windows10键盘:ikbc怎么解决它呢?二、解决问题ikbc键盘win按键失灵问题。其实是自己不小心把win键给锁定了。下面是介绍一下ikbc键盘上,锁定win键和解锁win键的方法,如下表所示:键盘款式锁定的方法解锁的方法非静音款Fn+左WinFn+右Win静音款Fn+F12F

    2022年6月1日
    151
  • 计算机组成原理期末复习【超实用】「建议收藏」

    计算机组成原理期末复习【超实用】「建议收藏」计算机组成原理(第二版)唐朔飞编著(课本有些地方还不错,可以下载电子版看看)五道解答题30‘=9’(9个知识点)+6’+6’+4’+5’我依据老师的考题范围手动整理,有什么问题or想添加的知识点请在评论下方留言!实时更新,助诸位共进步!一、解答题1.影响流水线性能的因素主要有哪几种?请简要加以说明。P348结构相关:是当多条指令进入流水线后,硬件资源满足不了指令…

    2022年5月31日
    37
  • 大疆网上测评题库_【大疆在线测试有几套题啊?】-看准网

    大疆网上测评题库_【大疆在线测试有几套题啊?】-看准网写面经,攒人品。大疆服务运营培训生。1.大疆网上笔试题(比较独创,很有趣,也有歇跟大疆相关的题,要比较熟悉大疆),笔试过后,有岗位笔试作业。2.大疆服务运营培训生笔试作业题目。三道大题,开放性题目,专业和岗位相关,涉及报告类题目。规定期限内提交,审核,通过后进入面试环节。3.一面,微信视频面试。提前约定时间,到点准时打来,直奔主题。自我介绍,针对个人经历开始提问,最后会用英文简单问答一下看英语能力…

    2022年6月18日
    66
  • 测试用例编写_根据接口文档生成测试用例

    测试用例编写_根据接口文档生成测试用例前言写用例之前,我们应该熟悉API的详细信息。建议使用抓包工具Charles或AnyProxy进行抓包。har2case我们先来了解一下另一个项目har2case他的工作原理就是将当前主流的抓

    2022年7月30日
    8
  • 寄存器,移位寄存器的电路原理以及verilog代码实现「建议收藏」

    寄存器,移位寄存器的电路原理以及verilog代码实现「建议收藏」寄存器:用以存放二进制代码的电路,下图为由维特阻塞D触发器组成的4位数码寄存器:逻辑功能分析:1.异步端CR置0时,输出置0;2.同步并行置数:D0~D3为4个输入代码,当CP上升沿到达时,D0

    2022年7月1日
    99
  • ideavim怎么用_idea基本使用教程

    ideavim怎么用_idea基本使用教程ideavim使用分享ideavim使用ideavim介绍ideavim是JetBrains官方开发的模拟vim插件,熟练ideavim的人可以更快的进行操作,大部分操作都可以用键盘来代替。纯vim也能进行更高效的开发,但是一款适合自己深定义的配置,能够让人更加高效。配合ide的智能补全,就一个字爽ideavim的安装idea中自带的插件管理搜索ideavim然后选择安装macos打开idea配置cmd+,windows打开idea配置ctrl+shfit+s

    2022年10月1日
    4

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号