Jsf 包含在ui中的表单:包含不填充bean

Jsf 包含在ui中的表单:包含不填充bean,jsf,dynamic,primefaces,uiinclude,Jsf,Dynamic,Primefaces,Uiinclude,这是一个问题: 我们有包含xhtml表单的主页。commandButton调用操作,但作用域bean不会由inputText的值填充。代码如下: 欢迎使用\u file.xhtml <h:head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>XHTML Page</title> <h:ou

这是一个问题: 我们有包含xhtml表单的主页。commandButton调用操作,但作用域bean不会由inputText的值填充。代码如下:

欢迎使用\u file.xhtml

  <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>XHTML Page</title>
    <h:outputStylesheet name="CSS/style.css" />    
  </h:head>
    <h:body>  
        <f:facet name="last">
        <link rel="stylesheet" type="text/css" href="#{facesContext.externalContext.requestContextPath}/resources/CSS/style.css" />
        <h:outputStylesheet name="CSS/style.css" />
        </f:facet>
    <f:view contentType="text/html" id="fview">
        <p:layout  fullPage="true" resizeTitle="resize">  
            <p:layoutUnit position="north" size="68" id="north" style="font-size: 100%; text-align: center;" header="КРАУДСОРСИНГОВАЯ ПЛАТФОРМА MEPHORCE">
            <h:outputText value="#{clientBean.clientFIO.get(0)} #{clientBean.clientFIO.get(1)} #{clientBean.clientFIO.get(2)}" style="font-size: 100%; text-align: left;"/>    
            </p:layoutUnit>   
                       <p:layoutUnit position="west" id="west" resizable="false" header="Меню" style="height:580px;overflow:hidden;" size="225">
            <h:panelGroup id="menu" layout="block">

        <h:form>
        <f:ajax render=":content">
            <ul>
                <li><h:commandLink value="Профиль" action="#{beanClient.setPage('profile')}" /></li>            
                <li><h:commandLink value="Мои проекты" action="#{beanClient.setPage('my_projects')}" /></li>            
                <li><h:commandLink value="Новый проект" action="#{beanClient.setPage('new_project')}"  /></li>
                <li><h:commandLink value="Чат с модератором" action="#{beanClient.setPage('mod_chat')}" /></li> 
                <li><h:commandLink value="Сообщество" action="#{beanClient.setPage('community')}" /></li> 
                <li><h:commandLink value="Выход" action="#{clientBean.logout()}" /></li>
            </ul>
        </f:ajax>
    </h:form>
         </h:panelGroup>
            </p:layoutUnit>
 <p:layoutUnit styleClass="layoutUnitCenter" position="center">
  <h:panelGroup id="content" layout="block">
    <ui:include src="/WEB-INF/includes/client/#{beanClient.page}.xhtml" />
  </h:panelGroup>
  </p:layoutUnit>

        <p:layoutUnit position="east" size="0" style="width:0px; display:none;" id="east">
        </p:layoutUnit>

        <p:layoutUnit position="south" resizable="true" id="south">

        </p:layoutUnit>
    </p:layout>

 </f:view>
</h:body> 

XHTML页面
new_project.xhtml

    <table width="100%" height="100%" >
  <h:form id="form">  
      <p:growl id="growl" class="ui-growl"  showDetail="false"  sticky="false" life="10000"/>
    <tr>
        <td>
  <h:panelGrid columns="2"   styleClass="h_pgrid-style"  >  

    <h:outputLabel for="title" value="Название: "  styleClass="el-style"/>  
    <p:inputText id="title"  size="45" required="true"  value="#{projectBean.prTitle}" >                       
    </p:inputText>

    </h:panelGrid></td>

        <td>
      <h:panelGrid columns="2"   styleClass="h_pgrid-style"  >  


    <f:facet name="footer">    
        <h:panelGroup style="display:block; text-align:center">
            <p:commandButton id="submit" type="submit" value="Создать" process="@this" action="#{projectBean.CreateNewProjectSubmit(clientBean.clientId)}" 
                             update="growl"  ajax="true"/> 
        </h:panelGroup>
    </f:facet>          

    </h:panelGrid>  

    </td>           

    </tr>
   </h:form>    
  </table> 

项目bean类

import java.io.Serializable;
import java.sql.*;
import java.util.*;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.persistence.PrePersist;
import org.primefaces.component.inputtext.InputText;
import trg.dao.ProjectsDAOImpl;


@ManagedBean
@SessionScoped

public class ProjectBean
{
    private List<Project> projectList;

    private int prId;
    private String prTitle;
    private String prDesctiption;
    private java.util.Date prDate;
    private int prBudget;
    private String prStatus;
    private int prMod;

    public int getPrId()
    {
        return prId;
    }

    public void setPrId(int prId)
    {
        this.prId=prId;
    }

    public String getPrTitle() {
        System.out.println ("GetPrTitle:"+prTitle);
        return prTitle;
    }

    public void setPrTitle(String prTitle) {
        this.prTitle = prTitle;
        System.out.println ("SetPrTitle:"+prTitle);
    }

    public String getPrDesctiption() {
        return prDesctiption;
    }

    public void setPrDesctiption(String prDesctiption) {
        this.prDesctiption = prDesctiption;
    }

    public java.util.Date getPrDate() {
        return prDate;
    }

    public void setPrDate(java.util.Date prDate) {
        this.prDate = prDate;
    }

    public int getPrBudget() {
        return prBudget;
    }

    public void setPrBudget(int prBudget) {
        this.prBudget = prBudget;
    }

    public String getPrStatus() {
        return prStatus;
    }

    public void setPrStatus(String prStatus) {
        this.prStatus = prStatus;
    }

    public int getPrMod() {
        return prMod;
    }

    public void setPrMod(int prMod) {
        this.prMod = prMod;
    }


    public List<Project> getProjectList(int cl_id) throws  SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException
  {
      ProjectsDAOImpl projectsDAOImpl = new ProjectsDAOImpl();

      projectList = projectsDAOImpl.getProjectListClient(cl_id);
      return projectList;  

  } 

      public void CreateNewProjectSubmit(int cl_id) throws  SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException
  {

      FacesContext context=FacesContext.getCurrentInstance();

      /*ProjectsDAOImpl projectsDAOImpl = new ProjectsDAOImpl();
      projectsDAOImpl.createNewProject(prTitle, prDesctiption, prDate, prBudget, prStatus, prMod, cl_id);
*/
      FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Проект успешно создан","");
      context.addMessage(null, message);    

  }   
import java.io.Serializable;
导入java.sql.*;
导入java.util.*;
导入javax.faces.application.FacesMessage;
导入javax.faces.bean.ManagedBean;
导入javax.faces.bean.SessionScoped;
导入javax.faces.bean.ViewScoped;
导入javax.faces.component.UIComponent;
导入javax.faces.context.FacesContext;
导入javax.persistence.PrePersist;
导入org.primefaces.component.inputtext.inputtext;
导入trg.dao.ProjectsDAOImpl;
@ManagedBean
@会议范围
公共类ProjectBean
{
私人清单项目清单;
私人国际学院;
私人产权;
私有字符串描述;
private java.util.Date prDate;
私人预算;
私有字符串状态;
私人int prMod;
公共int getPrId()
{
返回prId;
}
公共无效设置优先级(内部优先级)
{
this.prId=prId;
}
公共字符串getPrTitle(){
System.out.println(“GetPrTitle:+prTitle”);
归还产权;
}
公共无效设置prTitle(字符串prTitle){
this.prTitle=prTitle;
System.out.println(“SetPrTitle:+prTitle”);
}
公共字符串getPrDesctiption(){
返回命令;
}
public void setPrDesctiption(字符串prDesctiption){
this.prDesctiption=prDesctiption;
}
public java.util.Date getPrDate(){
返回日期;
}
public void setPrDate(java.util.Date prDate){
this.prDate=prDate;
}
公共int getPrBudget(){
返回预算;
}
公共无效设置prBudget(内部prBudget){
this.prBudget=prBudget;
}
公共字符串getPrStatus(){
返回状态;
}
公共无效setpStatus(字符串pStatus){
this.prStatus=prStatus;
}
public int getPrMod(){
返回prMod;
}
公共无效设置prMod(int prMod){
this.prMod=prMod;
}
public List getProjectList(int cl_id)抛出SQLException、ClassNotFoundException、InstantiationException、IllegalAccessException
{
ProjectsDAOImpl ProjectsDAOImpl=新项目sDaoimpl();
projectList=projectsDAOImpl.getProjectListClient(cl\u id);
返回项目列表;
} 
public void CreateNewProjectSubmit(int cl_id)抛出SQLException、ClassNotFoundException、InstanceionException、IllegaAccessException
{
FacesContext context=FacesContext.getCurrentInstance();
/*ProjectsDAOImpl ProjectsDAOImpl=新项目sDaoimpl();
projectsDAOImpl.createNewProject(项目名称、项目描述、项目日期、项目预算、项目状态、项目模型、项目id);
*/
FacesMessage消息=新的FacesMessage(FacesMessage.SEVERITY_信息,“Пззззазаазазааа”和“);
addMessage(null,message);
}   
clientBean.java

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import trg.dao.ClientDAOImpl;
import trg.service.SessionBean;

@ManagedBean
@SessionScoped
public class ClientBean {
    private int clientId;
    private String clFam;
    private String clFirst;
    private String clSec;
    private String clPass;  

    public int getClientId() {
        return clientId;
    }

    public void setClientId(int clientId) {
        this.clientId = clientId;
    }

    public String getClFam() {
        return clFam;
    }

    public void setClFam(String clFam) {
        this.clFam = clFam;
    }


  public String getClFirst() {
        return clFirst;
    }

     public void setClFirst(String clFirst) {
        this.clFirst = clFirst;
    }     

  public String getClSec() {
        return clSec;
    }

     public void setClSec(String clSec) {
        this.clSec = clSec;
    }     

 public String getClPass() {
        return clPass;
    }

     public void setClPass(String clPass) {
        this.clPass = clPass;
    }             


public List<Client> getClientsList() throws  SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException
  {
      ClientDAOImpl clientDAOImpl = new ClientDAOImpl();

      List<Client> clientlist = clientDAOImpl.getClientList();

      return clientlist;  

  }

public List<String> getClientFIO() throws  SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException
  {
       ClientDAOImpl clientDAOImpl = new ClientDAOImpl();

      List<Client> clientFIO = clientDAOImpl.getFio(clientId);

      List<String> clientFIO_separated=new <String>ArrayList();

      clientFIO_separated.add(clientFIO.get(0).getClFamily());
      clientFIO_separated.add(clientFIO.get(0).getClFirstName());
      clientFIO_separated.add(clientFIO.get(0).getClSecName());

      return clientFIO_separated;  

  } 

 public String ClAuthSubmit() 
            throws  SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException  
    {

    ClientDAOImpl clientDAOImpl = new ClientDAOImpl();

    FacesContext context=FacesContext.getCurrentInstance();

      boolean valid= clientDAOImpl.rightClient(clientId, clPass);;
        if (valid) {
              HttpSession session = SessionBean.getSession();
              session.setMaxInactiveInterval(15*60);
               return("success_ClientAuth");
        }       
            else{

            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Вы ввели неверные данные","");
            context.addMessage(null, message);
            return(null);
        }

        }
public String logout() {
    FacesContext context=FacesContext.getCurrentInstance();
    HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
    HttpSession session = request.getSession(false);
         session.setAttribute("userlogged","0");
         session.setAttribute("ID", clientId);

         return "loggedout";
     }
}
import java.sql.SQLException;
导入java.util.ArrayList;
导入java.util.List;
导入javax.faces.application.FacesMessage;
导入javax.faces.bean.ManagedBean;
导入javax.faces.bean.SessionScoped;
导入javax.faces.context.FacesContext;
导入javax.servlet.http.HttpServletRequest;
导入javax.servlet.http.HttpSession;
导入trg.dao.ClientDAOImpl;
导入trg.service.SessionBean;
@ManagedBean
@会议范围
公共类ClientBean{
私人int客户ID;
私有字符串clFam;
私有字符串优先;
私有字符串clSec;
私有字符串clPass;
public int getClientId(){
返回客户ID;
}
public void setClientId(int clientId){
this.clientId=clientId;
}
公共字符串getClFam(){
返回clFam;
}
公共void setClFam(字符串clFam){
this.clFam=clFam;
}
公共字符串getClFirst(){
先返回;
}
公共void setClFirst(字符串clFirst){
this.clFirst=clFirst;
}     
公共字符串getClSec(){
返回clSec;
}
公共void setClSec(字符串clSec){
this.clSec=clSec;
}     
公共字符串getClPass(){
返回clPass;
}
公共void setClPass(字符串clPass){
this.clPass=clPass;
}             
public List getClientsList()抛出SQLException、ClassNotFoundException、InstanceionException、IllegaAccessException
{
ClientDAOImpl ClientDAOImpl=new ClientDAOImpl();
List clientlist=clientDAOImpl.getClientList();
返回客户列表;
}
public List getClientFIO()抛出SQLException、ClassNotFoundException、InstanceionException、IllegalAccessException
{
ClientDAOImpl ClientDAOImpl=new ClientDAOImpl();
List clientFIO=clientDAOImpl.getFio(clientId);
List clientFIO_separated=new ArrayList();
clientFIO_separated.add(clientFIO.get(0.getClFamily());
clientFIO_separated.add(clientFIO.get(0.getClFirstName());
clientFIO_separated.add(clientFIO.get(0.getClSecName());
返回客户fio_分离;
} 
公共字符串ClAuthSubmit()
抛出SQLException、ClassNotFoundException、InstanceionException、非法