netbean create jsf project

Steps to develop JSF:
1. Develop page
2. Develop managed Bean
3. Configure managed Bean (optional) or annotation
4. Define navigation rules

1. Install the software first

2. Configuration

Tools -> Selection ->java ->Java Card ->Activation

Insert picture description here

Insert picture description here

Insert picture description here

Insert picture description here

3. New page *.xhtml page

Web page–>New–>Other–>JavaServer Faces–>JSF page
Insert picture description here

<?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">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:form>
            请输入姓名:<h:inputText value="" />
            <h:commandButton action="" />
        </h:form>
    </h:body>
</html>

4. Develop managed beans

<default package> --> Java class -->

Insert picture description here
Insert picture description here

4.1 Writing a bean

Add field
Right mouse button -> insert code -> getter and setter

public class HelloBean {
    
    
    private String name;

    public String getName() {
    
    
        return name;
    }

    public void setName(String name) {
    
    
        this.name = name;
    }
}

5. Configure the bean

WEB-INF right mouse button -> New -> Others -> JavaServer Faces -> JSF Faces Configuration -> Next -> Finish

Guess you like

Origin blog.csdn.net/zx77588023/article/details/109636629
jsf