Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
07. Apr 2008, 20:13 America/New_York | Link

I cant get the seam convertDateTime to work.

I have a simple form control declared as follows

...
           <s:decorate id="dateOfBirthDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Date Of Birth</ui:define>
                <h:inputText id="dateOfBirth" 
                             value="#{person.dateOfBirth}">
    				<s:convertDateTime  type="date" dateStyle="medium"  pattern="dd/mm/yyyy" />
    			</h:inputText>	
            </s:decorate>     
...

in the backing entity I have a definition as follows


..
	public GregorianCalendar getDateOfBirth()
	{
		return dateOfBirth;
	}

	public void setDateOfBirth(GregorianCalendar dateOfBirth)
	{
		this.dateOfBirth = dateOfBirth;
	}


...

when i fill in a date line

20\10\1962 i get a seam validation faiure like this


person.xhtml @55,60 value="#{person.dateOfBirth}": java.lang.IllegalArgumentException: argument type mismatch

Bit unclear from the seam documentation as to what this should look like - however i think i had it right - but clearly not.

how do i get the format to accept the DD\MM\YYYY input format ?

2 Replies:
07. Apr 2008, 22:25 America/New_York | Link

I think your backing bean field needs to be of type java.util.Date not GregorianCalendar.

Rating:  * * * * *
07. Apr 2008, 23:17 America/New_York | Link

thanks, just found that out for myself in trial and error.

query if you want the seam validator to work with other date/calendar formats (java.sql.Date - avoid use of @Temporal for example, or GregorianCalendar) how should that be done or is this into writing the custom validator code - I havent got the expertise right now to get into that

Thanks for the prompt response