I would like to ask why you would want to disable the XPM markup for some Component Presentations, since that basically makes them not editable through XPM. So I'm wondering what the use case for that is.
DXA is setup to make enabling of XPM default and simple, so removing it will require more work in most cases, but it isn't impossibe, you have full control over it in each view. The Page view you mention is probabaly GeneralPage.jsp
(or something similar), and the bit of the code you highligted only adds the XPM Javascript to enable the editing buttons for the header and footer include page and the XPM markup for the page itself.
The Component Presentation XPM markup is generated in the Entity view itself. Take a look at for example the Article.jsp
view, in there you can see the following two lines:
<jsp:useBean id="entity" type="com.sdl.webapp.common.api.model.entity.Article" scope="request"/>
<jsp:useBean id="markup" type="com.sdl.webapp.common.markup.Markup" scope="request"/>
Now I'm not a star at Java, but I think the first line is referencing the Model class and the second line enables the generation of the markup. Note this is both the XPM Markup and the optional Semantic markup for SEO. If you remove that second line, you will disable the markup ability in that Entity view (so for that Component Presentation).
But you have to do a little more, by simply removing that line, you broke the view as it is, you will also need to remove all the calls which add the inline editing markup.
So you must now remove all markup bits like the following ${markup.entity(entity)}
, and ${markup.property(entity, "image")}
(including for all other fields).
update
The reason why some of your views might try to output an <html>
and <body>
tag is related to the way Spring MVC handles your view. It expects a view to output HTML and thus it must contain some HTML too. Since DXA uses partial views (we render a Region and Entity view inside the Page view), we must make sure that each view contains at least a top level HTMl element (like a <div>
for example). This is also required for the XPM markup, but even if in your case you removed all that, your view must still have a top level HTML element. We have an open documentation defect on this, so we will document this requirement better in one of our upcoming releases.