code: private void ensureElementFormatter(CmsResource resource, HttpServletRequest req) {
  
          CmsJspStandardContextBean contextBean = CmsJspStandardContextBean.getInstance(req);
          CmsContainerElementBean element = contextBean.getElement();
          if (!resource.getStructureId().equals(element.getFormatterId())) {
              element.setFormatterId(resource.getStructureId());
          }
      }
docs: Ensure the element formatter id is set in the element bean.<p>
  
  @param resource the formatter resource
  @param req the request