WebFormElement>autoConvertString:toObject:
autoConvertString: aString toObject: anObject
"try to convert string depending on object type"
(anObject isKindOf: String) ifTrue: [^aString].
(anObject isKindOf: Integer) ifTrue: [^aString asInteger].
"(anObject isKindOf: FixedPoint) ifTrue: [^aString asFixedPoint: anObject scale]."
"(anObject isKindOf: SpDate)
ifTrue: [self halt]."
(anObject isKindOf: SpDate) ifTrue: [^SpDate fromISO8610String: aString].
anObject isNil ifTrue: [^aString].
^aString
Problems:
1) FixedPoint it not known in Pharo
2) instead of SpDate Date have to be used if one wants to call asDays
(IIRC)
There is IMHO another problem. I think this is not easy extendible, or
if one has another isKindOf he will have to change this function..
I wrote a few weeks ago. About the Accept/Presenter pattern from CLIM I
think this would be better for extensibility. We'd may have a class like
PseudoCode
class MyTime
present
"Present in ISO format
accept
"accept from ISo format.
or maybe even better
we'd have
class MyTime
presenter: aPresenter
accepter: anAccepter
and than we can just plug in whatever we like for presentation.
Presenters could be as easy as:
IntegerPresenter
present
self asString
IntegerAccepter
accept
self acceptFromString: externFormatString
...
With the above function the following Date formats do not work
The original implementation uses
readSloFrom
The formats accepted are:
the forms:
<day> <monthName> <year> (5.April 198 5.april 1982 5.apr 82 5.apr 1982)
<day><monthNumber> <year> (5.4.82 5.4.1982 050482 05041992)
So if anyone used Date in America he will have "hard" times (as I'd had
with using ISO Date format)....
Regards
Friedrich
--
Q-Software Solutions GmbH; Sitz: Bruchsal; Registergericht: Mannheim
Registriernummer: HRB232138; Geschaeftsfuehrer: Friedrich Dominicus
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida