{"action":"created","issue":{"url":"https://api.github.com/repos/unic/neba/issues/145","repository_url":"https://api.github.com/repos/unic/neba","labels_url":"https://api.github.com/repos/unic/neba/issues/145/labels{/name}","comments_url":"https://api.github.com/repos/unic/neba/issues/145/comments","events_url":"https://api.github.com/repos/unic/neba/issues/145/events","html_url":"https://github.com/unic/neba/issues/145","id":167432146,"number":145,"title":"Preload models in the controller","user":{"login":"ivoleitao","id":9285937,"avatar_url":"https://avatars.githubusercontent.com/u/9285937?v=3","gravatar_id":"","url":"https://api.github.com/users/ivoleitao","html_url":"https://github.com/ivoleitao","followers_url":"https://api.github.com/users/ivoleitao/followers","following_url":"https://api.github.com/users/ivoleitao/following{/other_user}","gists_url":"https://api.github.com/users/ivoleitao/gists{/gist_id}","starred_url":"https://api.github.com/users/ivoleitao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivoleitao/subscriptions","organizations_url":"https://api.github.com/users/ivoleitao/orgs","repos_url":"https://api.github.com/users/ivoleitao/repos","events_url":"https://api.github.com/users/ivoleitao/events{/privacy}","received_events_url":"https://api.github.com/users/ivoleitao/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/unic/neba/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2016-07-25T18:21:39Z","updated_at":"2016-08-29T19:17:04Z","closed_at":null,"body":"Hi, I'm currently developing a project with NEBA and Adobe Experience Manager. My website features a lot of transactions under the hood (it's a selfcare) and I have a user context stored in session. Some of the information contained in the user context is needed to fill some component models before they are used in sightly. Having a Spring background and looking at the example provided in (https://github.com/unic/publication-neba-adaptto-2015/blob/master/src/main/java/to/adapt/neba/impl/contact/ContactController.java) I though  that I can use something like this:\r\n\r\n```\r\n@ModelAttribute\r\npublic Contact prepareFormModel(@ResourceParam Contact contact) {\r\n    return contact;\r\n}\r\n```\r\n\r\nThe objective is to preload the model with some data before it's used at the sightly level. I'm currently trying to use this with the latest snapshot version of 4.0, AEM 6.1 and with a component that is added to the page.\r\n\r\nI found in the documentation http://neba.io/userguide.html#api_PreMapping-and-PostMapping the `@PostMapping` annotation which I'm currently using (and it works) but somehow and taking in consideration my background does not feel completely right since the model is normally preloaded via the controller\r\n\r\nI've also found that I can intercept the models via ResourceModelPostProcessor namely the processBeforeMapping method but I receive in here calls for all the lifecycle events of all the models. Also once again is detached from the controller...\r\n\r\n```\r\n<T> T processBeforeMapping(T resourceModel,\r\n                         org.apache.sling.api.resource.Resource resource,\r\n                         org.springframework.beans.factory.BeanFactory factory)\r\n```\r\n\r\nIs there an alterantive way of accomplishing this ? Or since there is a single page like orientation in the way neba is supposed to be used most of the data is normally fetched from ajax calls and this not a typically a need and therefore not addressed ?"},"comment":{"url":"https://api.github.com/repos/unic/neba/issues/comments/243225825","html_url":"https://github.com/unic/neba/issues/145#issuecomment-243225825","issue_url":"https://api.github.com/repos/unic/neba/issues/145","id":243225825,"user":{"login":"joaotab","id":13393409,"avatar_url":"https://avatars.githubusercontent.com/u/13393409?v=3","gravatar_id":"","url":"https://api.github.com/users/joaotab","html_url":"https://github.com/joaotab","followers_url":"https://api.github.com/users/joaotab/followers","following_url":"https://api.github.com/users/joaotab/following{/other_user}","gists_url":"https://api.github.com/users/joaotab/gists{/gist_id}","starred_url":"https://api.github.com/users/joaotab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joaotab/subscriptions","organizations_url":"https://api.github.com/users/joaotab/orgs","repos_url":"https://api.github.com/users/joaotab/repos","events_url":"https://api.github.com/users/joaotab/events{/privacy}","received_events_url":"https://api.github.com/users/joaotab/received_events","type":"User","site_admin":false},"created_at":"2016-08-29T19:17:03Z","updated_at":"2016-08-29T19:17:03Z","body":"Hi @olaf-otto! Thanks for the update, I'm sorry we didn't had the chance to contribute more for this version but as @ivoleitao mentioned we're still taking our first steps with NEBA. Surely we will have more thoughts as we use it on a day to day basis!\r\n\r\nThe documentation has helped very much, so far the only thing I had more trouble with was understanding the installation part with maven on AEM. I'll create a separate issue for it.\r\n\r\nCheers, João"}}
{"actor":{"display_login":"joaotab"}}