You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Thorsten Scherler <th...@wyona.org> on 2003/02/02 04:27:43 UTC

Re: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?

Hello Andrew,

how is weather in SA? Here in Germany it is snowing!

Please see my answer below:

>>But the people using the app that I am writing don't want type 01/30/2003 to get the reports.
>>The main reason is that the company that I am working for is in Germany. So the user wants to put 30.01.2003 in the form.
>>If I parse that into the esql I can't get any data out of db.
>>
So to avoid worring about the format the user uses,
I could use a JavaScript with my html-Form:
1) <input type="text" name="date">31.01.2003</input>
2) transform that date before submit -> result: 01/31/2003
3) request it with ?date=01/31/2003
4) ...and had no problems.
> I'm not sure if you've understood the <esql:parameter> concept fully.
> Using the esql parameter will result in java code that looks something
> like the following:
...
> When using code like this, you don't have to worry about the format the
> database engine uses, you only have to worry about the format the user
> uses and parse that into a Date object.

You are right! I think that is the actual problem.

The parsed date in the request (?date=01/31/03) is a string!

That was the conclusion the let me to the following code (date.xsp). I 
assume the request is ?date=30.01.2002 (datePattern = "dd.MM.yyyy").

<xsp:page language="java" xmlns:xsp="http://apache.org/xsp">
<xsp:structure>
<xsp:include>java.util.*</xsp:include>
<xsp:include>java.text.*</xsp:include>
</xsp:structure>
<document>
<xsp:logic>
String datePattern = "dd.MM.yyyy";
SimpleDateFormat dateFormat = new SimpleDateFormat( datePattern );
String sDate_one = "31.01.2002";
String sDate_two = request.getParameter("date");
Date date_one = null;
         try
        {
            date_one = dateFormat.parse( sDate_two );
        }
        catch( ParseException e )
        {
  getLogger().error("XSP date error: ", e);
}
</xsp:logic>
<request>
<xsp:expr>sDate_two</xsp:expr>
</request>
<transformed>
<xsp:expr>date_one</xsp:expr>
</transformed>
<static>
<xsp:expr>sDate_one</xsp:expr>
</static>
</document>
</xsp:page>

Thanks again for all the help and your time!

King regards
Thorsten

Re: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?

Posted by Andrew Timberlake <an...@timberlake.co.za>.
Thorsten

On Sun, 2003-02-02 at 05:27, Thorsten Scherler wrote:
> Hello Andrew,
> 
> how is weather in SA? Here in Germany it is snowing!
Here it is hotter than I have experienced for many years.

What problem are you still experiencing?
The code you included produced the following results when run with the
querystring date=01.02.2003

<document>
   <request>01.02.2003</request>
   <transformed>Sat Feb 01 00:00:00 SAST 2003</transformed>
   <static>31.01.2002</static>
</document>

-- 
Andrew
------------------------------------------------------------
I have never let my schooling interfere with my education.
						--Mark Twain


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>