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;

}

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

  • 程序心形曲线绘制_java输出心形图案

    程序心形曲线绘制_java输出心形图案代码如下:importjava.awt.Color;importjava.awt.Graphics;importjava.awt.Image;importjava.awt.Toolkit;importjavax.swing.JFrame;@SuppressWarnings(“serial”)publicclassDemoextendsJFrameimplementsRunna…

    2022年10月16日
  • 树莓派开发笔记(十):Qt读取ADC模拟量电压(ADS1115读取电压模拟量)

    树莓派开发笔记(十):Qt读取ADC模拟量电压(ADS1115读取电压模拟量)若该文为原创文章,未经允许不得转载原博主博客地址:https://blog.csdn.net/qq21497936本文章博客地址:https://blog.csdn.net/qq21497936/article/details/102524577目录前话Demo运行效果Demo:电压模拟量采集ADS1115实物特点引脚图与访问地址多个ADS1115连接(单级…

    2022年10月25日
  • python打开h5文件可视化_python环境变量的配置

    python打开h5文件可视化_python环境变量的配置我正在尝试用Python读取h5文件。该文件可以在thislink中找到,名为“vstoxx_data_31032014.h5”。我试图运行的代码来自YvesHilpisch的《PythonforFinance》一书,内容如下:importpandasaspdh5=pd.HDFStore(‘path…/vstoxx_data_31032014.h5′,’r’)futures…

  • 规范化理论:多值依赖的理解_依赖关联泛化实现

    规范化理论:多值依赖的理解_依赖关联泛化实现多值依赖的定义我们用一个例子来引出多值依赖(MultivaluedDependency,MVD)的含义。假设学校中一门课程可由多名教师讲授,教学中他们使用相同的一套参考书,这样我们可用下图的非规范化的关系来表示课程C、教师T和参考书B间的关系。关系CTB如果关系CIB转化成规范化的关系,如图所示。规范后的关系CTB由此可以看出,规范后的关系模式…

    2022年10月25日
  • Maven 常用镜像站地址

    Maven配置打开Maven的配置文件(windows机器一般在maven安装目录的conf/settings.xml),在<mirrors></mirrors>标签中添加mirror子节点:常用的镜像地址阿里云仓库(推荐使用,速度快)阿里云Maven中央仓库为阿里云云效提供的公共代理仓库,帮助研发人员提高研发生产效率,使用阿里云Maven中央仓…

  • MDK中hex转BIN文件生成「建议收藏」

    MDK中hex转BIN文件生成「建议收藏」MDK开发的技巧:1.使用fromelf.exe程序,将.hex或者.axf转化为.bin文件。2.利用.bat批处理文件,将.bin和.hex拷贝到需要的文件夹下。例如:E685工装中Run#1D:\Keil_v5\ARM\ARMCC\bin\fromelf.exe–bin-o./Debug/AppT081E685.bin./Debug/AppT081E685.axfR…

    2022年10月20日

发表回复

您的电子邮箱地址不会被公开。

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