USe lib <%# taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
how to apply single panel grid in colspan?
Related
I am trying to include an erb file in puppet. But the file consists of lines like these:
<%# taglib prefix="ww" uri="webwork" %>
<%# taglib prefix="ui" uri="webwork" %>
<%# taglib prefix="aui" uri="webwork" %>
<%# taglib prefix="page" uri="sitemesh-page" %>
When I run puppet, this is showing a syntax error that says
'# ' is not allowed as an instance variable name.
How can I escape this character #?
Your question is basically answered here already: How do I escape the ERB tag in ERB.
You can't escape the # character per se; you need to "escape" the ERB tags, by using the sequence <%% to indicate that you want the literal string <%.
So, change your ERB code to:
<%%# taglib prefix="ww" uri="webwork" %>
<%%# taglib prefix="ui" uri="webwork" %>
<%%# taglib prefix="aui" uri="webwork" %>
<%%# taglib prefix="page" uri="sitemesh-page" %>
We have a lot of spring, jsp and jstl tags in our templates that we wish to include. Can we make dust ignore these tags?
<sec:authorize access="!hasRole('ROLE_USER')">
<a>Blah</a>
</sec:authorize>
<sec:authorize access="hasRole('ROLE_USER')">
<a>Foo</a>
</sec:authorize>
or
<%# taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%#taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%#taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%#taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%# taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
Use the parser expression grammar to ignore special delimiters, which would look something like this:
= ld [^%] ws* [#?^><+%:#/~%] ws* (!rd !eol .)+ ws* rd
References
dustjs / src / dust.pegjs
dust.pegjs is a bunch of regexes that output an array
peg.js Online Tester
I know this may be a silly question but I ma trying to understand the jsp templates in opencms.
Even though we have htm tags in jsp. what is the actual use of cms tags such as :
<cms:template element="body">
<cms:include element="body" />
As described in this wiki page you can define your template parts in a jsp file through cms tag cms:template and then include them in your jsp page through cms tag cms:include
The cms:template tag
With the tag, you can add control structures to the template which allows it to deal with multiple page elements.
The cms:include tag
This tag is used to include files from the OpenCms VFS dynamically at runtime. The included file is treated like a request with optional additional request parameters.
There are different options to determine the name of the included file by using one of the following attributes:
- page
- property
- attribute
If none of these attributes has been set, the body of the tag is evaluated and the result is used as filename.
<%# page session="false" %>
<%# taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<cms:template element="head">
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><cms:property name="title" escapeHtml="true" /></title>
<meta HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; CHARSET=<cms:property name="content-encoding" default="ISO-8859-1" />">
<link type="text/css" rel="stylesheet" href="<cms:link>../resources/mystyle.css</cms:link>">
<cms:editable />
</head>
<body>
<h2>My first template head</h2>
<!-- Main page body starts here -->
</cms:template>
<cms:template element="body">
<h2>This is the first page element:</h2>
<cms:include element="body" editable="true"/>
<cms:template ifexists="body2">
<h2>This is the second page element:</h2>
<cms:include element="body2" editable= "true"/>
</cms:template>
</cms:template>
<cms:template element="foot">
<!-- Main page body ends here -->
<h2>My first template foot</h2>
</body>
</html>
</cms:template>
During working with JSF 1.2 one page code is too large and JDeveloper gave too large code in service method exception. Now I want to split my JSF file in smaller files. During splitting I need some help and suggestion.
Beacuse the whole page binds with a single bean, is it also necessary to split the bean? If not, then how to overcome this? What is the best way to split JSF file and include in main page?
You don't need to split the bean. You could just split the page fragments over multiple files which you include by <jsp:include> (and not by #include as that happens during compiletime and you would end up with still the same exception!). Note that you should store those include files in /WEB-INF folder to prevent direct access by enduser.
So given this example of an "extremely large" page,
<%#taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%#taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div>
large chunk 1
</div>
<div>
large chunk 2
</div>
<div>
large chunk 3
</div>
</body>
</html>
You could split it as follows while keeping the beans:
<%#taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%#taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<jsp:include page="/WEB-INF/includes/include1.jsp" />
<jsp:include page="/WEB-INF/includes/include2.jsp" />
<jsp:include page="/WEB-INF/includes/include3.jsp" />
</body>
</html>
and /WEB-INF/includes/include1.jsp:
<%#taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%#taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<div>
large chunk 1
</div>
and /WEB-INF/includes/include2.jsp:
<%#taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%#taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<div>
large chunk 2
</div>
and /WEB-INF/includes/include3.jsp:
<%#taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%#taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<div>
large chunk 3
</div>
Is it possible to do this? What I'm trying to accomplish here is the creation of an extensible Struts 2 plugin with customizable screens to avoid code duplication in similar projects.
Yes, it is possible, but it has nothing to do with Struts 2:
http://docs.oracle.com/javaee/1.4/tutorial/doc/JSPTags6.html#wp90207 (under "Packaged Tag Files").
Here is an example: http://www.examulator.com/moodle/mod/resource/view.php?id=473
Quoting steps from this source(taken from prev. answer) in case URL changes. (Simplest solution I found on the internet)
When wrapped in a jar (Java archive) tag files require a tld.
menu.tld placed in the META-INF directory.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>menutagfile</shortname>
<uri>www.examulator.com/menutagfile</uri>
<tag-file>
<name>menu</name>
<path>/META-INF/tags/menu.tag</path>
</tag-file>
</taglib>
menu.tag placed in the META-INF\tags directory.
<%# tag body-content="tagdependent" %>
<%# attribute name="menutext" rtexprvalue="true"%>
<h1>This is my tag file</h1>
<jsp:doBody/>
The command to package these into JAR(Auto package in case of maven)
Jar cvf menutagfile.jar .\META-INF\*.*
Usage in the parent project
<%# taglib prefix="mytagfile" uri="www.examulator.com/menutagfile" %>
<html>
<head>
<title>Demonstration of Tag Files</title>
</head>
<body>
<h1> What is going down? </h1>
<mytagfile:menu/>
</body>
</html>
Note: In case you do not have a META-INF folder in your project, create one inside src/main/resources.