2012-11-25 65 views
0

,同時運行這段代碼爲/facelet/crew/objectMapGossip.xhtml @14,94 value="#{objcetMapBean.searchCrewParam.staffNum}": Property 'staffNum' not readable on type java.lang.String我收到錯誤 請幫我從這個小錯誤。我是新來的JSF的東西基本如此stucking ...提前 感謝:-)如何從支持bean映射jsf中的對象?

這是我的支持bean ... import javax.faces.bean.ManagedBean;

@ManagedBean(name = "objcetMapBean") 

public class ObjectMapGossip { 
private SearchCrew1 searchCrewParam = new SearchCrew1("212","kart","asd"); 

public SearchCrew1 getSearchCrewParam() { 
    return searchCrewParam; 
} 

public void setSearchCrewParam(SearchCrew1 searchCrewParam) { 
    this.searchCrewParam = searchCrewParam; 
} 

public String search() { 
    return "success"; 
} 

} 

class SearchCrew1 { 

public SearchCrew1() { 
    super(); 
} 
/** 
* @param staffNum 
* @param surName 
* @param rank 
*/ 
public SearchCrew1(String staffNum, String surName, String rank) { 
    super(); 
    this.staffNum = staffNum; 
    this.surName = surName; 
    this.rank = rank; 
} 

private String staffNum; 

private String surName; 

private String rank; 

public String getStaffNum() { 
    return staffNum; 
} 

public void setStaffNum(String staffNum) { 
    this.staffNum = staffNum; 
} 

public String getSurName() { 
    return surName; 
} 

public void setSurName(String surName) { 
    this.surName = surName; 
} 

public String getRank() { 
    return rank; 
} 

public void setRank(String rank) { 
    this.rank = rank; 
} 

}

這是我的JSF頁面

<?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://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:ui="http://java.sun.com/jsf/facelets"> 
<h:body> 
    <ui:composition template="/facelet/layout/mainlayout.xhtml"> 
     <ui:define name="content"> 
      <h:form> 
       <div align="left"> 
        <h:outputText value="Staff Number: " /> 
        <h:inputText id="staffnum" size="6" value="# {objcetMapBean.searchCrewParam.staffNum}" /> 
        <h:outputText value="Surname: " /> 
        <h:inputText id="surname" size="10" maxlength="25" value="# {objcetMapBean.searchCrewParam.surName}" /> 
        <h:outputText value="Rank: " /> 
        <h:inputText id="rank" size="3" value="#{objcetMapBean.searchCrewParam.rank}" /> 
        <h:commandButton value="Search" action="#{objcetMapBean.search}" /> 
       </div> 
     </h:form> 
     </ui:define> 
    </ui:composition> 
    </h:body> 
</html> 

回答