user1451130
user1451130

Reputation: 135

placeholder not recognized when using omnifaces

I'm new to JSF. Well, I'm trying to pass attributes like placeholder through jsf with omnifaces. But somehow the attributes are not recognized. Am I missing something?

Omnifaces.jar is in the Java Server Faces library and I added the Html5RenderKitFactory to the faces-config.xml.

Here's what the content of the JSP file look like:

<%@ 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 xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
<head>
<title>Login</title>
</head>
<body>
    <div class="container">
        <f:view>
            <f:loadBundle basename="de.jsf.messages" var="msg" />

            <h:form styleClass="form-signin" o:autocomplete="off">
                <h2 class="form-signin-heading">Please sign in</h2>
                <h:panelGrid columns="2">
                    <h:inputText value="#{user.name}" styleClass="input-block-level" placeholder="#{msg.user}">

I'm using Tomcat 7.0, MyFaces 2.1, Omnifaces 1.4.

Thanks in advance!

Upvotes: 0

Views: 609

Answers (1)

BalusC
BalusC

Reputation: 1109422

You're mixing legacy JSP with its successor Facelets (XHTML). What you've there is a JSP file. JSP is deprecated since JSF 2.0 (released Dec 2009) and succeeded by Facelets (XHTML). JSF 2.0 compatible libraries do not have JSP tag libraries anymore and are incompatible with JSP. They are designed for usage with Facelets only.

Rename your page.jsp to page.xhtml and get rid of all <%@ %> things. This way PrimeFaces and OmniFaces will work and you'll also be able to use the new JSF 2.0 awesomeness such as <h:head> and <f:ajax>.

I'm not sure which resources you used while learning JSF, but the attempt to use JSP indicates that you were reading JSF 1.x targeted resources. This is not right when your intent is to learn JSF 2.x as many, many things have changed in JSF 2.x as compared to JSF 1.x. I strongly recommend to check twice if the resource is JSF 2.x targeted.

See also:

Upvotes: 2

Related Questions