如何获取表格以显示图像

时间:2019-03-30 17:48:05

标签: smalltalk seaside

我正在Seaside中建立一张桌子(使用VisualAge Smalltalk)。我希望每个表行都有一个图像以及文本数据。该方法如下所示:

其中PSIni getImageUrl返回url的主要部分。最后的url看起来像 http://www.totallyobjects.com/images/pennstadt//15.jpg

请问有人可以告诉我如何完成此操作吗?

 makeData: html usingMethod: aMethod

|tableData headingList methodList|

tableData := self perform: aMethod.
headingList := self headingList.
methodList := self methodList.

html table: [ 
    html tableRow: [ 
        headingList do: [ :each | html 
            tableHeading: each 
        ]
    ].
    tableData do: [ :one |          
        html tableRow: [
            methodList do: [ :each | 
                each = #image ifTrue: [ 
                    html tableData: (self showImageFor: one id using: html)
                ] ifFalse: [ 
                    html tableData: (one perform: each)                        
                ]
            ]
        ]
    ]
]

(self showImageFor: one id using: html)显然不起作用。此方法如下所示:

showImageFor: anID using: html

html image width: 200; url: PSIni getImageURL, '/', anID printString, '.jpg'

其中PSIni getImageUrl返回url的主要部分。

最后的url如下所示: http://www.totallyobjects.com/images/pennstadt/15.jpg 并应导致该图像出现在表格行的一个元素中。

1 个答案:

答案 0 :(得分:3)

您需要嵌套画笔:

html tableData: [ (self showImageFor: one id using: html) ]

这本书有详细的解释:http://book.seaside.st/book/fundamentals/rendering-components

相关问题