Problem with expression language functions in Tomahawk tags - jsf

I'm using:
Tomcat 6.0
Jsf 1.2 - Mojarra Implementation
Tomahawk 1.1.9
I imported the taglib
<%# taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
when i call:
<h:outputText value="#{fn:indexOf('ciao','i')}"></h:outputText>
Output is 1
when i use
<t:outputText value="#{fn:indexOf('ciao','i')}"></t:outputText>
it throws a server exception, like there are some problems referencing right library.
javax.el.ELException: Function 'fn:indexOf' not found
at org.apache.el.lang.ExpressionBuilder.visit(ExpressionBuilder.java:171)
at org.apache.el.parser.SimpleNode.accept(SimpleNode.java:145)
at org.apache.el.lang.ExpressionBuilder.prepare(ExpressionBuilder.java:133)
at org.apache.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:147)
Any hint? Thank you everybody for help :)

I was able to reproduce exactly this problem with Mojarra 1.2_14 and Tomahawk 1.1.9 on Tomcat 6.0.18. The same problem also occurred at Tomcat 6.0.20, although the line numbers of the org.apache.el.* methods in the stacktrace were slightly different.
To exclude Tomcat's jsp-el from being suspect, I tested at Glassfish v3 as well, which is using a different EL impl. It produced basically the same exception, although with different EL classes in stacktrace (com.sun.el.* instead of org.apache.el.*).
Interesting fact is however that it indeed works flawlessly when using Facelets instead of JSP, as commented by Bozho. This would mean that the JSP EL implementations of both Tomcat and Glassfish are broken.
I would start filing an issue for Tomcat 6 here http://tomcat.apache.org/bugreport.html and see what the Apache guys says about this.

Related

h:outputStylesheet not inserted when using FullAjaxExceptionHandler

I'm using the OmniFaces FullAjaxExceptionHandler to display error pages. The error pages are shown correctly, but I'm having issues with the styling of those pages.
My application is using a template which has CSS classes loaded in the <h:body> section like the following. <h:outputStylesheet name="css/theme.css" library="theme" />
I found the BalusC answer at h:body not rerendered when using FullAjaxExceptionHandler to be helpful for changing the body tag. But I'm stumped on why the FullAjaxExceptionHandler isn't replacing the children of individual <head> element. It appears like all <h:outputStylesheet> elements are ignored no matter where they are located.
I know this quite an old question but I have only recently encountered it and it has only just been solved as of 15/May/2021.
The headline is that this issue is solved in the versions of OmniFaces >= 3.11.1. At the time of writing this, OmniFaces 3.11.1 is a Maven Snapshot build.
The problem was caused by the Mojarra implementation of JSF 2.3 attempting to avoid outputting HTML links to CSS resources twice. It does this by recording a list of all of the resources that it thinks have been output. Then if a further attempt is made to output the same resource then the second and further attempts are ignored. The list is stored in a JSF attribute called "/javax.faces.resource", which is the value of ResourceHandler.RESOURCE_IDENTIFIER.
In the case of Primefaces/JSF rendering the response to an Ajax request generated by an Primefaces component, the rendering replaces the entire page including the resources that had already been rendered. In this case the "/javax.faces.resource" attribute should be cleared by OmniFaces' FullAjaxExceptionHandler to allow the re-rendering of the resources.
The problem was tracked and solved in OmniFaces cases 627 & 630

In NetBeans, Mojarra 2.2 outputStyleSheet doesn't have media attribute

I'm using NetBeans 8.0.2 and Mojarra 2.2 where according to the docs there's a media attribute and this is not the case, I get the following message:
The attribute media is not defined in the component outputStyleSheet
So the problem I know is with NetBeans 8.0.2. When I launch the application, It runs properly so does anyone know why NetBeans shows this error ?
It's documentary bug in the tag library declaration file of the Mojarra implementation. The Mojarra guys forgot to declare the media attribute of outputStylesheet tag in the html_basic.taglib.xml file. Netbeans is relying its tag/attribute validation on it and therefore gives false warnings.
The tag library declaration entry of the attribute is not necessary for the technical functioning of the attribute (not in components, tagfiles, nor composites) and that's why it just works fine.
The same documentary bug problem is known with below tag attributes:
<ui:fragment rendered> - fixed in Mojarra 2.1
<f:selectItem itemEscaped> - fixed in Mojarra 2.2
If you report the <h:outputStylesheet media> documentary bug, it'll likely be fixed in Mojarra 2.3.

role attribute of h:panelGrid

I'm using exaples from the official Java EE tutorial In which contains the follow:
<h:panelGrid columns="2"
headerClass="list-header"
styleClass="list-background"
rowClasses="list-row-even, list-row-odd"
summary="#{bundle.CustomerInfo}"
title="#{bundle.Checkout}"
role="presentation">
But compiler says that attribute role is not defined for h:panelGrid component. How to fix this?
That attribute was introduced in JSF 2.2. As evidence, the role attribute is mentioned in JSF 2.2 <h:panelGrid> documentation, but not in JSF 2.1 <h:panelGrid> documentation.
Your question history confirms that you're using JSF 2.2 on GlassFish 4.0, so this compiler warning is actually wrong. This is not exactly a JSF problem, but an IDE problem. The IDE is somehow thinking that you're not using JSF 2.2, but JSF 2.1 or older. I.e. your toolset is working against you. You didn't mention which IDE you're using, so it's not possible to post the right answer.
If the project runs fine and the JSF page produces the right HTML output (i.e. the role attribute actually ends up in generated HTML <table> element as you can see by rightclick, View Source in webbrowser), then everything is well and it's just the IDE who's pretending to be smarter than it actually is.
I'd start peeking around in IDE project's properties to check if the JSF versions are all right. The JSF facet in project's properties must be set to version 2.2, not lower. The faces-config.xml must be declared conform JSF 2.2, not lower.

JSTL <c:remove not recognized

I have tried looking, and its just getting silly.
I am running Glassfish 3.1.1,
JSF version 2
and netbeans 7.0.1
And the following will not work, at all.
< html xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core">
snipped
< c:remove var="test" scope="session"/>
I know it must be something stupid, this is what netbeans keeps saying:
The component library Jstl Core doesn't contain component
And in every JSTL tag library I have checked, it does!
The <c:remove> is originally in the JSTL library for the legacy JSP view technology. Facelets, the successor of JSP, has only a subset of the JSTL tags redefinied (JSP tags doesn't work in Facelets, they have been ported/rewritten). The <c:remove> is not among them.
Your concrete problem has to be solved differently. As the concrete functional requirement is unclear, I can't answer that in detail. But I guess that you actually need a JSF #ViewScoped or a CDI #ConversationScoped bean and store the desired property in there. It'll then be removed when the view scope or the conversation scope ends. Those scopes are well definied and lies in between the request and session scope. See also How to choose the right bean scope?

Netbeans + Facelets + Jboss EL

I've got a problem with JBossEL in NetBeans. Jboss EL provides method execution besides java bean binding. So th code :
<h:outputText value="#{welcomeController.getWelcome(request)}" />
is correct and works fine. But NetBeans shows me an error:
The function getWelcome must be used with a prefix when a default namespace is not specified
How to make NetBeans compatilble with JbossEL ?
I'm using Facelets if it helps.
Just ignore and run.
If those errors annoy you, just disable/reconfigure the JSP EL validator somewhere in the IDE settings.

Resources