The application launches and makes a request for the home page:
http://localhost:8080/crs/mobile/browse/?format=json
The following JSON response is returned to the EMConnectionManager
:
{ "auditContents": "[{\"@type\":\"MobilePage\",\"endeca.internal.created.by\":\"admin\",\"rule.msg\":\"User trigger not satisfied\",\"endeca.internal.last.modified.by\":\"admin\",\"rule.msgcode\":\"14\",\"rule.state\":\"considered\",\"endeca.internal.resource.path\":\"\\/sites-live\\/CRS\\/content\\/Mobile\\/Web Browse Pages\\/Category Page\",\"endeca.internal.workflow.state\":\"ACTIVE\",\"type\":\"DGraph.MerchDebug\",\"Title\":\"Category Page\",\"rule.id\":\"6\",\"endeca.internal.last.modified\":\"2013-02-18T10:44\",\"endeca.internal.date.created\":\"2013-02-18T10:44\",\"Zone\":\"\\/content\\/Mobile\\/Web Browse Pages\"}\n,{\"@type\":\"MobilePage\",\"endeca.internal.created.by\":\"admin\",\"rule.msg\":\"Fired\",\"endeca.internal.last.modified.by\":\"admin\",\"rule.msgcode\":\"13\",\"rule.state\":\"fired\",\"endeca.internal.resource.path\":\"\\/sites-live\\/CRS\\/content\\/Mobile\\/Web Browse Pages\\/Default Browse Page\",\"endeca.internal.workflow.state\":\"ACTIVE\",\"type\":\"DGraph.MerchDebug\",\"Title\":\"Default Browse Page\",\"rule.id\":\"7\",\"endeca.internal.last.modified\":\"2013-02-18T10:44\",\"endeca.internal.date.created\":\"2013-02-18T10:44\",\"Zone\":\"\\/content\\/Mobile\\/Web Browse Pages\"}\n]\n", "previewModuleUrl": "http://localhost:8080/preview", "contents": [ { "SecondaryContent": [ { "removeAllAction": { … }, "refinementCrumbs": [ ], "displayNamePropertyAlias": "displayName", "geoFilterCrumb": null, "@type": "Breadcrumbs", "name": "Breadcrumbs", "searchCrumbs": [ ], "rangeFilterCrumbs": [ … ], "displayNameProperty": "displayName_en" }, { … } ], "@type": "MobilePage", "name": "MobilePage", "MainContent": [ { "@type": "SearchAdjustments", "name": "Search Adjustments" }, { … } ] } ], "@type": "PageSlot", "name": "Mobile Browse Page Slot", "endeca:contentPath": "/mobile/browse", "atg:currentSiteProductionURL": "/crs/storeus", "ruleLimit": "1", "endeca:siteRootPath": "/pages", "contentCollection": "/content/Mobile/Web Browse Pages" }
JSON Response
The JSON response is received by the EMConnectionManager
and passed through to its delegate, an EMAssemblerViewController
. The EMAssemblerViewController
parses the object into an EMContentItem
:
//The default Assembler View Controller uses an EMJSONParser for this parsing //which utilizes introspection to determine how to construct Objective-C classes. //If you want to override the default parsing behavior subclass the EMJSONParser //and //override the dataObjectClassForClass: and contentItemClassForType: methods - (EMContentItem *)parseResponseObject:(id)pResponseObject;
The EMContentItem
constructs a series of EMContentItemAdaptors,
which are stored and managed by the EMAdaptorManager
.
//This is a recursive function. It utilizes a factory to construct a content item //adaptor for each content item it finds. If there is no specific implementation //for an adaptor it //constructs the default EMContentItemAdaptor. The resulting EMContentItemAdaptors //are stored on the EMAdaptorManager. If you wish to override the factory //construction you should subclass the EMAdaptorManager and implement your own //logic in the adaptorForContentItem:controller: method - (void)constructAdaptorForContentItem:(EMContentItem *)pContentItem withController:(EMAssemblerViewController *)pController;
The EMAdaptorManager
uses the list of EMContentItemAdaptors
to inform an EMAssemblerViewControllers
view’s layout. In response, the following EMContentItems
for which an adaptor is constructed:
PageSlot
MobilePage
SearchBox
Breadcrumbs
ContentSlotSecondary
GuidedNavigation
RefinementMenu
SearchAdjustments
ContentSlotMain
ResultsList
Each content item is individually managed via a specific EMContentItemAdaptor
. The EMAssemblerViewController's
view (UICollectionView
) queries its datasource (EMAdaptorManager
) for the following information::
Number of Sections (one section per content item) in response.
In the preceding example, in the JSON response has ten content items
[..list]
, and as a result, theadaptorManager
will have tenadaptorSections
each with 1 adaptor.Number of Items in Each Section
EMContentItems
are not rendered by default. Since there are many dynamic slots and other container content items, we do not construct a renderer for each content item discovered in the response. To render Guided Search content you must have a concrete adaptor implementation which specifies that the content should be rendered. In our example, we specify using a concrete adaptor that we want to renderBreadcrumbs
,RefinementMenu
,SearchAdjustments
, andResultsList
. Each of these concrete adaptors is queried by theadaptorManager
about the number of items to render to see if it returns a value greater than or equal to zero. Breadcrumbs return the number of breadcrumbs, the refinement menu returns the number of refinements,SearchAdjustments
return the number of adjusted search terms, andResultsList
returns the number of products. If any of these values returns a value of less than one, a renderer will not be constructed for that page.What is Drawn for a Given Index (Section, Row)
The
adaptorManager
is not queried again for a renderer, since it does not need a renderer. For the adaptors that have specified a count or greater than zero, theadaptorManager
queries the adaptor about what class object to prepare for the renderer.EMContentItems
by default requires a correspondingEMContentItemRenderer
which implementssetObject
to be rendered. The object that is to be rendered usingsetObject
on the renderer corresponds to an object in the content item such as a product, refinement, breadcrumb, etc.The
EMAdaptorManager
asks the adaptor what object to render and pass it to the renderer using this interface.EMBlockQueue
ObjectsThe
EMAssemblerViewController
has twoEMBlockQueue
objects that can be used by adaptors to run code inviewWillAppear
, ordataReady
. Blocks used in theEMBlockQueue
should be of the following format:
typedef void (^block)(void);
The EMAssemblerViewController
automatically runs/removes blocks in the queue, and viewWillAppearBlockQueue
in the standard UIViewController
uses the viewWillAppear
method, and dataReadyBlockQueue
in the Assembler view controller’s dataReady
method, which is called when the collection view is ready to be displayed in view.