You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When ViewModels are serialized to the session and then deserialized, the data from ViewModel.extendedViewModel is lost.
Since ViewModel.extendedViewModel works fine in Handlebars, losing this information during session handling was unexpected to me.
We stumbled upon this problem when we wanted to add a boolean field to MiniCartBean. Not using the extended view model but introducing a subclass of MiniCartBean is undoable because
CartInSession having all private fields so a lot of information needs to be duplicated in the subclass
MiniCartBeanFactory.create(Cart) not delegating to a separately overridable method that creates a Bean instance and at the same time being invoked via super.create(...) from TruncatedMiniCartBeanFactory so our subclass of TruncatedMiniCartBeanFactory cannot override MiniCartBeanFactory.create(Cart) in an effective way. Of course we could start copying more of TruncatedMiniCartBeanFactory but code copying has limits, right?
We would like to show a message in the minicart explicating that it has been truncated. We're not able to do that right now due to above limitations.
The text was updated successfully, but these errors were encountered:
@selo-ecube I just re-read the last line and realized that you may have needed some action to fix this for your project. Sorry! I understood the issues as just feedback to fix in next releases (which we are working on at the moment). Do you still need help with that?
Regarding the topic itself, we are getting rid of ViewModels, specially in Session, so we are working in the right direction.
Unfortunately we are working on that in the 1.0.0-RC1 version which is completely different from the v0.x.x, so I don't think we could painlessly provide a fix for the latter version. But these are the key changes involved:
We don't use ViewModels, we use the JVM SDK models directly in the templates (except for very few exceptions).
We only keep in cache JVM SDK models such as cart and customer. In Session we keep ID and version of those models, and any other quick and non-sensible data that we may often need.
Then we just request the cached cart and put it in the page data to the template. The template takes care of extracting all info for the mini cart.
In your case you told me in another issue that you didn't want to go the cache solution, but it's the only solution that will solve this I'm afraid. So for your version I can either point you to the v1.0.0-RC1 development branch files so that you can copy them to your project and drop the Session classes from v0.x.x, or we can discuss which would be the best way for me to integrate them in v0.x.x so that it can help your case.
ViewModel
s are serialized to the session and then deserialized, the data fromViewModel.extendedViewModel
is lost.ViewModel.extendedViewModel
works fine in Handlebars, losing this information during session handling was unexpected to me.MiniCartBean
. Not using the extended view model but introducing a subclass ofMiniCartBean
is undoable becauseMiniCartBeanFactory.create(Cart)
not delegating to a separately overridable method that creates a Bean instance and at the same time being invoked viasuper.create(...)
fromTruncatedMiniCartBeanFactory
so our subclass ofTruncatedMiniCartBeanFactory
cannot overrideMiniCartBeanFactory.create(Cart)
in an effective way. Of course we could start copying more ofTruncatedMiniCartBeanFactory
but code copying has limits, right?The text was updated successfully, but these errors were encountered: