HstResponse::addHeadElement has no effect - java

I'm using Hippo CMS.
After unsuccessfully using HST SEO support plugin, I realised that HstResponse::addHeadElement did not have any effect on my HTML pages.
For instance, when adding the following lines in a component's code:
Element title = response.createElement("title");
title.setTextContent("Foo");
response.addHeadElement(title, "hst.seo.document.title");
I would expect the corresponding <title>Foo</title> markup to be included in the response, but it is not.
What did I miss?

The problem is that I didn't have an appropriate hst:headContributions node in the layout file.
I had two of them for two different categories:
<hst:headContributions xhtml="true" categoryIncludes="headerNav" />
and
<hst:headContributions xhtml="true" categoryIncludes="styles" />
But the plugin doesn't use any category for its head contributions.
Adding the following line in my JSP template fixed the issue:
<hst:headContributions xhtml="true" categoryExcludes="headerNav,styles" />

Related

restrict error pages in default cq5 search

I am using the CQ5 out-of-the-box search component. My problem is that the error pages are getting displayed in the search results.
May I know how I can restrict error pages from getting displayed in the search.
Do we need to add a new property for the page so that it can be restricted by QueryBuilder?
If you are unable to separate content that you do not wish to be index from that which you do, the search indexer can be configured to ignore certain content or attributes within specified content. This is described in some detail on the "How to modify the search engine configurations in CQ5 page on the Adobe CQ Help site.
Essentially, attributes can be ignored by the indexer by adding them to the indexing_config.xml file like so:
<index-rule nodeType="nt:base">
<!-- ... existing ignored properties -->
<property nodeScopeIndex="false">mySecretProperty</property>
</index-rule>
The following should exclude pages of a nodes with a specific resourceType and their descendents.
<index-rule nodeType="nt:base" condition="#sling:resourceType='app/components/errorPage'" />
<index-rule nodeType="nt:base" condition="ancestor::*/#excludefromindex='app/components/errorPage'" />
The Jackrabbit Indexing Configuration page has some more details on the syntax of this file.
Content will not automatically be re-indexed, details of how to trigger a reindex can be found here.
In the dialog box where you configure your search results component instance (which would be on your search results page), look for a field called "Path to search in." This maps to a property in the CRX called searchIn. Set this property to a subtree of your content that excludes your error page(s). For instance, if you set up your content tree to be
/content
/searchable-content
home-page
...
/error-pages
404
401
...
In this case, you would set your searchIn to be /content/searchable-content.

How would I make custom atom links using RESTEasy?

I'm wondering if (and if so, how) it's possible to make RESTEasy return an object with custom atom links, such as links to next/previous page when paginating, particularly what I want to get is something akin to the following:
<collection>
<start>4</start>
<values>4</values>
<total>20</total>
<item>...</item>
<item>...</item>
<item>...</item>
<item>...</item>
<atom:link rel="next" href="...?page=3"/>
<atom:link rel="previous" href="...?page=1"/>
<atom:link rel="first" href="...?page=1"/>
<atom:link rel="last" href="...?page=5"/>
</collection>
I've worked out how to give links for discovery, but making custom links like this appears to be more complicated, if at all possible.
In the end I've ended up using the <any/> element and creating my own Elements to insert in to the any field of the JAXB objects. That seems to have its own problems, but at least it's a step further.

In JSP, what do the path and value attribute do within the input tag, and how does the form prefix affect them?

Just wanted a clear answer for a direct question -- google results have been all over the place or don't address the combos you'll see below.
I'm generally a JSP newbie and have been screwing around with the following code.
<form:input id="theId" path="path.copied.directly.fromSomewhereElse"
cssClass="contentTextInput" cssStyle="width: 229px" />
When I put that into my JSP page and load my website, it works fine and looks as my cssClass defines it. Then I start messing with it because I want it to display a default value.
<form:input id="theId" path="path.copied.directly.fromSomewhereElse"
value="blah" cssClass="contentTextInput" cssStyle="width: 229px" />
Suddenly, HTTP 500, an org.apache.jasper.JasperException! So I decide to remove the path altogether, while leaving in the value. This is just step 1 in something I know works because of prior experience. The code is now:
<form:input id="theId" value="someClass.valueIWantAsDefault"
cssClass="contentTextInput" cssStyle="width: 229px" />
That actually throws an exception, too -- but then I remove the form prefix and it works-- mostly. You see, the cssClass's effects are now gone; it looks like a regular, unaffected input textbox. Here's the code so far.
<input id="theId" value="someClass.valueIWantAsDefault"
cssClass="contentTextInput" cssStyle="width: 229px" />
What exactly do these attributes (and prefix) do that makes this mix-and-match work?
I'm guessing you're dealing with a jsp page that relies on a JSP custom tag library that's part of the Spring Framework. Here are the docs for the <form:input> tag. value is not a valid attribute for this custom tag as you can see in the docs link I provided above. When you remove the form:, you're turning the tag into a plain old HTML <input> tag which is why your error is going away at that point. It's also why your css stops working. cssClass is not the correct attribute for the HTML <input> tag. It's simply class. They called it cssClass in the jsp custom tag lib most likely to avoid a lower level collision with the Object.getClass() method (long story, just take my word for it).

header and footer and freemarker

My website has a consistant header and footer that I want on all pages.
What is the best way to do this?
The header will have some dynamic data also, based on the current view.
P.S Does freemarker have any sort of master page functionality? Where I can create a base template, then have other templates build upon the base?
Basically I want to design a template that has header and footer + a place holder for the main content area.
THEN, all other pages will inherit the main template (with header + footer), and then inject the action's render output into the templates main content area.
Define a macro like this in an import library:
<#macro page title>
<html><head><title>${title?html}</title></head>
<body>
<!-- header section -->
<#nested/>
<!-- footer section -->
</body></html>
</#macro>
and use the following template for all your pages:
<#import "common.ftl" as c/>
<#c.page title="custom page title">
<!-- custom page content -->
</#c.page>
You can find the spring-specific part in the spring reference and the freemarker part in the freemarker online docs
(It doesn't seem like Freemarker supports master pages, but through recursive use of include you can achieve a high level of code reuse)
Have a look at SiteMesh. I believe you will find it useful.

JSF runtime pagename passing

I have an include page which is a navigation menu. When i click on those menu i want to refresh the content area of layout with a certain page. How can i pass the page name into a JSF page using include tag
I dont want to switch to facelets and also i tried using $ and calling the backing bean method. It works but no css or richfaces components renders properly.
Thanks
Raj
I am not sure about the RichFaces part, but you can just use EL in <jsp:include> as well.
<jsp:include page="/WEB-INF/#{bean.pagename}.jsp" />
If bean.getPagename() returns for example home, then this will include /WEB-INF/home.jsp. You also need to ensure that the JSF/HTML contents of home.jsp is wrapped by a <f:subview> with an unique ID.
As to the CSS trouble, just ensure that the generated HTML validates and that the CSS imports in the <link> tags are all valid.

Categories

Resources