0

I'm using NetBeans 8.2, JSF 2.2 and glassfish 4.1. I've tried the following portions of code:

My xhtml page code:

    <?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://xmlns.jcp.org/jsf/html"
          xmlns:f="http://xmlns.jcp.org/jsf/core">
        <h:head>
            <title>Facelet Title</title>
        </h:head>
        <h:body>
            <h:form>
                <h:inputText  value="#{myBean.inputValue}">
                    <f:validateLongRange minimum="25" maximum="40"/>
                </h:inputText>
               <h:commandButton
                   value="submit"
                   action="#{myBean.action}" />
               <h:outputText 
                   value="#{myBean.outputValue}" />
               <h:messages />
            </h:form>
        </h:body>
    </html>

My managed bean is as follow:

    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.RequestScoped;

    @ManagedBean
    @RequestScoped
    public class MyBean {
    
        private String inputValue;
        private String outputValue;
    
        public MyBean() {
        }
    
        public void action() {
            outputValue = inputValue;
        }
    
        // Getters/setters 
        public String getInputValue() {
            return inputValue;
        }
    
        public void setInputValue(String inputValue) {
            this.inputValue = inputValue;
        }
    
        public String getOutputValue() {
            return outputValue;
        }
    
    }

Everything works fine. My question is: when I inspect the resulting page

I don't see any javascript function or any other code doing the tests. I want to understand what is happening exactly, where is the part of code doing the tests?

Besides, here in the "3.3) Validator" section, I've read this:

Validation is a must for almost any application. Data entered by the clients have to be validated before being sent to the Server for processing.

Which confused me more. Does the validation happens on the client's side or on the server's side?

Community
  • 1
  • 1
ziMtyth
  • 1,008
  • 16
  • 32
  • I think it happen in JVM, note, instead of sharing images which i can't saw them in my company, can you please share the full code, so we can understand more? – Youcef LAIDANI Aug 27 '17 at 13:22
  • another thing, GlassFish 4.1 is not Payara just for information! – Youcef LAIDANI Aug 27 '17 at 13:22
  • @YCF_L I wish I could share the code, but I didn't know how to add it because it contains "<" and ">" it caused me problems when adding it :pp – ziMtyth Aug 27 '17 at 13:23
  • 1
    read this https://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks – Youcef LAIDANI Aug 27 '17 at 13:28
  • @YCF_L I don't think that it happens in the JVM because here http://javabeat.net/introduction-to-java-server-faces/ they say: "Validation is a must for almost any application. Data entered by the clients have to be validated before being sent to the Server for processing.". So when I read this I understand that the validation is done in the client side (which doesn't have necessarily a JVM ). – ziMtyth Aug 27 '17 at 13:48
  • 1
    mmm, lets wait @BlueC maybe he has an answer for that i already said **I think** ;) – Youcef LAIDANI Aug 27 '17 at 13:49
  • 1
    Never trust javabeat. Bad tutorials. And this is a **_10 year old_** one. Read the specs or stackoverflow (or http://jsf.zeef.com) and who is BlueC? And if you don't see any validations in javascript or other way on the client, where do you **think** it takes place? – Kukeltje Aug 27 '17 at 18:57
  • @Kukeltje thank you for the reply, I will take your advice. – ziMtyth Aug 28 '17 at 07:27

0 Answers0