[aida] How to set the #addLinkTo:

Janko Mivšek janko.mivsek at eranova.si
Sat Jan 24 15:17:25 CET 2009


Hi Germán,

Sorry for so late answer. Let me try to help you below.

Germán Arduino pravi:

> I'm working with a model that has a main collection and other instvar
> to store choices for the main collection.
> 
> Such #choices is a Dictionary that can have differente things as
> elements, by example:
> 
> * A simple preloaded array:
> 
> brands
> 	^self choices at: #brands ifAbsentPut: [Array with: 'IBM' with:
> 'Hewlett Packard' with: 'Clon']
> 
> * A collection of full objects, as:
> 
> serverTypes
> 	^self choices at: #serverTypes ifAbsentPut: [Set new]
> 
> ServerType in this case is an object with several instvars (name,
> brand, machine model, etc)
> 
> Then, on server collection of the main class (the system) each server
> have an instvar named #serverType
> who has the #name of the server type object of the serverTypes
> collection stored on the dictionary
> choices.
> 
> I'm adding server types on the serverTypes collection on the way:
> 
> addServerType: aServerType
> 	^self serverTypes add: aServerType
> 	
> 
> The main view of the system is as follow:
> 
> viewMain
> 
> 	| e entryList |
> 
> 	e := WebElement new.
> 	e addTextH1: 'Server List'.
> 	entryList := WebGrid new.
> 	entryList columnNames: #('' 'Name' 'Role' 'Company' 'Status' 'Server Type');
> 		setNumbering;
> 		columnFilters: #(nil nil nil true true nil);
> 		sortOn: 2;
> 		collection: self observee servers;
> 		columnAspects: #(nil #name #role #company #status #serverTypeName);
> 		column: 6 addBlock: [ :each |
> 			(WebElement new) addLinkTo: each text: each serverTypeName].
> 	e add: entryList.
> 	e addBreak.
> 	e addButtonText: 'Add a new server'.
>         self pageFrameWith: e title: 'Server List'.

> My goal is provide a link on server type column that show all the data
> of such server type.
> 
> The text I show is #serverTypeName because I must to show the name of
> server type object, as follow:
> 
> serverTypeName
> 	^ serverType name
> 
> The question is what should code at addLinkTo: (on the column 6 of
> above text) to link the ServerTypeApp
> that shows the server type data which name is #serverTypeName?

I think the solution is simply:
      column: 6 addBlock: [:each |
  	(WebElement new)
		addLinkTo: each serverType text: each serverTypeName].

or better:
        ...
	WebLink text: each serverTypeName linkTo: each serverType

Block argument #each namely points to current webGrid row object, that
is a server in your case.

I hope this helps a bit
Janko


-- 
Janko Mivšek
Svetovalec za informatiko
Eranova d.o.o.
Ljubljana, Slovenija
www.eranova.si
tel:  01 514 22 55
faks: 01 514 22 56
gsm: 031 674 565


More information about the Aida mailing list