[Seaside] subcomponents with arguments?
Avi Bryant
seaside@lists.squeakfoundation.org
Wed, 7 Aug 2002 13:01:24 -0700 (PDT)
On Tue, 6 Aug 2002, Ragnar Hojland Espinosa wrote:
> I have something like this:
>
> ExShowCompany>>html
> ^ 'companydatahere
> <ExListPersons sea:id=persons></ExListPersons>'
>
> ExShowCompany has a companyID instance variable that gets called on object
> creation. ExListPersons lists all people along with their companies.
>
> What I want to do is, in ExListPersons, if companyID has been defined, dont
> write the companies column and obviously only output people who belong to
> companyID. The if I know I can do with, well.. if :) But how do I pass the
> value / call the companyID method of the ExListPersons component from inside
> the html template or similar?
Two ways you can do this:
1. ExListPersons can access EXShowCompany through its 'parent' instance
variable. So ExListPersons can simply check 'parent companyID'.
2. ExShowCompany can use #addHandlers to pass information down to
ExListPersons. For example,
ExShowCompany>>addHandlers
(template elementNamed: 'persons')
onDisplay: [:p | p companyID: companyID]
Does this work for what you need?