0

Have some doubt with JSF 2, I would like to use the ajax functionality of JSF 2 only, not going to use any of its implementations.

Have taken the JSF libraries from http://download.java.net/maven/2/com/sun/faces/jsf-api/2.1.1-b03/

But still none of these are supporting the ajax tag that I am using to implement the functionality.

I get the error org.apache.jasper.JasperException: /JSP/BillingPayment.jsp(15,3) No tag "ajax" defined in tag library imported with prefix "f" for the following request.

<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<html>
<body>
<h:form>
    <h:panelGrid>
        <h:inputText value="#{dataTableBean.sponsorID}">
            <f:ajax event="keyup" />
        </h:inputText>
        <h:outputText id="text" value="#{dataTableBean.sponsorID}" />
    </h:panelGrid>
</h:form>
</body>
</html>

For this I presume, I am not having the proper library, please can you give me the correct JSF2 library that supports ajax.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Sridevi Laks
  • 187
  • 2
  • 7
  • 19
  • **MY JSP** `<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%> <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%> ` – Sridevi Laks Mar 29 '11 at 07:11
  • Is there any particular reason that you still prefer the legacy JSP over its superios successor Facelets? – BalusC Mar 29 '11 at 12:02
  • the current system is in JSP, we are redesigning it wid JSF , so am currently in to giving a POC , analysing how efficient is JSF and how well it fits our app. – Sridevi Laks Mar 30 '11 at 06:54
  • but can you tell me why none of the JSF2 library IMPL/CORE tld is not having the ajax tag? – Sridevi Laks Mar 30 '11 at 06:55

2 Answers2

1

You have to use Facelets Technology. Your sth.xhtml will have this form

<?xml version='1.0' encoding='UTF-8' ?>
<!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:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core">
<h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
    <link rel="stylesheet" type="text/css" href="my.css" />
</h:head>
<h:body>
</h:body>
</html>

If you are using netbeans ide 7.1 when you are creating a jsf page check the faceletes option. I had a similar question h:outputScript not defined in library h.

Community
  • 1
  • 1
Billior
  • 23
  • 6
0

Your link points to the jsf-api.jar. You need jsf-impl.jar as well which you can find in this directory.

If you have both in your classpath, you should be able to access the TLDs. I think there's no way to use jsf without a jsf-impl.jar.

Furthermore, you have to include all components tags on your page with the f:view tag. So your page should have the following structure:

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<f:view>
 <html>
  <body>
    <h:form>
      <h:panelGrid>
        <h:inputText value="#{dataTableBean.sponsorID}">
          <f:ajax event="keyup" />
        </h:inputText>
        <h:outputText id="text" value="#{dataTableBean.sponsorID}" />
      </h:panelGrid>
   </h:form>
  </body>
 </html>
</f:view> 
Matt Handy
  • 29,855
  • 2
  • 89
  • 112