[Seaside] Re: Problems using Tasks and MenuDemo

Miguel Enrique Cobá Martínez m.coba.m at gmail.com
Sun Feb 3 16:38:11 UTC 2008


William Hubbard wrote:
> 
> 
> 2008/2/1, William Hubbard <billhubard at gmail.com 
> <mailto:billhubard at gmail.com>>:
> 
>     I'm running into problems trying to use the MenuDemo
>     (http://blog.leugim.com.mx/index.php/2008/01/03/seaside-menus/)
>     approach and Tasks. Take a look the following scenario:
> 
>     I'm using a MainComponent (like MDMain in the tutorial), and this
>     holds a task instance variable to the MainTask and a content iVar
>     for the menu item components (initialized with a "null" component,
>     WAComponent) . In the go method I have:
> 
>     self loginUser ifTrue: [
>         self isolate: [
>             result := self call: WelcomeComponent new
>             (more calls here)
>         ]
>     ]
> 
>     Therefore my UI is like this:
> 
>         LoginComponent
>             |
>             |
>             true
>             |
>             
>     The user is ok, then shows the Menu from MainComponent (the menu is
>     rendered only if the user is authenticated) and the WelcomeComponent
>     from the task. (content still would be just WAComponent like the
>     tutorial)
> 
>     |          |
>     |          |
>     | Menu |  WelcomeComponent
>     |          |
> 
>     When I click a menu item, content needs to be replaced with the
>     NewComponentFromMenu, but the WelcomeComponent is still there,
>     displayed below the NewComponentFromMenu:
> 
> 
>     |          |
>     |          |
>     | Menu |  NewComponentFromMenu
>     |          |
>     |          |
>     |          |
>     |          |  WelcomeComponent
>     |          |
> 
>     I understand this happens because the MenuDemo do not use call:
>     message, but I don't know how to "replace" the WelcomeComponent with
>     the NewComponentFromMenu when a menu item is clicked. I tried
>     setting the content iVar to the WelcomeComponent when enters the
>     isolate: but this just shows two times the WelcomeComponent:
> 
>     |          |
>     |          |
>     | Menu |  WelcomeComponent
>     |          |
>     |          |
>     |          |
>     |          |  WelcomeComponent
>     |          |
> 
> 
>     Any idea how to solve this?
>     Thanks
> 
> 
> 
> I forgot to paste the current main render method I'm using:
> 
> MainComponent>>renderContentOn: html
> 
>    ( self username isAuthenticated ] )
>                 ifTrue: [ html render: menu ].
>        html render: content.
>        html render: task
> 

I'am afraid I don't understand what are you trying to do.

In my app I have choosen to use Announcements because of the flexibility 
it gives you. It permits you to un-wire your components, so your 
children components don't need to know who their parent is.
My app consists from an Main component whose role is to be a container 
for other components, and, this is the important part, this children 
component are swapped or interchanged all the time.
Main has 4 components: (header, menu, content and footer)
and Main can substitute any of then at any time in response to actions 
from the user. When the user clicks an entry from the menu (a child 
component) the menu doesn't change the content component (another child) 
but throws an announcement to anyone interested. It happens that the 
component that registered interest in this particular message is the 
Main component (the parent component), so when the menu component sends 
the announcement, the Main component receives it and take care of 
responding accordingly.

The main component renders itself this way:

Main>>renderContentOn: html
	html div
		id: 'main';
		with: [
			html div
				id: 'header';
				with: [ html render: header ].
			html div
				id: 'menu';
				with: [ html render: menu ].
			html div
				id: 'content';
				with: [ html render: content ].
			html div
				id: 'footer';
				with: [ html render: footer ]]

The main component responds to this announcement changing the objects 
refered by the ivars (header, footer, content, main) so when the user 
wants to see a list of items, for example, the main component takes the 
list that comes with the announcement, creates a new ListComponent and 
set the content ivar to point to this new component, forgetting what the 
old component the content ivar pointed to.
Something like this:

Main>>itemList: anAnnouncement
	self pageTitle: 'Search results'.
	content := ItemList items: anAnnouncement items

This method is called by Main as response to the announcement. ItemList 
is just a new component (items is a handy constructor for this class) 
that replaces the old component pointed to by the content ivar.

This way, when Main is rendered again, it will show the new content (the 
item list) instead of the old content (for example the welcome message)

I hope this helps you,
Miguel Cobá

> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



More information about the seaside mailing list