JSTL tag not translate in HTML - html

My imports :
xmlns:c="http://java.sun.com/jstl/core"
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
My JSTL Code :
<h:outputLabel value="YESS" >
<fmt:formatNumber value="0.25" type="percent"></fmt:formatNumber>
HTML generated code:
<label>YESS</label>
<fmt:formatNumber value="0.25" type="percent"></fmt:formatNumber>
The generated code show that the JSTL core is translate in HTML.
But the JSTL "fmt" is not translate in HTML.
More information:
<fmt:ErrorInThisFunctionName value="0.25" type="percent" /> ===> generate an error
I work on Tomcat 6

What Pierre said, and also,
Try xmlns:fmt="http://java.sun.com/jstl/fmt"
Check web.xml for
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

suggestion:
check your TLD file.
check your header (DTD, attributes) in your web.xml

If you are using the normal JSP syntax and not the XML-based syntax try using
<%# taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

xmlns:c="http://java.sun.com/jstl/core"
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
The URI for core taglib is invalid. It should be http://java.sun.com/jsp/jstl/core as per its TLD, with /jsp. The URI for format taglib is perfectly fine as per its TLD.
Does the core taglib work in any way? If it doesn't work as well, then it simply means that JSTL is not installed at all. Tomcat does not ship with JSTL by default. You need to download jstl-1.2.jar and put it in /WEB-INF/lib of your webapp. That's all. Do not extract the JAR file and put its loose contents (TLD files and so on) in the classpath as some poor tutorials suggests. It will only get worse. If you already did so, you should cleanup. Only putting the JSTL JAR in classpath is enough.

I had the exact same problem where I would basically declare and it wouldn't get translated into HTML (basically, instead of printing the variable, the entire c:out was printed in the html source). I had forgotten to add this dependency to maven:
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
(If the xml doesn't print, the groupId is taglibs, the artifactId is standard, and the version is 1.1.2

Related

How to move a Skin Object Control with Resources to a DNN Module and building the module without namespace errors?

I have created a DotNetNuke module with code I have copied from a skin file (Skin Object).
I am trying to make this a module so that I can drop it on any page and move and manipulate it any way I like.
I have managed to get the module to work, but only after it failed to find the tagprefix after installing the module and refreshing the page.
The problem is that Visual Studio is complaining that it can't find the namespace, but these resources are defined in the skin file.
<%# Register TagPrefix="dnn" TagName="USER" Src="/Admin/Skins/User.ascx" %>
<%# Register TagPrefix="dnn" TagName="LANGUAGE" Src="/Admin/Skins/language.ascx" %>
<%# Register TagPrefix="dnn" TagName="LOGIN" Src="/DesktopModules/LoginSkinObject/ParrotLoginSkinObject.ascx" %>
<div class="loginlinkwrapper">
<em class="fa fa-user"></em><dnn:USER runat="server" id="dnnUSER" CssClass="login" />
<em class="fa fa fa-lock"></em><dnn:LOGIN runat="server" id="dnnLOGIN" CssClass="login" />
<dnn:LANGUAGE runat="server" id="dnnLANGUAGE" showMenu="False" showLinks="True" />
</div>
I just need a way for Visual Studio to build the module without complaining about the namespaces.
This is the error I get in the Output window (Please note that we only have our DesktopModules in VS to keep everything neat:
This is where the Resources are already defined in the Skin File.
Now, I did try to copy the resources from DNN and adding it to the Project, but for some reason it can't find it. Is there perhaps a web.config setting I can add?
Any particular reason you're not doing the references with ~
<%# Register TagPrefix="dnn" TagName="USER" Src="~/Admin/Skins/User.ascx" %>
<%# Register TagPrefix="dnn" TagName="LANGUAGE" Src="~/Admin/Skins/language.ascx" %>
<%# Register TagPrefix="dnn" TagName="LOGIN" Src="~/DesktopModules/LoginSkinObject/ParrotLoginSkinObject.ascx" %>
You also should double check that IIS doesn't have an application/virtual directory on the /desktopmodules/ folder as that can sometimes happen and cause problems.
Another thing you might try is simply close the ASCX files when you build, and see if Visual Studio stops chirping about them.
When referencing these skin objects like this inside of a DNN Module it can get really complicated as Visual Studio doesn't know where to go find the type of the referenced element.
Typically, if you go into your .designer.cs file you will see that the element gets tagged as a Generic control of some type, you will need to modify this to reflect the proper type/namespace reference for the controls. This additionally does require DLL references as part of this, so be cautious for circular references depending on how you have things architected.
This isn't an issue for the skins, as they are not using a code-behind file and are processing these truly dynamically by loading the referenced src attribute.

Razor RenderPage my.js without HttpException

Suppose I want to render javascript from an external file inline into my layout file for performance reasons.
If I use the following Razor code
<script>
#RenderPage("~/Content/my.js")
</script>
results in
Server Error in '/' Application.
The following file could not be
rendered because its extension ".js" might not be supported:
"~/Content/my.js".
If I merely rename my javascript file to my.js.cshtml
<script>
#RenderPage("~/Content/my.js.cshtml")
</script>
The peasants rejoice.
The question:
Is there any simple way for me to prevent RenderPage from nagging such that I can tell it that the .js extension is fine?
With some feedback from #choudeshell one potential solution is:
<compilation debug="true" targetFramework="4.5">
<buildProviders>
<remove extension=".js"/>
<add extension=".js" type="System.Web.WebPages.Razor.RazorBuildProvider,
System.Web.WebPages.Razor"/>
</buildProviders>
</compilation>
What type of side effects would there be from removing whatever the default is for .js, any?

AppFuse font-awesome webjars error

I am trying to add font-awesome to my AppFuse (v3.0) application. I added the webjars library as below:
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
<version>4.0.3</version>
</dependency>
and modified the wro.xml file to:
<!-- CSS URL Rewriting fails when using webjar resource locator:
https://github.com/alexo/wro4j/issues/127 -->
<group name="main">
<css>classpath:META-INF/resources/webjars/bootswatch/3.0.0/spacelab/bootstrap.min.css</css>
<css>/styles/style.css</css>
<css>classpath:META-INF/resources/webjars/font-awesome/4.0.3/css/font-awesome.min.css</css>
<js>classpath:META-INF/resources/webjars/jquery/1.8.3/jquery.min.js</js>
<js>classpath:META-INF/resources/webjars/bootstrap/3.0.2/js/bootstrap.min.js</js>
<js>classpath:META-INF/resources/webjars/jquery-cookie/1.3.1/jquery.cookie.js</js>
<js>/scripts/script.js</js>
</group>
When loading the contents of the page I get the following errors:
java.io.IOException: No resource found for wildcard: fontawesome-webfont.woff?v=4.0.3
at ro.isdc.wro.model.resource.locator.wildcard.DefaultWildcardStreamLocator.triggerWildcardExpander(DefaultWildcardStreamLocator.java:175)
at ro.isdc.wro.model.resource.locator.wildcard.JarWildcardStreamLocator.locateStreamFromJar(JarWildcardStreamLocator.java:155)
at ...
java.io.IOException: No resource found for wildcard: fontawesome-webfont.ttf?v=4.0.3
...
etc
It looks like there is a problem with retrieving the "fonts" files that come with font-awesome library. Has anybody ran into this problem before? Is there a better way of handling this?
I am pretty new to AppFuse so any help would be appreciated. Thanks.
Replace the "fontawesome-webfont.woff?v=4.0.3" with "fontawesome-webfont.woff". The "?" character is treated as a special character matcher. This can be treated as a bug with the current version of wro4j, but I'll open an issue and it will be fixed for next release of wro4j.

understanding logic flow Struts

first off, i'm new to Struts and i have been following the tutorial here. I understand the set-up of files, and web.xml.
index.jsp:
<%# taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<logic:redirect forward="helloWorld"/>
However, when it comes to the opening of index.jsp, i am at quite a loss. From index.jsp, how does it call the class com.vaannila.action.HelloWorldAction? I know that index.jsp calls the forward=helloWorld but does it mean that it looks for a forward name="helloWorld", which is in <global-forwards>?
Let me know how I can further improve my question, since this is my first.
Correct; it redirects to whatever forward is named "helloWorld".
In this case, that's a forward that runs an action that sticks a value into a form.
You'll likely want to refer to the Struts 1 tag docs, it'll be quicker than asking here every time.
If you can avoid learning Struts 1, I would: it's pretty antiquated on almost all fronts. Frameworks like Struts 2 and Spring MVC dominate Java-framework-based web apps, while things like Grails, Play, Ruby on Rails, etc. dominate JVM-based web apps.
Line 17 of the config file in the tutorial you link to starts:
<action path="/helloWorld"
type="com.vaannila.action.HelloWorldAction"
name="helloWorldForm">
<forward name="success" path="/helloWorld.jsp" />
</action>

How to use a web.config variable in an HTML header?

I have this variable defined in my web.config file :
<appSettings>
<add key ="version" value="123"/>
</appSettings>
and I am using it in my aspx pages' headers without problem:
<link rel="stylesheet" type="text/css" href="../css/style.css?<%= ConfigurationManager.AppSettings["version"] %>"/>
But this doesn't seem to work in a regular HTML page.
What is the correct way of using a web.config variable in straight HTML ?
Server code (for instance what you have in the <%%>) can't be executed on static pages.
You need to append this manually in your static pages, or convert them to dynamic pages (.aspx).
<%%> stands for:
<script runat="server"></script>
In a static page which is not routed through the ASP.NET engine, this will not do anything and will not get converted to server code.