Op 11-3-2019 om 00:03 schreef Ben
Coman:
I did try to make this idea work but now im complete lost. Right now the collection that should contain the objectNumbers is total empty anyone who can see where I went wrong. I included my code so far. Roelof |
WAComponent subclass: #TBApplicationRootComponent instanceVariableNames: 'main' classVariableNames: '' poolDictionaries: '' category: 'Paintings-Components'! !TBApplicationRootComponent methodsFor: 'updating' stamp: 'RoelofWobben 3/8/2019 14:35'! updateRoot: anHtmlRoot super updateRoot: anHtmlRoot. anHtmlRoot beHtml5. anHtmlRoot title: 'Paintings'. anHtmlRoot stylesheet url: (WAUrl absolute: 'https://code.getmdl.io/1.3.0/material.blue-cyan.min.css')! ! !TBApplicationRootComponent methodsFor: 'initialization' stamp: 'RoelofWobben 3/8/2019 13:43'! children ^ { main }! ! !TBApplicationRootComponent methodsFor: 'initialization' stamp: 'RoelofWobben 3/8/2019 20:35'! main: aComponent main := aComponent! ! !TBApplicationRootComponent methodsFor: 'initialization' stamp: 'RoelofWobben 3/8/2019 20:35'! initialize super initialize. main := TBPostsListComponent new! ! !TBApplicationRootComponent methodsFor: 'initialization' stamp: 'EvelynCusi 3/8/2019 09:57'! renderContentOn: html html render: main .! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! TBApplicationRootComponent class instanceVariableNames: ''! !TBApplicationRootComponent class methodsFor: 'class initialization' stamp: 'RoelofWobben 3/8/2019 13:25'! canBeRoot ^ true ! ! !TBApplicationRootComponent class methodsFor: 'class initialization' stamp: 'RoelofWobben 3/8/2019 14:18'! initialize "self initialize" | app | app := WAAdmin register: self asApplicationAt: 'Paintings'. app addLibrary: JQDeploymentLibrary; addLibrary: JQUiDeploymentLibrary; addLibrary: MDLLibrary! ! WAComponent subclass: #TBHeaderComponent instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Paintings-Components'! !TBHeaderComponent methodsFor: 'rendering' stamp: 'EvelynCusi 3/8/2019 16:12'! renderContentOfHeaderOn: html self subclassResponsibility ! ! !TBHeaderComponent methodsFor: 'rendering' stamp: 'EvelynCusi 3/8/2019 16:12'! renderContentOn: html html mdlLayout fixedHeader; with: [ html mdlLayoutHeader: [ html mdlLayoutHeaderRow: [ html mdlLayoutTitle: 'Paintings' ] ]. self renderContentOfHeaderOn: html ]! ! WAComponent subclass: #TBPostComponent instanceVariableNames: 'post' classVariableNames: '' poolDictionaries: '' category: 'Paintings-Components'! !TBPostComponent methodsFor: 'initialization' stamp: 'RoelofWobben 3/8/2019 20:37'! painter ^ post painter! ! !TBPostComponent methodsFor: 'initialization' stamp: 'RoelofWobben 3/8/2019 22:11'! renderContentOn: html html mdlCard shadow: 2; mdlTypographyTextLeft; with: [ html mdlCardTitleContainer style: 'background: url(''' , self imageUrl asString , ''') center / cover; color: #fff'; with: [ html mdlCardTitleText: self painter ] ]! ! !TBPostComponent methodsFor: 'initialization' stamp: 'RoelofWobben 3/8/2019 20:37'! imageUrl ^ post imageUrl! ! !TBPostComponent methodsFor: 'initialization' stamp: 'RoelofWobben 3/8/2019 20:36'! initialize super initialize. post := Painting new! ! !TBPostComponent methodsFor: 'initialization' stamp: 'RoelofWobben 3/8/2019 20:36'! title ^ post title ! ! !TBPostComponent methodsFor: 'accessing' stamp: 'EvelynCusi 3/8/2019 16:11'! post: aPost post := aPost! ! TBHeaderComponent subclass: #TBPostsListComponent instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Paintings-Components'! !TBPostsListComponent methodsFor: 'rendering' stamp: 'EvelynCusi 3/8/2019 16:12'! renderContentOfHeaderOn: html " super renderContentOn: html." (Paintings new getImages) paintings do: [ :p | html render: (TBPostComponent new post: p) ]! ! WAComponent subclass: #TBScreenComponent instanceVariableNames: 'header' classVariableNames: '' poolDictionaries: '' category: 'Paintings-Components'! !TBScreenComponent methodsFor: 'initialization' stamp: 'RoelofWobben 3/8/2019 14:30'! children ^ { header }! ! !TBScreenComponent methodsFor: 'initialization' stamp: 'RoelofWobben 3/8/2019 14:29'! createHeaderComponent ^ TBHeaderComponent new! ! !TBScreenComponent methodsFor: 'initialization' stamp: 'RoelofWobben 3/8/2019 14:29'! initialize super initialize. header := self createHeaderComponent! ! !TBScreenComponent methodsFor: 'rendering' stamp: 'RoelofWobben 3/8/2019 14:31'! renderContentOn: html html render: header! ! TBApplicationRootComponent initialize!Object subclass: #Painting instanceVariableNames: 'imageUrl' classVariableNames: '' poolDictionaries: '' category: 'Paintings'! !Painting methodsFor: 'accessing' stamp: 'RoelofWobben 2/25/2019 20:17'! imageUrl: anObject imageUrl := anObject! ! !Painting methodsFor: 'accessing' stamp: 'RoelofWobben 2/25/2019 20:17'! imageUrl ^ imageUrl! ! Object subclass: #Paintings instanceVariableNames: 'paintings numbers' classVariableNames: '' poolDictionaries: '' category: 'Paintings'! !Paintings methodsFor: 'accessing' stamp: 'RoelofWobben 3/11/2019 08:05'! paintings ^ paintings! ! !Paintings methodsFor: 'accessing' stamp: 'RoelofWobben 3/11/2019 08:05'! numbers: anObject numbers := anObject! ! !Paintings methodsFor: 'accessing' stamp: 'RoelofWobben 3/11/2019 08:05'! paintings: anObject paintings := anObject! ! !Paintings methodsFor: 'accessing' stamp: 'RoelofWobben 3/11/2019 08:05'! numbers ^ numbers! ! !Paintings methodsFor: 'instance creation' stamp: 'RoelofWobben 3/12/2019 16:53'! getImagesData: objectNumber | json | json := NeoJSONReader fromString: (ZnEasy get: 'https://www.rijksmuseum.nl/api/nl/collection/', objectNumber, 'tiles?key=4OGzuak&format=json') contents. ^ self class getImagesDataFromJSON: json ! ! !Paintings methodsFor: 'instance creation' stamp: 'RoelofWobben 3/11/2019 07:58'! addNumber: aNumber numbers add: aNumber! ! !Paintings methodsFor: 'instance creation' stamp: 'RoelofWobben 2/25/2019 20:29'! addPainting: aPainting paintings add: aPainting. ! ! !Paintings methodsFor: 'instance creation' stamp: 'RoelofWobben 3/11/2019 08:05'! initialize super initialize. numbers := OrderedCollection new! ! !Paintings methodsFor: 'instance creation' stamp: 'RoelofWobben 3/12/2019 17:32'! getData | collectionUrl json | collectionUrl := 'https://www.rijksmuseum.nl/api/nl/collection?key=14OGzuak&format=json&type=schilderij&toppieces=True'. json := NeoJSONReader fromString: (ZnEasy get: collectionUrl) contents. numbers := Paintings GetNumbersfromJSON: json. ^ numbers ! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! Paintings class instanceVariableNames: 'numbers paintings'! !Paintings class methodsFor: 'instance creation' stamp: 'RoelofWobben 3/12/2019 17:26'! getImagesDataFromJSON: json | instance | instance := Painting new. (json at: #values) do: [ :artObjectJson | | painting | painting := Painting new. painting imageUrl: (json at: #name). instance addPainting: painting ]. ^ instance! ! !Paintings class methodsFor: 'instance creation' stamp: 'RoelofWobben 3/12/2019 17:31'! GetNumbersfromJSON: json (json at: #artObjects) do: [ :artObjectJson | | number | number := artObjectJson at: #objectNumber. Paintings new addNumber: number ]. ^ numbers! !