[Seaside] Clickable pictures in reports?

John Chludzinski john.chludzinski at gmail.com
Wed Jun 10 04:40:13 UTC 2009


To make pics clickable I first subclassed MAReport adding an instance
variable to maintain a reference to the component in which the report
is created:

MAReport subclass: #MMAReport
    instanceVariableNames: 'component'
    classVariableNames: ''
    poolDictionaries: ''
    category: 'MMAApp'!

!MMAReport methodsFor: 'accessing' stamp: 'jtc 6/9/2009 18:15'!
component

    ^ component! !

!MMAReport methodsFor: 'accessing' stamp: 'jtc 6/9/2009 18:16'!
component: c

    component _ c! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

MMAReport class
    instanceVariableNames: ''!

!MMAReport class methodsFor: 'instance creation' stamp: 'jtc 6/9/2009 18:16'!
rows: aCollection description: aDescription component: aComponent

    | report |

    report := self rows: aCollection.
    aDescription asContainer do: [ :each |
        report addColumnDescription: each ].
    report component: aComponent.
    ^ report! !

------------------------------------------------------------------------------------------------------------------

I next modified #renderCellContent:on: in class
MMADescribedImageColumn (my #reportColumnClass: class).

!MMADescribedImageColumn methodsFor: 'rendering' stamp: 'jtc 6/9/2009 18:16'!
renderCellContent: anObject on: html

	| myValue ibt |

	myValue _ self valueFor: anObject.

	(myValue isNil or: [myValue contents isEmpty]) ifTrue: [
		^html render: (self formatter value: myValue)].

	html form: [
		ibt _ html imageButton.
		ibt url: (ibt canvas context urlForDocument: myValue contents
mimeType: myValue mimetype fileName: nil).
		ibt callback: callback: [ self report component editBuddy: anObject
]. "This is where the report's reference to the component (that
created it) is used."
	].
! !

This works but I was considering subclassing MMADescribedImageColumn
from MACommandColumn instead of MADescribedColumn.  Would this have
been a better approach?

---John


More information about the seaside mailing list