0

I have a little problem with JSF,

I've made simple JSF page to learn:

 <?xml version="1.0" encoding="UTF-8" ?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML      1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"     xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
 <h:head>
   <title>register</title>
   <meta http-equiv="Content-Type"
content="application/xhtml+xml; charset=UTF-8" />
  </h:head>
  <h:body>
<h:form>
    <h:outputText value="Hello."/>
    <h:inputText value="#{login.name}"/> 
    <h:outputText value="Password"/>
    <h:inputText value="#{login.password}"/>

    <h:button value="Getgreeeting" outcome="welcome"/>
</h:form>




 </h:body>
 </html>

And another page to show the values inserted to bean:

<?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML  1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>welcome</title>
<meta http-equiv="Content-Type"
content="application/xhtml+xml; charset=UTF-8" />
</h:head>
<h:body>
<h:outputText value="#{login.name}"></h:outputText>
<h:outputText value="Yours password #{login.password}"></h:outputText>

 </h:body>
 </html>

I've made some System.out.println() methods and they present that only getters in my beans works. Can somebody explain me why? What is solutionof my problem?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
code_pretty
  • 145
  • 3
  • 15

1 Answers1

1

The <h:button> is not a submit button. It's a navigation button. Look closer at the Hello World example in your book/tutorial/resource (if you have any ..). You need a <h:commandButton> instead.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Then either the problem is caused elsewhere than visible in the information provided so far, or you're not running the code you think you're running. To start excluding, are you familiar with HTTP and HTML? – BalusC Sep 16 '13 at 13:04
  • yes I am - I think I am :) . What I have to do to run this code? – code_pretty Sep 16 '13 at 13:24
  • Okay, check in the browser's HTTP monitor which kind of HTTP request you see when the `` is pressed and show the form data. – BalusC Sep 16 '13 at 13:27