从<h:selectonemenu>中选择项目不会更改bean属性</h:selectonemenu>

时间:2011-07-05 07:53:29

标签: jsf-2

我面对的情况,当项目选择从不改变bean属性。方法setCurrentOrg()不会被调用。 托管bean代码是:

@ManagedBean(name = "requestAccessBean")
@RequestScoped
public class RequestAccessSection {  
private List<AccessRight> accessList;
private List<OrgUnit> orgList;   
private String currentOrg;  

public String getCurrentOrg() {
return this.currentOrg;
}

public void setCurrentOrg(String currentOrg) {  
this.currentOrg = currentOrg;
}

public List<AccessRight> getAccessList() {
 if (this.accessList == null) {
  this.accessList = returnAccessList();
 }
return this.accessList;    
}

public void setAccessList(List<AccessRight> accessList) {
  this.accessList = accessList;
}

public List<OrgUnit> getOrgList() {
  if (this.orgList == null) {
    this.orgList = returnOrgList();
  }
 return this.orgList;
}

public void setOrgList(List<OrgUnit> orgList) {
  this.orgList = orgList;
}  

public List<OrgUnit> returnOrgList() {
 List<OrgUnit> orgList = new ArrayList<OrgUnit>();
 orgList = getOfficeBranches();  
 return orgList;
}

public List<AccessRight> returnAccessList() {
  List<AccessRight> accessList = new ArrayList<AccessRight>();   
  accessList = getAccessList();
  return accessList;
}

}

页面是:

    <h:form>
    <h:selectOneMenu id="orgList" value="# {requestAccessBean.currentOrg}">
     <f:selectItem itemLabel="--select--" itemValue="null"></f:selectItem>
       <f:selectItems value="#{requestAccessBean.orgList}" 
                var="org" itemLabel="#{org.ou}" itemValue="#{org.globalid}"/>
    <f:ajax event="change" execute="@this" render="accessTable"/>
</h:selectOneMenu>  

<h:dataTable var="access" value="#{requestAccessBean.accessList}"
            binding="#{requestAccessBean.htmlDataTable}" id="accessTable">
    <h:column>
        <h:selectOneRadio onclick="radioButton(this);" id="selectAccess" 
                valueChangeListener="#{requestAccessBean.setSelected}">
            <f:selectItem itemValue="null" />
        </h:selectOneRadio>
    </h:column>
    <h:column>
        <h:outputText value="#{access.title}" />
    </h:column>
</h:dataTable>
<h:form>

你能帮我吗?

1 个答案:

答案 0 :(得分:2)

<h:selectOneMenu id="orgList" value="# {requestAccessBean.currentOrg}">

这不是有效的EL。您在#{之间有一个空格。删除它。

<h:selectOneMenu id="orgList" value="#{requestAccessBean.currentOrg}">