Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6184255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:30:19+00:00 2026-05-24T01:30:19+00:00

Im using DWR, which im fairly new to…I using ajax to submit a comment

  • 0

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 <strong><span id="commentsCounter">${const['COMMENT_MAX_LENGTH'] - fn:length(commentForm.comment)}</span></strong> characters left.<br/>
            <textarea id="comment" name="comment" rows="2" cols="125" style="width:395px;"
                 onkeypress="characterCounter('commentsCounter',${const['COMMENT_MAX_LENGTH']}, this)"
                 onkeydown="characterCounter('commentsCounter',${const['COMMENT_MAX_LENGTH']}, this)"
                 onkeyup="characterCounter('commentsCounter',${const['COMMENT_MAX_LENGTH']}, this)">
              </textarea>

                    <a href="javascript:addComment();"><img src="../images/icon_add.gif" border="0" alt="Add"/></a>

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 += "<tr><td>" + comment.messages[i] + "</td></tr>";
       }
       $("#commentErrors").html(html);
       $("#commentErrors").css("visibility", "visible");
    }
    else
    {
        // Build HTML for new row.
        var html = "<tr id='id"+comment.id+"'><td id='comment-"+comment.id+"'class='wrappable'>" + comment.comment + "</td>" +

                   "<td id='auditable-"+comment.id+"'>" + comment.id + "</td>" +


                   "</tr>"; // three empty TDs for the three actuals fields
        $("#commentRow").before(html);

WHATIFDATAACTION.JAVA:

public CommentForm addComment(Map<String,String> 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; 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:30:19+00:00Added an answer on May 24, 2026 at 1:30 am

    Did you try returning new Date().getTime() ? This would give you the current date in millisecond precision.

    Or just return a formatted date string like new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSS").format(new Date()).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button
I want to open a pdf file from DWR call. I am using DWR
I trying to upload a zip file. In my project i am using DWR
Looking to implement a RIA using AJAX with Java on the backend. I was
using select statement we can call functions inside the stored procedure, is there another
Using online interfaces to a version control system is a nice way to have
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using TortoiseSVN against VisualSVN I delete a source file that I should not have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.