Getting an unknown tag warning for f:ajax while using jsf 2

Go To StackoverFlow.com

0

I'm using eclipse. In the WEB-INF/lib folder I have the following jars.

jstl-api-1.2.jar
jstl-impl-1.2.jar
myfaces-api-2.0.2.jar
myfaces-impl.2.0.2.jar

I get the following warning

Multiple annotations found at this line:
    - Unknown tag (f:ajax).
    - Unknown tag (f:ajax).

.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>no</title>
</head>
<body>
<f:view>
    <h:form id="form1">
        <h:commandButton value="submit" type="submit" action="#{registrationBean.storeUserId}" >
             <f:ajax render="node1" />
        </h:commandButton>
        <br>
        <h:outputText id="node1" value="#{userIdBean.userId}" style="font-weight:bold" />
    </h:form>
</f:view>
</body>
</html>
2012-04-04 01:09
by Dale


1

The <f:ajax> is not supported in the ancient JSP view technology. It's only supported in its successor Facelets.

Rename page.jsp to page.xhtml and rewrite the code conform Facelets syntax:

<!DOCTYPE html>
<html lang="en"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
>
    <h:head>
        <title>no</title>
    </h:head>
    <h:body>
        <h:form id="form1">
            <h:commandButton value="submit" type="submit" action="#{registrationBean.storeUserId}" >
                 <f:ajax render="node1" />
            </h:commandButton>
            <br>
            <h:outputText id="node1" value="#{userIdBean.userId}" style="font-weight:bold" />
        </h:form>
    </h:body>
</html>

When learning JSF 2.x, make sure that you're reading JSF 2.x resources/tutorials/books, not JSF 1.x ones.

See also:

2012-04-04 01:18
by BalusC
Thanks! Is there a better way to create an xhtml file or must I create a jsp and rename it? I don't see a create xhtml option. Also, what must I do to get eclipse 3.5 to validate the xhtml file? I can type whatever garbage i want in there and get no warnings or errors - Dale 2012-04-04 02:07
Keep yourself and your tools up to date. Eclipse 3.5 was born before JSF 2.0 was born (june 2009 versus december 2009). So it can impossibly be aware of Facelets files. You need at least Eclipse 3.6. It's currently almost at 3.8. I can warmly recommend the Jboss tools plugin on top of it (at least version 3.3.x) as it offers many very useful JSF/Facelets targeted tools like EL autocompletion - BalusC 2012-04-04 02:08
oops, I meant to say I'm using 3.6 (Helios). Any idea why it behaves as I've described using 3.6? Either way, I'll download 3.7 and check out the jboss tools - Dale 2012-04-04 02:14
Ads