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
The ContextEngine is used to determine device characteristics such as screen width and device family. This is then used in the DefaultMediaHelper and ContextualDeviceUrlBasedViewResolver to implement serverside responsive (RESS) rendering.
Some rough tests I have done for a page (without any caching) give a processing time of 2.2 seconds with the ContextEngine and 1.2 seconds without. Many implementations implement responsive design client side, and would thus prefer not to have this unneccesary overhead on every request.
It would be thus good to have a feature toggle to set use of the ContextEngine on/off.
The text was updated successfully, but these errors were encountered:
A quick and dirty workaround without rebuilding DXA is to do the following:
Wire in (in a Spring initialization class) a standard ViewResolver before the ContextualDeviceUrlBasedViewResolvers kick in
@Bean
public ViewResolver fallbackViewResolver() {
UrlBasedViewResolver viewResolver = new UrlBasedViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix(this.viewResolverPrefix);
viewResolver.setSuffix(this.viewResolverSuffix);
viewResolver.setOrder(5);//before the 2 ContextualDeviceUrlBasedViewResolvers (order 10 and 20)
return viewResolver;
}
Make your own MediaHelper and override the methods which use the context engine:
@Component
@Primary
public class NonResponsiveMediaHelper extends DefaultMediaHelper {
//These are the 2 methods that call the context engine in the super class.
//By overriding them we ensure the Context Engine is never called
@Override
public ScreenWidth getScreenWidth() {
return ScreenWidth.MEDIUM;
}
@Override
public int getResponsiveWidth(String widthFactor, int containerSize) {
widthFactor = StringUtils.isEmpty(widthFactor) ? "100%" : widthFactor;
double width = 0.0D;
if (!widthFactor.endsWith("%")){
try {
width = Double.parseDouble(widthFactor);
} catch (NumberFormatException var11) {
widthFactor = "100%";
}
}
if (widthFactor.endsWith("%")){
return super.getResponsiveWidth(widthFactor, containerSize);
}
return (int)Math.ceil(width);
}
}
willprice76
pushed a commit
to willprice76/dxa-web-application-java
that referenced
this issue
Oct 1, 2018
The ContextEngine is used to determine device characteristics such as screen width and device family. This is then used in the DefaultMediaHelper and ContextualDeviceUrlBasedViewResolver to implement serverside responsive (RESS) rendering.
Some rough tests I have done for a page (without any caching) give a processing time of 2.2 seconds with the ContextEngine and 1.2 seconds without. Many implementations implement responsive design client side, and would thus prefer not to have this unneccesary overhead on every request.
It would be thus good to have a feature toggle to set use of the ContextEngine on/off.
The text was updated successfully, but these errors were encountered: