You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wolfgang Woger <wo...@syslog.at> on 2004/08/13 09:49:24 UTC
Hi,
I have a form with a Date:
<html-el:text property="someDate" disabled="true">
<fmt:formatDate value="${theBean.someDate}" type="date"/>
</html-el:text>
The problem: the formated date is not shown at all, it should have
functioned as the value of that input.
what can I do ?
Wolfgang
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re:
Posted by Erik Weber <er...@mindspring.com>.
I just tried this in one of my forms. Works fine under both add and
update conditions, with and without validation errors (the only time the
new string is rendered is for a fresh add page).
Erik
Erik Weber wrote:
> Not positive on this, but I think the place to set this default date
> string would be in your form bean's reset method. Then your JSP
> wouldn't need any code, the html:text field would pull the
> just-initialized value from the form bean, as reset would be invoked
> by Struts just before the JSP renders.
>
> As far as I know, you should steer clear of using the "value"
> attribute to any HTML input tags. You won't get proper "memory" of
> what the user had entered when the page is redisplayed after a form
> validation error.
>
> Someone correct me if that is not the right approach. It's what I do
> when I want checkboxes to be checked by default though, for example,
> so this seems analogous.
>
> Erik
>
>
> Wolfgang Woger wrote:
>
>>
>>
>> Erik Weber wrote:
>>
>>> Not sure about the fmt:format tag, but I use the Struts bean:write
>>> tag to format my dates:
>>>
>>> <bean:write name="event" property="startDate" format="MM/dd/yyyy"/>
>>>
>>> Erik
>>
>>
>>
>> Thank you Erik,
>>
>> I will try bean:write.
>> But by now I have an other problem. I want a new Date() as a default
>> value for a html-el:text element. I did:
>> <%
>> Date curDate = new Date();
>> String dateString = curDate.toString();
>> %>
>> <c:set var="nowDate" value="${dateString}"/>
>> <tr>
>> <td><bean:message key="someDate.displayname"/>:</td>
>> <td><html:text property="someDate" value="${nowDate}"/></td>
>>
>> But nothing can be seen in that field.
>>
>> regards
>> Wolfgang
>>
>>>
>>>
>>>
>>> Wolfgang Woger wrote:
>>>
>>>> Hi,
>>>> I have a form with a Date:
>>>>
>>>> <html-el:text property="someDate" disabled="true">
>>>> <fmt:formatDate value="${theBean.someDate}" type="date"/>
>>>> </html-el:text>
>>>>
>>>> The problem: the formated date is not shown at all, it should have
>>>> functioned as the value of that input.
>>>>
>>>> what can I do ?
>>>>
>>>>
>>>> Wolfgang
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re:
Posted by Erik Weber <er...@mindspring.com>.
Sorry, that's one I have not encountered.
Erik
Wolfgang Woger wrote:
>
>
> Erik Weber wrote:
>
>> Not positive on this, but I think the place to set this default date
>> string would be in your form bean's reset method. Then your JSP
>> wouldn't need any code, the html:text field would pull the
>> just-initialized value from the form bean, as reset would be invoked
>> by Struts just before the JSP renders.
>
>
> I think that will not be that simple, since my form is a
> DynavalidatorForm and all its properties are Strings. An initial value
> for the questionable property can be given in struts.config.xml, which
> is not what i wanted
>
> regards
> Wolfgang
>
>>
>>
>> As far as I know, you should steer clear of using the "value"
>> attribute to any HTML input tags. You won't get proper "memory" of
>> what the user had entered when the page is redisplayed after a form
>> validation error.
>>
>> Someone correct me if that is not the right approach. It's what I do
>> when I want checkboxes to be checked by default though, for example,
>> so this seems analogous.
>>
>> Erik
>>
>>
>> Wolfgang Woger wrote:
>>
>>>
>>>
>>> Erik Weber wrote:
>>>
>>>> Not sure about the fmt:format tag, but I use the Struts bean:write
>>>> tag to format my dates:
>>>>
>>>> <bean:write name="event" property="startDate" format="MM/dd/yyyy"/>
>>>>
>>>> Erik
>>>
>>>
>>>
>>>
>>> Thank you Erik,
>>>
>>> I will try bean:write.
>>> But by now I have an other problem. I want a new Date() as a default
>>> value for a html-el:text element. I did:
>>> <%
>>> Date curDate = new Date();
>>> String dateString = curDate.toString();
>>> %>
>>> <c:set var="nowDate" value="${dateString}"/>
>>> <tr>
>>> <td><bean:message key="someDate.displayname"/>:</td>
>>> <td><html:text property="someDate" value="${nowDate}"/></td>
>>>
>>> But nothing can be seen in that field.
>>>
>>> regards
>>> Wolfgang
>>>
>>>>
>>>>
>>>>
>>>> Wolfgang Woger wrote:
>>>>
>>>>> Hi,
>>>>> I have a form with a Date:
>>>>>
>>>>> <html-el:text property="someDate" disabled="true">
>>>>> <fmt:formatDate value="${theBean.someDate}" type="date"/>
>>>>> </html-el:text>
>>>>>
>>>>> The problem: the formated date is not shown at all, it should have
>>>>> functioned as the value of that input.
>>>>>
>>>>> what can I do ?
>>>>>
>>>>>
>>>>> Wolfgang
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re:
Posted by Wolfgang Woger <wo...@syslog.at>.
Erik Weber wrote:
> Not positive on this, but I think the place to set this default date
> string would be in your form bean's reset method. Then your JSP
> wouldn't need any code, the html:text field would pull the
> just-initialized value from the form bean, as reset would be invoked
> by Struts just before the JSP renders.
I think that will not be that simple, since my form is a
DynavalidatorForm and all its properties are Strings. An initial value
for the questionable property can be given in struts.config.xml, which
is not what i wanted
regards
Wolfgang
>
>
> As far as I know, you should steer clear of using the "value"
> attribute to any HTML input tags. You won't get proper "memory" of
> what the user had entered when the page is redisplayed after a form
> validation error.
>
> Someone correct me if that is not the right approach. It's what I do
> when I want checkboxes to be checked by default though, for example,
> so this seems analogous.
>
> Erik
>
>
> Wolfgang Woger wrote:
>
>>
>>
>> Erik Weber wrote:
>>
>>> Not sure about the fmt:format tag, but I use the Struts bean:write
>>> tag to format my dates:
>>>
>>> <bean:write name="event" property="startDate" format="MM/dd/yyyy"/>
>>>
>>> Erik
>>
>>
>>
>> Thank you Erik,
>>
>> I will try bean:write.
>> But by now I have an other problem. I want a new Date() as a default
>> value for a html-el:text element. I did:
>> <%
>> Date curDate = new Date();
>> String dateString = curDate.toString();
>> %>
>> <c:set var="nowDate" value="${dateString}"/>
>> <tr>
>> <td><bean:message key="someDate.displayname"/>:</td>
>> <td><html:text property="someDate" value="${nowDate}"/></td>
>>
>> But nothing can be seen in that field.
>>
>> regards
>> Wolfgang
>>
>>>
>>>
>>>
>>> Wolfgang Woger wrote:
>>>
>>>> Hi,
>>>> I have a form with a Date:
>>>>
>>>> <html-el:text property="someDate" disabled="true">
>>>> <fmt:formatDate value="${theBean.someDate}" type="date"/>
>>>> </html-el:text>
>>>>
>>>> The problem: the formated date is not shown at all, it should have
>>>> functioned as the value of that input.
>>>>
>>>> what can I do ?
>>>>
>>>>
>>>> Wolfgang
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re:
Posted by Erik Weber <er...@mindspring.com>.
Not positive on this, but I think the place to set this default date
string would be in your form bean's reset method. Then your JSP wouldn't
need any code, the html:text field would pull the just-initialized value
from the form bean, as reset would be invoked by Struts just before the
JSP renders.
As far as I know, you should steer clear of using the "value" attribute
to any HTML input tags. You won't get proper "memory" of what the user
had entered when the page is redisplayed after a form validation error.
Someone correct me if that is not the right approach. It's what I do
when I want checkboxes to be checked by default though, for example, so
this seems analogous.
Erik
Wolfgang Woger wrote:
>
>
> Erik Weber wrote:
>
>> Not sure about the fmt:format tag, but I use the Struts bean:write
>> tag to format my dates:
>>
>> <bean:write name="event" property="startDate" format="MM/dd/yyyy"/>
>>
>> Erik
>
>
> Thank you Erik,
>
> I will try bean:write.
> But by now I have an other problem. I want a new Date() as a default
> value for a html-el:text element. I did:
> <%
> Date curDate = new Date();
> String dateString = curDate.toString();
> %>
> <c:set var="nowDate" value="${dateString}"/>
> <tr>
> <td><bean:message key="someDate.displayname"/>:</td>
> <td><html:text property="someDate" value="${nowDate}"/></td>
>
> But nothing can be seen in that field.
>
> regards
> Wolfgang
>
>>
>>
>>
>> Wolfgang Woger wrote:
>>
>>> Hi,
>>> I have a form with a Date:
>>>
>>> <html-el:text property="someDate" disabled="true">
>>> <fmt:formatDate value="${theBean.someDate}" type="date"/>
>>> </html-el:text>
>>>
>>> The problem: the formated date is not shown at all, it should have
>>> functioned as the value of that input.
>>>
>>> what can I do ?
>>>
>>>
>>> Wolfgang
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re:
Posted by Wolfgang Woger <wo...@syslog.at>.
Erik Weber wrote:
> Not sure about the fmt:format tag, but I use the Struts bean:write tag
> to format my dates:
>
> <bean:write name="event" property="startDate" format="MM/dd/yyyy"/>
>
> Erik
Thank you Erik,
I will try bean:write.
But by now I have an other problem. I want a new Date() as a default
value for a html-el:text element. I did:
<%
Date curDate = new Date();
String dateString = curDate.toString();
%>
<c:set var="nowDate" value="${dateString}"/>
<tr>
<td><bean:message key="someDate.displayname"/>:</td>
<td><html:text property="someDate" value="${nowDate}"/></td>
But nothing can be seen in that field.
regards
Wolfgang
>
>
>
> Wolfgang Woger wrote:
>
>> Hi,
>> I have a form with a Date:
>>
>> <html-el:text property="someDate" disabled="true">
>> <fmt:formatDate value="${theBean.someDate}" type="date"/>
>> </html-el:text>
>>
>> The problem: the formated date is not shown at all, it should have
>> functioned as the value of that input.
>>
>> what can I do ?
>>
>>
>> Wolfgang
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re:
Posted by Erik Weber <er...@mindspring.com>.
Not sure about the fmt:format tag, but I use the Struts bean:write tag
to format my dates:
<bean:write name="event" property="startDate" format="MM/dd/yyyy"/>
Erik
Wolfgang Woger wrote:
> Hi,
> I have a form with a Date:
>
> <html-el:text property="someDate" disabled="true">
> <fmt:formatDate value="${theBean.someDate}" type="date"/>
> </html-el:text>
>
> The problem: the formated date is not shown at all, it should have
> functioned as the value of that input.
>
> what can I do ?
>
>
> Wolfgang
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org