We are preparing to move this Jira installation to codehaus. Please wait and don't use this version for some days.

The AndroMDA project

validwhen doesn't work with java.util.Date

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: Bpm4Struts Cartridge
  • Labels:
    None

Description

The validwhen validation doesn't work with the java.util.Date, since the validator uses the toString method, and the java.util.Date.toString() doesn't return a string suitable for comparison. Besides that, bpm4struts uses the sufix AsDate in date fields, so the validwhen tries to use the String version of the form attribute, which isn't suitable for comparison too.

Issue Links

Trackbacks

biaxin (biaxin)
biaxin
mobic (mobic)
mobic
doxycycline (doxycycline)
doxycycline
sumatriptan (sumatriptan)
sumatriptan
buy phentermine 37.5 (buy phentermine 37.5)
buy phentermine 37.5
meridia (meridia)
meridia
norvasc (norvasc)
norvasc
gabapentin (gabapentin)
gabapentin
prometrium (prometrium)
prometrium
tricor (tricor)
tricor
brand viagra (brand viagra)
brand viagra
hjksphur (hjksphur)
hjksphur
generic xanax (generic xanax)
generic xanax
buy xanax online (buy xanax online)
buy xanax online
bactroban (bactroban)
bactroban
buy propecia (buy propecia)
buy propecia
erythromycin (erythromycin)
erythromycin
cheapest cialis (cheapest cialis)
cheapest cialis
hyzaar (hyzaar)
hyzaar
plavix (plavix)
plavix
advair diskus (advair diskus)
advair diskus
topamax side effects (topamax side effects)
topamax side effects
hytrin (hytrin)
hytrin
diovan hct (diovan hct)
diovan hct
flovent (flovent)
flovent
zyvox (zyvox)
zyvox
motilium (motilium)
motilium
wellbutrin (wellbutrin)
wellbutrin
brand viagra (brand viagra)
brand viagra
dostinex (dostinex)
dostinex
buy phentermine online (buy phentermine online)
buy phentermine online
rhinocort (rhinocort)
rhinocort
order valium online (order valium online)
order valium online
flovent (flovent)
flovent
antabuse (antabuse)
antabuse
seroquel (seroquel)
seroquel
bcaa (bcaa)
bcaa
coq10 (coq10)
coq10
detrol la (detrol la)
detrol la
prozac (prozac)
prozac
triphala (triphala)
triphala
clomid (clomid)
clomid
l glutamine (l glutamine)
l glutamine
saw palmetto (saw palmetto)
saw palmetto
buy phentermine (buy phentermine)
buy phentermine
crestor side effects (crestor side effects)
crestor side effects
sildenafil citrate (sildenafil citrate)
sildenafil citrate
toprol xl (toprol xl)
toprol xl
order phentermine (order phentermine)
order phentermine
prednisolone (prednisolone)
prednisolone
augmentin (augmentin)
augmentin
exelon (exelon)
exelon
paxil side effects (paxil side effects)
paxil side effects
protonix (protonix)
protonix
keppra (keppra)
keppra
montelukast (montelukast)
montelukast
8 cialis (8 cialis)
8 cialis
omeprazole (omeprazole)
omeprazole
acai weight loss (acai weight loss)
acai weight loss
diamox (diamox)
diamox
acai diet (acai diet)
acai diet
zofran (zofran)
zofran
buy valium online (buy valium online)
buy valium online
meridia (meridia)
meridia
site cialis (site cialis)
site cialis
generic phentermine (generic phentermine)
generic phentermine
ativan (ativan)
ativan
effexor withdrawal (effexor withdrawal)
effexor withdrawal
tretinoin (tretinoin)
tretinoin
phentermine with (phentermine with)
phentermine with
singulair (singulair)
singulair
xeloda (xeloda)
xeloda
adipex p (adipex p)
adipex p
cheap xanax (cheap xanax)
cheap xanax
cardizem (cardizem)
cardizem
proventil (proventil)
proventil
ciprofloxacin (ciprofloxacin)
ciprofloxacin
fluoxetine (fluoxetine)
fluoxetine
cheap cialis (cheap cialis)
cheap cialis
finasteride (finasteride)
finasteride
lasix (lasix)
lasix
retin (retin)
retin
plan b (plan b)
plan b
generic xanax (generic xanax)
generic xanax
kamagra (kamagra)
kamagra
acai berry detox (acai berry detox)
acai berry detox
hyzaar (hyzaar)
hyzaar
naproxen 500 (naproxen 500)
naproxen 500
crestor side effects (crestor side effects)
crestor side effects
lorcet (lorcet)
lorcet
carisoprodol soma (carisoprodol soma)
carisoprodol soma
cleocin (cleocin)
cleocin
prilosec (prilosec)
prilosec
detrol (detrol)
detrol

Activity

Hide
Walter Itamar Mourão added a comment - 18/Apr/05 10:16 PM
 I attached a small projects correcting the issue, using the org.apache.beanutils.converter support in Struts to avoid the form fields with the AsDate suffix, and using the java.sql.Date instead of java.util.Date.
Show
Walter Itamar Mourão added a comment - 18/Apr/05 10:16 PM  I attached a small projects correcting the issue, using the org.apache.beanutils.converter support in Struts to avoid the form fields with the AsDate suffix, and using the java.sql.Date instead of java.util.Date.
Hide
Wouter Zoons added a comment - 19/Jul/05 2:36 PM
the validwhen should not be referencing the myDateAsDate fields in the first place, the regular myDate fields (returning a String) should be used

I will try to work on this issue in the next couple of days, no guarantees though (lots of work)
Show
Wouter Zoons added a comment - 19/Jul/05 2:36 PM the validwhen should not be referencing the myDateAsDate fields in the first place, the regular myDate fields (returning a String) should be used I will try to work on this issue in the next couple of days, no guarantees though (lots of work)
Hide
Walter Itamar Mourão added a comment - 19/Jul/05 3:31 PM
FYI: I don't know if there is another user waiting for this issue to be closed, but it's not an priority issue to me anymore.
Show
Walter Itamar Mourão added a comment - 19/Jul/05 3:31 PM FYI: I don't know if there is another user waiting for this issue to be closed, but it's not an priority issue to me anymore.
Hide
Wouter Zoons added a comment - 19/Jul/05 3:54 PM
before I restart trying to fix this issue one small question: when using the date field in the validwhen constraint, didn't it work to just reference the myDate field instead of the myDateAsDate ?

what was the reason ? I remember us talking about this but I don't remember the fine points
Show
Wouter Zoons added a comment - 19/Jul/05 3:54 PM before I restart trying to fix this issue one small question: when using the date field in the validwhen constraint, didn't it work to just reference the myDate field instead of the myDateAsDate ? what was the reason ? I remember us talking about this but I don't remember the fine points
Hide
Walter Itamar Mourão added a comment - 19/Jul/05 6:36 PM
myDateAsDate should not be used because the validWhen validator uses the toString() method, and the implementation of this method in java.util.Date isn't suitable for comparison. Now I'm using java.sql.Date, java.sql.Time and java.sql.Timestamp instead.
Besides that I don't think it is a good practice, since the modeler should learn implementation details, like the ...AsDate additional form properties.
Show
Walter Itamar Mourão added a comment - 19/Jul/05 6:36 PM myDateAsDate should not be used because the validWhen validator uses the toString() method, and the implementation of this method in java.util.Date isn't suitable for comparison. Now I'm using java.sql.Date, java.sql.Time and java.sql.Timestamp instead. Besides that I don't think it is a good practice, since the modeler should learn implementation details, like the ...AsDate additional form properties.
Hide
Wouter Zoons added a comment - 19/Jul/05 8:05 PM
that's my point .. why don't you use the date accessor that is returning a String instance ?

for each date 'today' you have these accessors:

getToday() : String
getTodayAsDate() : Date

my question was about what would go wrong when using the first one (also that way the user does not need to learn any implementation details)

I'm supporting the first one mainly to get things working with the validation framework used in Struts
Show
Wouter Zoons added a comment - 19/Jul/05 8:05 PM that's my point .. why don't you use the date accessor that is returning a String instance ? for each date 'today' you have these accessors: getToday() : String getTodayAsDate() : Date my question was about what would go wrong when using the first one (also that way the user does not need to learn any implementation details) I'm supporting the first one mainly to get things working with the validation framework used in Struts
Hide
Walter Itamar Mourão added a comment - 19/Jul/05 8:19 PM
I forgot to write: the string version isn't suitable to comparison since it can be dd/mm/yyyy (my case), mm/dd/yy, yy/mm/dd, and so on.
Show
Walter Itamar Mourão added a comment - 19/Jul/05 8:19 PM I forgot to write: the string version isn't suitable to comparison since it can be dd/mm/yyyy (my case), mm/dd/yy, yy/mm/dd, and so on.
Hide
Wouter Zoons added a comment - 19/Jul/05 8:39 PM
with comparison you mean not .equals() but .before and .after ? did you try writing your own validator ?

is still think < and > would work (if the pattern is strict, so by using '02' instead of just '2')
Show
Wouter Zoons added a comment - 19/Jul/05 8:39 PM with comparison you mean not .equals() but .before and .after ? did you try writing your own validator ? is still think < and > would work (if the pattern is strict, so by using '02' instead of just '2')
Hide
Walter Itamar Mourão added a comment - 19/Jul/05 9:25 PM
I'm my first case I needed to compare using > and <. The validWhen didn't work because '31/01/2005' is greater than '01/02/2005' when comparing strings, for example.
Show
Walter Itamar Mourão added a comment - 19/Jul/05 9:25 PM I'm my first case I needed to compare using > and <. The validWhen didn't work because '31/01/2005' is greater than '01/02/2005' when comparing strings, for example.
Hide
Wouter Zoons added a comment - 19/Jul/05 9:44 PM
oh yeah that's right, it only works when using yyyy/MM/dd
Show
Wouter Zoons added a comment - 19/Jul/05 9:44 PM oh yeah that's right, it only works when using yyyy/MM/dd
Hide
Wouter Zoons added a comment - 20/Jul/05 9:31 PM
I think I have found an easy solution that requires neither of us to implement anything specific while at the same time not expecting the user to know bpm4struts internals

suppose 'christmas' and 'easter' are both form fields of type java.util.Date; currently one would try to do this in a validwhen constraint:

    christmas > easter

which wouldn't work because of the reasons you mentioned before, doing

    christmasAsDate > easterAsDate

isn't nice either because the 'AsDate' suffix is something bpm4struts specific, only a convenient accessor

but what if we made use of the Java API instead:

    christmas.time > easter.time

I know it looks kinda funny but think about it: using the Java API is fine because we're dealing with a tagged value here, which is PSM anyway .. assuming we're using Java is also okay because we're generating Struts code

since the .time property returns a primitive long value the comparison is bulletproof

what do you think ?

Show
Wouter Zoons added a comment - 20/Jul/05 9:31 PM I think I have found an easy solution that requires neither of us to implement anything specific while at the same time not expecting the user to know bpm4struts internals suppose 'christmas' and 'easter' are both form fields of type java.util.Date; currently one would try to do this in a validwhen constraint:     christmas > easter which wouldn't work because of the reasons you mentioned before, doing     christmasAsDate > easterAsDate isn't nice either because the 'AsDate' suffix is something bpm4struts specific, only a convenient accessor but what if we made use of the Java API instead:     christmas.time > easter.time I know it looks kinda funny but think about it: using the Java API is fine because we're dealing with a tagged value here, which is PSM anyway .. assuming we're using Java is also okay because we're generating Struts code since the .time property returns a primitive long value the comparison is bulletproof what do you think ?
Hide
Walter Itamar Mourão added a comment - 21/Jul/05 3:17 PM
It looks like a good workaround, I don't know how validWhen handle primitives, but it should work. I will not use this way because (as I told before) I don't use dates as string in forms anymore.

Anyway, I will warn you: probably you will face the same question again (using strings instead the java date/time type) in BPM-215.
Show
Walter Itamar Mourão added a comment - 21/Jul/05 3:17 PM It looks like a good workaround, I don't know how validWhen handle primitives, but it should work. I will not use this way because (as I told before) I don't use dates as string in forms anymore. Anyway, I will warn you: probably you will face the same question again (using strings instead the java date/time type) in BPM-215.

People

Vote (1)
Watch (0)

Dates

  • Created:
    18/Apr/05 10:10 PM
    Updated:
    13/Aug/11 11:58 AM