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')}"/>
Related
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.
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.
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?
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.
I've been playing around a lot with the templating/layout concepts in Grails GSP. I've ben using layouts/content blocks for imitating ASP's master page behavior.
For example, I am using the tag <g:pageProperty /> in a template to leave a "placeholder" which can be overridden using a <content> tag:
myTemplate.gsp:
<body>
<g:pageProperty name="page.topDiv" />
</body>
myPage.gsp:
<html>
<head>
<meta name="layout" content="myTemplate"></meta>
</head>
<body>
<content tag="topDiv">
My top div
</content>
</body>
</html>
This works great for "appending" content to some spot within a template. However, I really want the behavior I can get in ASP.NET's master pages... which is to provide a "default" rendering of some content, and allow optional overriding. In an ASP.NET Master page, it would look like this:
myMaster.master:
<asp:ContentPlaceHolder id="something" runat="server">
<div>Default text/html here</div>
</asp:ContentPlaceHolder>
someOtherPage.aspx:
<asp:Content contentPlaceHolderId="something" runat="server">
Overriden content here!! I don't need to override this though :)
</asp:Content>
My Question:
Can I do this same default/overriding behavior in Grails' GSP?
There are a few different days you could accomplish this. The g:pageProperty is equivalent to the Sitemesh decorator:getProperty tag, so you can use a default attribute to indicate the default text to use. For example:
<g:pageProperty name="page.topDiv" default="Default text/html here"/>
However, I don't know of a clean way to get HTML content in there. You could use a g:if tag to test for that property and specify default behavior if it doesn't exist:
<g:if test="${pageProperty(name:'page.topDiv')}">
<g:pageProperty name="page.topDiv"/>
</g:if>
<g:else>
<div>Default text/html here</div>
</g:else>
The default content could also live in an external template gsp. The render method could then be used to display that content in the default attribute of g:pageProperty:
<g:pageProperty name="page.topDiv" default="${render(template:'topDiv')}"/>
Where in this case, the default content would be located in _topDiv.gsp.
I think you can try instead.
<g:render template=""><g:render>