zoukankan      html  css  js  c++  java
  • jsf--页面循环跳转,项目内容递交

    在order-flow.xml中:

    创建新的managebean:

    该位置回头待修改。

     此三处做修改

    OrderBean.java
      1 /*
      2  * To change this license header, choose License Headers in Project Properties.
      3  * To change this template file, choose Tools | Templates
      4  * and open the template in the editor.
      5  */
      6 package myBeans;
      7 
      8 import javax.inject.Named;
      9 import javax.enterprise.context.SessionScoped;
     10 import javax.inject.Named;
     11 import javax.faces.flow.FlowScoped;
     12 import java.io.Serializable;
     13 import javax.annotation.ManagedBean;
     14 
     15 /**
     16  *
     17  * @author Administrator
     18  */
     19 @Named
     20 @FlowScoped("order")
     21 
     22 public class OrderBean implements Serializable  {
     23 
     24     /**
     25      * Creates a new instance of OrderBean
     26      */
     27     private String itemCount;
     28     private String address;
     29     private String itemName;
     30     private String fankui0;
     31     private String fankui1;
     32     private String fankui2;
     33     private String fankui3;
     34     private String fankui4;
     35     public String getReturnValue(){
     36         return "/index";
     37         //“/”:相对的绝对路径
     38     }
     39     public OrderBean() {
     40         
     41     }
     42 
     43     public String getItemCount() {
     44         return itemCount;
     45     }
     46 
     47     public void setItemCount(String itemCount) {
     48         this.itemCount = itemCount;
     49     }
     50 
     51     public String getAddress() {
     52         return address;
     53     }
     54 
     55     public void setAddress(String address) {
     56         this.address = address;
     57     }
     58 
     59     public String getItemName() {
     60        
     61         return itemName;
     62     }
     63 
     64     public void setItemName(String itemName) {
     65         this.itemName = itemName;
     66     }
     67 
     68     public String getFankui0() {
     69         return fankui0;
     70     }
     71 
     72     public void setFankui0(String fankui0) {
     73         this.fankui0 = fankui0;
     74     }
     75 
     76     public String getFankui1() {
     77         return fankui1;
     78     }
     79 
     80     public void setFankui1(String fankui1) {
     81         this.fankui1 = fankui1;
     82     }
     83 
     84     public String getFankui2() {
     85         return fankui2;
     86     }
     87 
     88     public void setFankui2(String fankui2) {
     89         this.fankui2 = fankui2;
     90     }
     91 
     92     public String getFankui3() {
     93         return fankui3;
     94     }
     95 
     96     public void setFankui3(String fankui3) {
     97         this.fankui3 = fankui3;
     98     }
     99 
    100     public String getFankui4() {
    101         return fankui4;
    102     }
    103 
    104     public void setFankui4(String fankui4) {
    105         this.fankui4 = fankui4;
    106     }
    107 
    108    
    109    
    110 }
    OrderBean.java

    注:

    h:表示jsf的html

    创建一个表单,flow的入口,取名“order”

     在order.xhtml中写入代码:

     1 <?xml version='1.0' encoding='UTF-8' ?>
     2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     3 <html xmlns="http://www.w3.org/1999/xhtml"
     4       xmlns:h="http://xmlns.jcp.org/jsf/html">
     5     <h:head>
     6         <title>Select item quantity</title>
     7     </h:head>
     8     <h:body>
     9         <h:form>
    10             <h:outputText value="Item name:"/>
    11             <br/>
    12             <h:inputText value="#{orderBean.itemName}"/>
    13             <!--将itemname做一对一的绑定-->
    14             <br/><br/>
    15             <h:outputText value ="Item quantity"/>
    16             <br/>
    17             <h:inputText value="#{orderBean.itemCount}"/><!--将itemCount做一对一的绑定-->
    18             
    19              <h:commandButton value="Proceed" action="order-address"/><!--输入地址-->
    20              
    21         </h:form>
    22     </h:body>
    23 </html>
    order.xhtml

     同理,建立order-address.xhtml:

    在其中写入代码:

     1 <?xml version='1.0' encoding='UTF-8' ?>
     2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     3 <html xmlns="http://www.w3.org/1999/xhtml"
     4       xmlns:h="http://xmlns.jcp.org/jsf/html">
     5     <h:head>
     6         <title>Facelet Title</title>
     7     </h:head>
     8     <h:body>
     9          <h:form>
    10              <h:outputText value="You are about to order #{orderBean.itemCount}#{orderBean.itemName}"/>
    11             <br/>
    12             <br/>
    13             <h:outputText value ="address:"/>
    14             <br/>
    15             <h:inputText value="#{orderBean.address}"/>
    16             <!--将itemAddress做一对一的绑定-->
    17             <br/><br/>
    18              <h:commandButton value="Proceed" action="order-confirmation"/><!--下一个页面-->
    19              
    20         </h:form>
    21     </h:body>
    22 </html>
    order-address.xhml

     同理,最后一个,建立order-confirmation.xhtml:

     1 <?xml version='1.0' encoding='UTF-8' ?>
     2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     3 <html xmlns="http://www.w3.org/1999/xhtml"
     4       xmlns:h="http://xmlns.jcp.org/jsf/html">
     5     <h:head>
     6         <title>order-confirmation</title>
     7     </h:head>
     8     <h:body>
     9         <h:form>
    10         <h:outputText value="You have ordered #{orderBean.itemCount}#{orderBean.itemName}"/>
    11             <br/>
    12         <h:outputText value ="The item will be delivered at :#{orderBean.address}"/>
    13           
    14             <br/><br/>
    15         <h:commandButton value="Eixt" action="returnFromOrderFlow"/><!--结束,退出-->
    16     </h:form>
    17     </h:body>
    18 </html>
    order-configuration

    输出结果:

    解决方法:

    注:一定要使用cdibean ,修改如下:

  • 相关阅读:
    git 使用命令
    Mac上部署Jenkins,用git插件更新项目代码时报错的记录
    pycharm找不到本项目中的其他包或模块
    小米8线刷pixel experience全过程记录
    python环境清理
    怎么实现无遮罩屏蔽某些按钮的点击事件
    ios 上 WebCamTexture尺寸是16X16
    关于月份拆分
    关于const let的使用
    关于promise,const函数的使用
  • 原文地址:https://www.cnblogs.com/Catherinezhilin/p/9936341.html
Copyright © 2011-2022 走看看