Howto to use bean:write and format/formatKey in Struts?

C

Conor

Dear All,
I'm having problems using bean:write and format/formatKey in
Struts? I am not getting any errors, but am not getting the right
results as the same time! My example is this, have an entry form that
inputs one "string" field called myDate, say in format yyyy-MM-dd:

(struts-config.xml)
<form-bean name="inputFormNew"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="myDate" type="java.lang.String" />
</form-bean>


I then submit this screen to an action, which uses the
DynaValidatorForm to successfully validate the form with that given
format:

(validation.xml)
<form name="inputFormNew">
<field property="myDate"
depends="required,date">
<arg0 key="name.myDate"/>
<var>
<var-name>datePatternStrict</var-name>
<var-value>yyyy-MM-dd</var-value>
</var>
</field>
</form>

However, when I forward to the success screen, my date is still only
viewed as yyyy-MM-dd, even though my two bean:writes state that one
format should be just yyyy, while another references a resource file
key (using formatKey) to be MM-dd-yyyy:

<bean:write name="inputFormNew" property="myDate"
formatKey="display.date.format" />
<br />
<bean:write name="inputFormNew" property="myDate" format="dd/MM/yyyy"
/>

What am I doing wrong? Has anybody got this working for dates,
if so I'd be very happy to find out how they got it working as it
beginning to annoy me! Note I am using struts 1.1 release, am also
storing the locale in the session.
Thanks a lot to anyone that can help.
Conor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top