当我单击保存按钮时,会调用“addCompany”操作,但是当我调试并在我的支持 bean 中看到实例变量 companyName 的值时,它显示为 null。我想我正在犯一些真正愚蠢的错误。
Modal XHTML : 包含在另一个 xhtml 的表单标签中。
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:f="http://java.sun.com/jsf/core">
<rich:modalPanel id="AddDmpCompanyModalId"
showWhenRendered="#{companyAdminAction.showAddCompanyModal}"
width="500"
height="340"
autosized="true">
<f:facet name="header">
<h:outputText value="Add Company"/>
</f:facet>
<a4j:outputPanel id="addDmpCompanyInputPanel">
<label style="font-weight:bold;margin-top:5px">Name: </label>
<h:inputText id="companyName" value="#{companyAdminAction.companyName}"/>
<a4j:commandLink id="submit-add-company-name-link"
immediate="true"
action="#{companyAdminAction.addCompany()}"
styleClass="button"
reRender="AddDmpCompanyModalId,addDmpCompanyInputPanel"
limitToList="true">
<span class="inner-button">Save</span>
</a4j:commandLink>
</a4j:outputPanel>
</rich:modalPanel>
</ui:composition>
Backing Bean(接缝组件)
Name("companyAdminAction")
@Scope(ScopeType.CONVERSATION)
public class CompanyAdmin {
private String companyName;
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public void addCompany() {
// On click of save debugger comes here, but shows the value of
//companyName as null
}
}