Reputation: 121
I am working with JSF2.0 and I want to make JSP page with with ajax-enabled component which is inbuilt component in JSF2.0 and i did following coding for that.
<?xml version="1.0" encoding="UTF-8"?>
<%@ 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 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</head>
<body>
<f:view>
<h3>JSF 2.0 + Ajax Hello World Example</h3>
<h:form>
<h:inputText id="sname" value="#{helloBean.name}"></h:inputText>
<h:commandButton value="Welcome Me">
<f:ajax execute="sname" render="output" />
</h:commandButton>
<h2><h:outputText id="output" value="#{helloBean.sayWelcome}" /></h2>
</h:form>
</f:view>
</body>
</html>
Now,when i m trying to run this code i m getting following error:
org.apache.jasper.JasperException: /TestAjax.jsp (line: 22, column: 7) No tag "ajax" defined in tag library imported with prefix "f" org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:408)
So,please help me how to solve it?And also help me that is tag is allowed in JSP or not? Thanks in advance
I have inclded following jar files:jsf-api,jsf-impl,jstl-api-1.2,jstl-impl-1.2
Upvotes: 1
Views: 4598
Reputation: 1109570
Old JSP is not fully supported by JSF 2. All you get is JSF 1.2 fallback modus. You need its successor Facelets instead.
Rename page.jsp
to page.xhtml
and redeclare/rewrite the document as follows:
<!DOCTYPE html>
<html lang="en"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<h:head>
<title>Insert title here</title>
</h:head>
<h:body>
<h3>JSF 2.0 + Ajax Hello World Example</h3>
<h:form>
<h:inputText id="sname" value="#{helloBean.name}" />
<h:commandButton value="Welcome Me">
<f:ajax execute="@form" render="output" />
</h:commandButton>
<h2><h:outputText id="output" value="#{helloBean.sayWelcome}" /></h2>
</h:form>
</h:body>
</html>
Upvotes: 3