Taglib that generates output that has a taglib - taglib

I make a custom taglib that outputs html, and I want to have another taglib as part of the html.
For instance:
output.println("<foo:buildTable />");
I do have taglib "foo" referenced correctly in the page.

Related

Grails - How can I add a <script> inside <head> tag in custom taglib?

I'm using grails 2.4.5 (with asset pipeline plugin)
How can I add a <script src="myscript.js"> inside <head> tag in custom taglib?
Asset pipeline plugin provides a custom taglib called AssetsTagLib. You can invoke any methods of this taglib from any custom taglib you wrote just as you would do with the Grails provided taglib. The following should or atleast works for me on grails-2.5.1
out << asset.javascript(src: "some-file.js")
Check you taglib and if you find something like
static defaultEncodeAs = [taglib:'html']
remove it. Otherwise the output of the custom tag goes to <body> instead of <head>. I don't know the reason for this.

How to define displaytag.tld offline?

I want to define my displaytag.tld offline so that my application will no longer need to access uri="http://displaytag.sf.net", i put
<%# taglib prefix="display" uri="/displaytag"%>
in my jsp but it has error, i put my displaytag-1.2.jar inside /WebContent/WEB-INF/lib/. Can anyone advise me what to do next in order to eliminate the error? I'm using Eclipse IDE.
Thanks in advance.
uri="http://displaytag.sf.net" Look like a URL to a web resource.but it is not. it just a name that happens to be formatted as a URL. so instance of
<%# taglib prefix="display" uri="/displaytag"%> use
<%# taglib prefix="display" uri="http://displaytag.sf.net"%>
you can see tld file in inside META-INF folder of your jar file.

How to load external JSP taglib in Grails properly

I'm trying to integrate Isomorphic SmartClient with Grails. SmartClient server has some custom JSP taglibs described with xml file (it's TLD file based on schema web-jsptaglibrary_1_1.dtd).
I have proper jars in classpath and just for a test two similar files in Grails application web-app directory. The first one is w00t.jsp:
<%# taglib uri="/WEB-INF/iscTaglib.xml" prefix="isc" %>
<html>
<body>
<pre>
<isc:loadDMIStubs ID="ko" />
</pre>
<%= "w00t" %>
</body>
</html>
And the second one is dafaq.gsp
<%# taglib uri="/WEB-INF/iscTaglib.xml" prefix="isc" %>
<html>
<body>
<pre>
<isc:loadDMIStubs ID="ko" />
</pre>
<%= "dafaq" %>
</body>
</html>
When I'm loading those files through browser the JSP one works as expected and the tag is executed. However when I'm trying to call GSP file then an exception is thrown:
org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException
Unknown JSP tag isc:loadDMIStubs
According to Grails docs this should work, shouldn't it?

What is the difference between struts <html: tags and struts <s: tags

I can see in some forums they are initializing struts tag as
<%#taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
and they are initializing tags as <html:form> etc..
but i am using struts tag as
<%#taglib prefix="s" uri="/struts-tags" %>
and using as <s:form> tag. my qustion is, Is there any difference in between struts <html:form> tag and <s:form> tag, or they have only change in prefix only.
I do not have much idea about Struts1, but if i am correct the one you mention <html:form> are from classic Struts1 and <s:form> is from S2.
Basically you can use any prefix to define in S2 tags like a, b,c etc.If you want you are free to use html as you prefix all you need to tell S2 about this like
<%#taglib prefix="html" uri="/struts-tags" %>
in short its only the declaration and using s as prefix is kind of convention.
The taglib declaration sets up what the prefix is, and what prefix you use makes no difference as long as you're consistent and referring to the same taglib.

Struts program does not show properties value

i am try a program of Struts to show french value...for this i have define properties in message.properties file and in message_fr.properties files. but at run time when i access value of property it show blank space.
i have include struts2-core-2.1.8.1.jar, struts2-json-plugin-2.1.8.1.jar on classpath.
for example define in properties file:
pro.color=Blue
on jsp page:
<%# taglib prefix="s" uri="/struts-tags"%>
<%# taglib uri="/user" prefix="user" %>
<s:property value="pro.color"/>
now it show blank space.
Try this:
<s:property value="%{getText('pro.color')}"/>

Resources