why doesn't action take a block?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

why doesn't action take a block?

FDominicus
I searched through all the code, but I simply do not found a way to
assign an block to an action. I can use some Symbol but that does not
help really. I than looked into Ilian and there I found:
column: 6 buildContents:[:e :item | e a text: 'Remove'; action: [self
removeItem: item]];

you see, that is understandable. I have a link, I have an action I do
something in that action. Each line has it's own link which just deletes
or edits or whatever does to the object on this line.

so my approach seems to be sound. And still there's not way achieving
what I like?

I can't believe that.

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
Reply | Threaded
Open this post in threaded view
|

Re: why doesn't action take a block?

Janko Mivšek
Hi Friedrich,

On 06. 12. 2010 18:16, Friedrich Dominicus wrote:
> I searched through all the code, but I simply do not found a way to
> assign an block to an action. I can use some Symbol but that does not
> help really. I than looked into Ilian and there I found:
> column: 6 buildContents:[:e :item | e a text: 'Remove'; action: [self
> removeItem: item]];

Right way would be:

 column: 6 addBlock: [:object |
        e := WebElement new.
        (e addNilLinkText: 'remove')
          onClickDo: [object removeYourself];
          onClickUpdate: thisWholeGrid.
        e ]

column:addBlock: [] must return a web element which will be added in
this column.

object removeYourself removes itself from a parent list, you can also
write in longer form:

        object parent remove: object
or: self observee remove: object "etc"

I hope this helps.

Best regards
Janko

--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: why doesn't action take a block?

Herbert König
In reply to this post by FDominicus
Hi Friedrich,

would you mind to send a version of your example after using Janko's
hints? And summarize what you still would like to improve.


Cheers,

Herbert                            mailto:[hidden email]

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

autoconvertToString

FDominicus
In reply to this post by Janko Mivšek
Ok I replaced the function with:

autoConvertToString: anObject
        "try to convert object to string depending on object type"
        "Squeak specific!"
        (anObject isKindOf: String) ifTrue: [^anObject].
        (anObject isKindOf: Integer) ifTrue: [^anObject printString].
        (anObject isKindOf: Point) ifTrue: [^anObject printDotString]. "???" "Squeak specific!"
        (anObject isKindOf: Date) ifTrue: [^(SpDate onDate: anObject) asISO8610String ].
        anObject aidaIsAssociation ifTrue: [^anObject]. "multilingual"
        ^anObject printString


I know this is not a fix in anyway. But I think it points in the righ
direction.

It seems we have to register kind of callbacks for the wished for
formatting of elements. During that I think I found another problem
here:
printISOString
        ^self year printString,
                (self monthIndex < 10 ifTrue: ['0'] ifFalse: ['']), self monthIndex printString,
                (self dayOfMonth < 10 ifTrue: ['0'] ifFalse: ['']), self dayOfMonth printString

"Date today printISOString   "

It does not work neither with SpDate nor Date at least not on Pharo.

I propose to remove this function because it is wrong anyway....

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
Reply | Threaded
Open this post in threaded view
|

another problem with reading a date

FDominicus
In reply to this post by Janko Mivšek
Well here's a similiar problem to that I posted earlier

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: Date) ifTrue: [^Date readSloFrom: aString readStream].
        anObject isNil ifTrue: [^aString].
        ^aString

readSloFrom is not implemented anywhere....

In Pharo one can use:

^ aString asDate.

I'm sure this is not portable....

FixedPoint is not known to Pharo also and asFixedPoint is not known also

Here's a function which may fix that

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: Float) ifTrue: [^aString asFloat].
        (anObject isKindOf: Date) ifTrue: [^aString asDate].
        anObject isNil ifTrue: [^aString].
        ^aString


I know FixedPoint <> Float, but I've nothing comparable in my Pharo
image. So either my Pharo is messed up or the above is not workable in
Pharo...



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