[Seaside] click images and questionable API

Avi Bryant avi at beta4.com
Thu Mar 20 14:13:28 CET 2003


On Thu, 20 Mar 2003, Nevin Pratt wrote:

> My next problem is creating images that are links, like the following
> html would do:
>
>    <a href="http://www.ebay.com"><img src="/images/ebay"></a>
>
> It's not immediately obvious how to get Seaside to generate this type of
> html.  I've looked a little at the #imageFromForm: and
> #imageMapWithAction:form: methods.  It seems intuitively the latter
> method would be what I want, but it's not obvious if it is, or if so,
> how to use it.

What's probably confusing you about those methods is that they are
expecting a Form object, not a url.  This is an extension of the "pure
smalltalk" philosophy of HtmlRenderer - why store your image files outside
the image?  However, neither of them actually does what you're looking for
(and both of them ought to have variations that do indeed take a url, but
I haven't needed them yet and so they aren't there).

If I were you, I would add a method to the renderer something like:

imageWithSource: srcUrl link: hrefUrl
  self attributeAt: 'href' put: hrefUrl.
  self tag: 'a' do: [
    self attributes: {'border' -> 0. 'src' -> srcUrl}.
    self tag: 'img'.
  ]

Then you would have

html imageWithSource: '/images/ebay' link: 'http://www.ebay.com'.

Avi




More information about the Seaside mailing list