Unable to find Primefaces component

Asked

Viewed 64 times

3

I have the following problem:

I want to create a login screen and password. I’m using the primefaces to pick up the components, but I’m not getting the field to fill in the password.

Analyzing with my lay view, it seems that he does not recognize the tag of the primefaces

Component link in the primefaces: https://www.primefaces.org/showcase/ui/input/password.xhtml

index.xhtml:

<?xml version='1.0' encoding='ISO-8859-1' ?>
<!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"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<title>Pagina Incial da Biblioteca</title>
	
</h:head>
<h:body> 

<h:form>
     
    <p:messages id="messages" showDetail="true" autoUpdate="true" />
 
    <h:panelGrid columns="2" id="matchGrid" cellpadding="5">  
                     
        <h:outputLabel for="pwd1" value="Senha: " />
        <p:password id="pwd1" value="#{passwordView.password5}" match="pwd2" label="Password 1" required="true" />
 
    </h:panelGrid>

    <p:commandButton update="matchGrid" value="Entrar" />    
</h:form>

</h:body>
</html>

Passwordview:

import javax.faces.bean.ManagedBean;

@ManagedBean
public class PasswordView {

    private String password1;   
    private String password2;  
    private String password3;  
    private String password4;  
    private String password5;

    public String getPassword1() {
        return password1;
    }

    public void setPassword1(String password1) {
        this.password1 = password1;
    }

    public String getPassword2() {
        return password2;
    }

    public void setPassword2(String password2) {
        this.password2 = password2;
    }

    public String getPassword3() {
        return password3;
    }

    public void setPassword3(String password3) {
        this.password3 = password3;
    }

    public String getPassword4() {
        return password4;
    }

    public void setPassword4(String password4) {
        this.password4 = password4;
    }

    public String getPassword5() {
        return password5;
    }

    public void setPassword5(String password5) {
        this.password5 = password5;
    } 
}

Error presented:

mar 20, 2019 8:58:35 AM com.sun.faces.renderkit.html_basic.Htmlbasicrenderer getForComponent WARNING: Unable to find component with pwd1 ID in display.

Meus Jars

Resultado

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>2BIIM_Aula9_JSF</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
</web-app>

  • Would you kindly include all the code in your index.xhtml?

  • I updated, now with the full index.xhtml

  • You can also post the screen print that is not opening?

  • Updated, the first faces link shows how it should look. Link: https://www.primefaces.org/showcaseui/input/password.xhtml

  • you set up your web.xml mapping the JSF database? Something like javax.faces.webapp.FacesServlet? If you haven’t mapped the extension .xhtml to go through the page will not be rendered accordingly. Please post your web.xml

  • Updated, in Image 1 and 2 of web.xml there is javax.faces.webapp.Facesservlet, but I’m not entirely sure it’s correct.

Show 1 more comment

2 answers

0


I found the error, it was in the configuration of Deployment I had not put the first faces there.

0

Currently Servlet mapping is only for urls /faces/*

Add the following mapping to web.xml:

<servlet-mapping> 
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern> 
</servlet-mapping>

This will make the pages xhtml be processed by the JSF Server.


UPDATE: There is one more important detail in its implementation, its version of Primefaces (3.5) cannot stand the JSF 2.2.

To use JSF 2.2, you must update Primefaces to at least version 4.0

Another option would be to use the version 2.1 of the JSF.

More information can be found in this thread of Stackoverflow in English

  • Still giving the same error: WARNING: Unable to find component with pwd1 ID in display. - - - I put the new mapping just below the /faces/*

  • @Lucastrigoschott I supplemented the answer with one more detail

  • Dude, I upgraded the primefaces to the latest version, in case 7.0 and still has the error of impossible to find component

  • There must be some error of configuration of the project itself, I will take a time and go up a model project working for you in my Github, I warn you here when I go up there

  • Okay, thank you very much. I’ve researched other ways to do it too and I’m here trying ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.