Spring tags and facelets - spring

Can I use Spring tags with facelets? I have one JSP page, and there is a directive:
<%# taglib prefix="s" uri="http://www.springframework.org/tags"%>
Then I can insert the tag <s:theme code='css' /> (I'm using theme resolver.) Now I need to use theme resolver in another project using facelets instead JSP. There is a namespace declaration instead the JSP directive, isn't?
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:em="http://java.sun.com/jsf/composite/emcomp"
xmlns:st="http://www.springframework.org/tags">
But in Eclipse the namespace is labeled with the warning marker and on server it does not work, because the tag library is missing, althought I have put the library Spring Web MVC in the lib directory of Eclipse Internal Glassfish server. The JAR really contains META-INF/spring.tld.
I'm unable to find, what's wrong.

No, unfortunately you cannot. Spring tags are based on a JSP taglib. Facelet taglibs are different from JSP taglibs. The reason you can use the old-fashioned jsp core tags (c:forEach etc) in facelets is because they have been ported to facelet taglibs. AFAIK, there has not been any port done yet of the Spring JSP taglib to a facelet taglib.

Related

Spring taglib in uiBinder xml-file

How can I put my taglib prefix correctly in my name.ui.xml file, is it even possible ?
In an html/jsp file it normally would work with
<%#taglib uri="http://www.springframework.org/tags" prefix="spring"%>
But thats not the case with uiBinder xml files. Is there a way or an alternative ? I'm trying to ensure multilingualism in my application. Thx for any help :)
You do understand that JSP is processed by your server, and UiBinder is processed by the GWT compiler to produce JS for the browser (client), right?
If you want to internationalize your GWT application, there are tools for that: http://www.gwtproject.org/doc/latest/doc/latest/DevGuideI18n.html

One or more resources has the target of 'head' but not 'head' component has been defined within the view

I created a JSF page with PrimeFaces components. The project runs fine, but the PrimeFaces UI look and feel is completely missing. I'm only noticing below message in server log:
One or more resources has the target of 'head' but not 'head' component has been defined within the view
What does this mean and how can I fix the PrimeFaces UI styling?
This means that you're using plain HTML <head> instead of JSF <h:head> in your XHTML template. The JSF <h:head> allows automatic inclusion of CSS/JS resources in the generated HTML <head> via #ResourceDependency annotations. PrimeFaces as being a jQuery based JSF component library needs to auto-include some jQuery/UI JS/CSS files and this really requires a <h:head>.
So, search for a
<head>
<title>Some title</title>
...
</head>
in your templates and replace it by
<h:head>
<title>Some title</title>
...
</h:head>
See also:
What's the difference between <h:head> and <head> in Java Facelets?
Unable to understand <h:head> behaviour
How to programmatically add JS and CSS resources to <h:head>
How to include another XHTML in XHTML using JSF 2.0 Facelets?

Spring form tag and HTML 5 still incompatible?

I am using a spring form tag
<%# taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<form:input path="name.lastName" cssClass="text" maxlength="30"/>
When I try to add the new required html5 attribute
<form:input path="name.lastName" required="required" cssClass="text" maxlength="30"/>
I get this error message when the jsp is converted to html
<pre>org.apache.jasper.JasperException: /WEB-INF/pages/admission/registration/patientForm.jsp(168,5) PWC6131: Attribute required invalid for tag input according to TLD
Are the springframework tags ready for html 5 ? If yes, how do i use them ?
I am using spring 2.5
Ok so I researched a bit more and I found out that I need to upgrade to spring mvc 3.

how to configure and use jstl in websphere

Does anybody know how to configure jstl in websphere. i know that we have use taglib directive in web.xml . where do i find web.xml in websphere 5.1.2 and how to add the configuration.
You don't need to modify web.xml at all. Some poor online tutorials indeed suggests that, but you must never take everything at the interwebs for serious. Especially not roseindia.net and consorts.
To install JSTL, all you basically need to do are the following two steps:
Download this file, unzip, browse to /lib and put both jstl.jar and standard.jar in the webapp's runtime classpath.
Declare any of the taglibs as per the JSTL documentation in top of JSP file. For example JSTL core:
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
That's all. The default webapp's runtime classpath covers under each Webapp/WEB-INF/lib folder. Just drop the JAR's in there.

Jasper in Jetty 6 throws exception for JSTL tag

I'm trying to run an application in jetty that runs fine in Tomcat 5.5. The app uses servlet 2.4 and JSP 2.0.
Jetty/Jasper is throwing this exception:
org.apache.jasper.JasperException: /WEB-INF/tiles/layout/main.jsp(85,55) PWC6340: According to the TLD, rtexprvalue is true, and deferred-value is specified for the attribute items of the tag handler org.apache.taglibs.standard.tag.rt.core.ForTokensTag, but the argument for the setter method is not a java.lang.Object
One odd thing, I can't find the TLD anywhere. It seems to be obtaining it by magic that I don't understand. Is it possibly getting a wrong TLD?
It's also hard to tell from where it's loading org.apache.taglibs.standard.tag.rt.core.ForTokensTag. Eclipse doesn't find it in the load path of the project.
Any hints welcome ...
Jetty includes their own JSTL library and there is no need to include jakrta taglib's standard and core jars.
If you do put jakartat taglib's jars into your web application then there is a conflict in the forTokens tag that causes this error while other tags work well. I suggest either remove the jakarta taglib implementation from your web app and rely on Jetty's, or stop using forTokens.
#Guss is correct, the only way out seems to be to avoid the use of c:forTokens.
example alternative to c:forTokens using c:forEach:
<%#taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%#taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:forTokens items="${input}" delims="," var="i">
<!-- do stuff with ${i} -->
</c:forTokens>
<c:forEach items="${fn:split(input,',')}" var="i">
<!-- do stuff with ${i} -->
</c:forEach>

Resources