Thank you very much Walter! Great!
Carlos
Walter Mourão wrote:
I customized the form templates to handle dates.
Template code:
...
#elseif($field.type.fullyQualifiedName == "java.util.Date")
public void ${field.setterName}(java.lang.String $fieldName)
{
try{
#if($field.type.name.endsWith("date"))
this.$fieldName = $fieldName==null ||
${fieldName}.trim().equals("")?null:new
java.text.SimpleDateFormat("dd/MM/yyyy").parse($fieldName);
#elseif($field.type.name.endsWith("time"))
this.$fieldName = $fieldName==null ||
${fieldName}.trim().equals("")?null:new
java.text.SimpleDateFormat("hh:mm").parse($fieldName);
#else
this.$fieldName = $fieldName==null ||
${fieldName}.trim().equals("")?null:new
java.text.SimpleDateFormat("dd/MM/yyyy hh:mm").parse($fieldName);
#end
}
catch(java.text.ParseException e){
throw new RuntimeException(e);
}
}
public java.lang.String ${field.getterName}()
{
#if($field.type.name.endsWith("date"))
return this.$fieldName==null?null:new
java.text.SimpleDateFormat("dd/MM/yyyy").format(this.$fieldName);
#elseif($field.type.name.endsWith("time"))
return this.$fieldName==null?null:new
java.text.SimpleDateFormat("hh:mm").format(this.$fieldName);
#else
return this.$fieldName==null?null:new
java.text.SimpleDateFormat("dd/MM/yyyy hh:mm").format(this.$fieldName);
#end
}
public void ${field.setterName}AsDate(java.util.Date $fieldName)
{
this.$fieldName = $fieldName;
}
public $fieldType ${field.getterName}AsDate()
{
return this.$fieldName;
}
...
generated code:
...
public void setTxtPeridoDe(java.lang.String txtPeridoDe)
{
try{
this.txtPeridoDe = txtPeridoDe==null ||
txtPeridoDe.trim().equals("")?null:new
java.text.SimpleDateFormat("dd/MM/yyyy").parse(txtPeridoDe);
}
catch(java.text.ParseException e){
throw new RuntimeException(e);
}
}
public java.lang.String getTxtPeridoDe()
{
return this.txtPeridoDe==null?null:new
java.text.SimpleDateFormat("dd/MM/yyyy").format(this.txtPeridoDe);
}
public void setTxtPeridoDeAsDate(java.util.Date txtPeridoDe)
{
this.txtPeridoDe = txtPeridoDe;
}
public java.util.Date getTxtPeridoDeAsDate()
{
return this.txtPeridoDe;
}
...
I hope it helps...
Walter
<[EMAIL PROTECTED]> grava:
Hmm.. I'm on it right now.. it's probably a type mismatch, I'm not sure
if Struts can handle Dates (I assume it did before because I used it
with AndroMDA 2)
-- Wouter
-----Original Message-----
From: Carlos Cuenca [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 03, 2004 10:04 PM
To: [EMAIL PROTECTED]; andromda-user
Subject: Re: [Andromda-user] BPM4Struts & Date Parameters
...Hi again...
I had been doing some test with the Date and Float parameters and I
had
found the following:
-there was not any problem with the boolean nor float conversions.
-My error started when I tried to set the type of parameter like float
,since that datatype is not loaded on the default.xmi. I think that
it
should be included. (Currently there is only a Float)
-On the other hand and with dates, I am still using the lines: (I have
to build everything for testing..)
if (java.util.Date.class.getName().equals(type)) return "new
java.util.Date()";
if (java.sql.Date.class.getName().equals(type)) return "new
java.sql.Date()";
and I get the model compiling, but when I deploy it I get a error:
21:44:12,555 ERROR [Engine] StandardWrapperValve[action]:
Servlet.service() for servlet action threw exception
javax.servlet.ServletException: BeanUtils.populate
at
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:490)
at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcess
or
.java:798)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
20
5)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1158)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
21:44:12,555 ERROR [Engine] ----- Root Cause -----
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Im
pl.java:25)
---------------------------------------------------------------------------
Walter Itamar Mourão - Diretor de Tecnologia e Projetos - Arcadian S/A
www.arcadian.com.br
-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
Andromda-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/andromda-user
-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
Andromda-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/andromda-user