For instance, I have a Questionnaire and
QuestionnaireView, which renders
(it's children) Polls using Vote command. How
can I show this at the main
page of my site? Or how to do this some other (proper) way?
I'm not sure but I would try:
1) Implement a method #accept: in Questionnaire
Questionnaire>>accept: aVisitor
aVisitor visitQuestionnaire: self
2) Implement PRVisitor>>visitQuestionnaire:
PRVisitor>>visitQuestionnaire: aQuestionnaire
self visitCase: aQuestionnaire
3) Implement PREmbeddedRender>>visitQuestionnaire:
PREmbeddedRender>>visitQuestionnaire: aQuestionnaire
"do whatever you want with the 'html' instance variable and
'aQuestionnaire' questionnaire"
Wouldn't it be a hack to implement it this way?
PREmbeddedRenderer >> visitQuestionnaire: aStructure
(aStructure viewComponentClass on: self context)
structure: aStructure;
renderContentOn: html
Specifically I'm not sure about #structure: setter for QuestionnaireView...
I had to do the following there:
QuestionnaireView >>
renderContentOn: html
self components do: [:each |
html render: each]
components
| pollStructure pollCommand pollComponent |
^ self polls
collect: [:each |
pollStructure := self context structure: each command:
POVoteCommand new.
pollCommand := pollStructure command.
pollComponent := pollCommand description asComponentOn:
pollCommand.
"..."
pollComponent]
polls
^ self structure childrenDecoration children
structure
^ structure ifNil: [self context structure]
It works so far but I doubt it's a correct away... Though I can't
explain/understand why...
--
Dennis Schetinin