Top Head JSP Dynamic Includes

The top_head.jsp dynamic includes load additional links in the theme’s head. It uses the following keys:

Load additional links in the theme’s head before the existing ones:

/html/common/themes/top_head.jsp#pre

Alternatively, you can load additional links in the theme’s head, after the existing ones:

/html/common/themes/top_head.jsp#post

The example below injects a link into the top of the top_head.jsp:

@Component(immediate = true, service = DynamicInclude.class)
public class CssTopHeadDynamicInclude extends BaseDynamicInclude {

	@Override
	public void include(
			HttpServletRequest request, HttpServletResponse response,
			String key)
		throws IOException {

		PrintWriter printWriter = response.getWriter();

		String content = 
    "<link href=\"http://localhost:8080/o/my-custom-dynamic-include/css/mentions.css\" 
    rel=\"stylesheet\" 
    type = \"text/css\" />";
    
		printWriter.println(content);
	}

	@Override
	public void register(DynamicIncludeRegistry dynamicIncludeRegistry) {
		dynamicIncludeRegistry.register("/html/common/themes/top_head.jsp#pre");
	}
  
}

Figure 1: The top_head pre key loads additional CSS and HTML resources in the head of the theme.

Figure 1: The top_head pre key loads additional CSS and HTML resources in the head of the theme.

Note that the link’s href attribute’s value /o/my-custom-dynamic-include/ is provided by the OSGi module’s Web-ContextPath (/my-custom-dynamic-include in the example).

Now you know how to use the top_head.jsp dynamic includes.

Bottom JSP Dynamic Includes

Top JS Dynamic Include

WYSIWYG Editor Dynamic Includes

« WYSIWYG Editor Dynamic IncludesTop JS Dynamic Include »
この記事は役に立ちましたか?
0人中0人がこの記事が役に立ったと言っています