struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Musachy Barroso" <musa...@gmail.com>
Subject Re: Dojo datetimepicker problem
Date Tue, 02 Dec 2008 22:13:09 GMT
You can specify the format of the date with the "format" attribute. By
default it should be RFC3339(yyyy-MM-dd'T'HH:mm:ss), but it doesnt
seem like it is doing that for you. If it is in that format, struts
will parse it to a Date object. What is the html generated for that
field in your page?

musachy

On Tue, Dec 2, 2008 at 4:20 PM, Timothy Orme
<torme@genome.med.harvard.edu> wrote:
> Hello,
>
>        Someone might have to jump in and correct me on this but I think that
> it should just be coming in as a string. As I understand it, the form's
> action doesn't know that you're using a datepicker in the form, it only sees
> a text field with a value (a string). Struts tag libs just generate HTML and
> shouldn't have any influence on what data type is passed through. Therefore,
> you should be using the string setter instead. If you wanted to get this
> into a date object after, I would just get it as a string and use a date
> formatter to build your date.
>
> -Tim Orme
>
> Dimitar Vlasev wrote:
>>
>> Hi all,
>> I'm using Struts 2.0.14.
>>
>> I'm experiencing the following problem:
>> I tried to use datetimepicker in sample application and it worked fine
>> except that the java.util.Date property does not retrieve the new
>> value selected in the interface.
>> I don't have more time today to check this out and will continue
>> trying to fix it tomorrow.
>> What's more weird if i have getter for a String property with the same
>> name I'll get the text that's in the edit box rendered from
>> <s:datetimepicker />
>>
>> Here are some snippets from my test application:
>>
>> struts.xml
>> -------------------------------
>>    <package name="test" namespace="/" extends="struts-default">
>>         .........
>>        <action name="blah_*" class="test.Test" method="{1}">
>>                <result type="tiles">tiles_test</result>
>>        </action>
>>
>>
>> the JSP
>> -------------------
>> <%@ page contentType="text/html; charset=UTF-8" %>
>> <%@ taglib prefix="s" uri="/struts-tags" %>
>> <s:head theme="ajax"/>
>> <div>
>>        <h2> User Details changed </h2>
>>        <s:form action="blah_fetchDate">
>>                <s:textfield name="someText"/>
>>                <s:datetimepicker name="aDate" dayWidth="narrow"
>> weekStartsOn="1" />
>>                <s:submit>Submit Date</s:submit>
>>        </s:form>
>> </div>
>>
>>
>> the Action (implements RequestAware)
>> ----------------------
>>        private Date aDate = new Date()
>>
>>        public String fetchDate() {
>>                OgnlValueStack valueStack = (OgnlValueStack)
>> this.request.get("struts.valueStack");
>>                log.info("--------- this.aDate: " + this.aDate.toString());
>>                log.info("--------- vs: aDate: "
>> +valueStack.findString("aDate"));
>>                log.info("--------- vs: dojo.aDate: "
>> +valueStack.findString("dojo.aDate"));
>>                return Action.SUCCESS;
>>        }
>>
>>        public Date getADate() {
>>                return aDate;
>>        }
>>        public void setADate(Date date) {
>>                log.info("------------ Date set to: " + date.toString());
>>                aDate = date;
>>        }
>>
>>        public void setADate(String s) {
>>                log.info("------------ this one is called :" + s);
>>        }
>>
>> console output
>> --------------------------------------------------
>> 17:37:24,644 INFO  [Test] ------------ this one is called :12/3/08
>> 17:37:24,644 INFO  [Test] --------- this.aDate: Tue Dec 02 17:37:24 EET
>> 2008
>> 17:37:24,644 INFO  [Test] --------- vs: aDate: 12/2/08
>> 17:37:24,644 INFO  [Test] --------- vs: dojo.aDate: null
>>
>> as you can see setADate(Date date) never get's called.
>>
>> I've checked the request made from the browser (using FF with FireBug)
>> and the post parameters were fine "aDate" and "dojo.aDate" where both
>> set to the correct value 12/3/08
>>
>> I appreciate greatly your help.
>> Regards.
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message