cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Painter-Wakefield <paint...@mc.duke.edu>
Subject Re: Problems with date and xsp
Date Sat, 03 Jan 2004 19:45:50 GMT
You are instantiating your Date variable at the class level, when the page 
is instantiated.  Cocoon re-uses the page object (just calling the 
generate() method each time), AFAIK.  So you need to put your Date 
instantiation inside the generate() method by doing the logic block inside 
<addcomment>.  That way you will get the current date each time the page 
is requested, instead of just the first time.

-Christopher





Davide <dagarlas@aliceposta.it>
01/03/2004 02:26 PM
Please respond to users

 
        To:     users@cocoon.apache.org
        cc: 
        Subject:        Problems with date and xsp


Hi, i have some problems in getting the actual timestamp to put it into a 
db.

My xsp is:

<?xml version="1.0"?>

<xsp:page language="java"
                 xmlns:xsp="http://apache.org/xsp"
                 xmlns:xsp-request="http://apache.org/xsp/request/2.0"
                 xmlns:xsp-session-fw="http://apache.org/xsp/session-fw/1.0"
                 xmlns:esql="http://apache.org/cocoon/SQL/v2">
                 <xsp:logic>
                                 java.util.Date now=new java.util.Date();
                 </xsp:logic>

                 <addcomment>
                                 <page-title>Add a comment</page-title>
                                 <!-- header bar background source file 
-->
                                 <bg>images/logobg.gif</bg>
                                 <!-- mcnavigator css -->
                                 <css>css/main.css</css>
                                 <esql:connection>
 <esql:pool>mcnavigator</esql:pool>
                                                 <esql:execute-query>
 <esql:query>Insert into comments (User_ID, Comment_text, Commented_URL, 
Comment_Date, Comment_browser) values (
  '<xsp-session-fw:getxml context="authentication" 
path="/authentication/ID"/>',
  '<xsp-request:get-parameter name="comment_text"/>',
  '<xsp-request:get-parameter name="link"/>',
  '<xsp:expr>new java.sql.Timestamp(now.getTime())</xsp:expr>',
  '<xsp-request:get-header name="user-agent"/>')
 </esql:query>
 <esql:error-results>An error occurred</esql:error-results>
 <esql:update-results>
  <message>Your comment has ben added; you can now close this 
window</message>
 </esql:update-results>
                                                 </esql:execute-query>
                                 </esql:connection>
                 </addcomment>
</xsp:page>

The problem is that every time i add a new record to the db using this xsp 

i notice that the time doesn't change. Any solution??

Best Regards, Davide



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




Mime
View raw message