0

Good night.I can't understand why the jsf components aren't getting converted into html page.I am trying to create dataTable that will convert into html table.JSF version is - 2.1.6-SNAPSHOT

└───WebContent
│   Main.jsp
│   Page 0.xhtml
│   Page1.xhtml
│
├───META-INF
│       MANIFEST.MF
│
├───resources
│   └───css
│           CSS.css
│
└───WEB-INF
    │   faces-config.xml
    │   web.xml
    │
    └───lib
            javax.faces.jar
            jstl-1.2.jar

I am trying to get Page1 using http://localhost:8080/Practice/Page1.xhtml Here before xhtml :

<h:body>
<div class = "Task">
    <h:dataTable value = "#{Countries.countries}" var = "country">
        <h:column>
            <f:facet name="header">Country</f:facet>
            #{country.name}
            //I have also tried outputText but the result is the same - empty
        </h:column>
        <h:column>
            <f:facet name = "header">Capital</f:facet>
            #{country.capital}
        </h:column>
    </h:dataTable>
</div>

Here is converted into HTML :

<div class="Task">
    <h:dataTable value="[Lesson2.Country@4d1e67be, Lesson2.Country@81ce079, Lesson2.Country@7f6b1dc8, Lesson2.Country@395e8b9d]" var="country">
        <h:column>
            <f:facet name="header">Country</f:facet>

        </h:column>
        <h:column>
            <f:facet name="header">Capital</f:facet>

        </h:column>
    </h:dataTable>
</div>

Why hasn't jsf components been converted?

Why is there empty where I have tried to display out a country property? There are no exceptions about what's wrong neither in the browser nor in Eclipse.

Here is my full .xhtml -

<!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:ui="http://xmlns.jcp.org/jsf/facelets"
  xmlns:h="http://xmlns.jcp.org/jsf/html"
  xmlns:f="http://xmlns.jcp.org/jsf/core">


  <h:head>
  <title><ui:insert name="title">Default title</ui:insert></title>
  </h:head>

  <h:body>

    <h:dataTable id = "Id" value = "#{Countries.countries}" var = "country">
        <h:column>
            <f:facet name="header">Country</f:facet>
            <h:outputText value = "#{country.name}"/>
        </h:column>
        <h:column>
            <f:facet name = "header">Capital</f:facet>              
            <h:outputText value = "#{country.capital}"/>
        </h:column>

    </h:dataTable>

Here is matching

<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>*.xhtml</url-pattern>
</servlet-mapping>
skoriy
  • 186
  • 10
  • So an `h:inputText` works? – Kukeltje Apr 24 '19 at 06:49
  • @Kukeltje , No,it doesn't. – skoriy Apr 24 '19 at 07:54
  • @Selaron , very thanks!!! There have been xml namespaces that are matched to earlier jsf version.I just had to replace all xmlns.jcp to java.sun...Everything is working! – skoriy Apr 24 '19 at 08:46
  • Sounds like you are using a rather old JSF implementation not knowing recent namespaces. You should pick up a tutorial on recent jsf versions 2.3+. Don't thank me, thank BalusC ;) – Selaron Apr 24 '19 at 09:25
  • @Selaron , frankly speaking , I need JSF to make college practice works.I don't wanna generate html-content using PHP scripts , because it's horrible)I haven't the time now to study JSF well)But,I like JSF on account of nice mvc realization. – skoriy Apr 24 '19 at 09:37

0 Answers0