由于客户的需求,我刚开始使用 BootsFaces,所以请多多包涵。
这是我的xhtml:
<h:form id="form" prependId="false">
<b:dataTable id="dtEmpresas" value="#{recController.empresas}" var="e" searching="false" striped="true"
styleClass="tabela" customLangUrl="../resources/js/lang-pt-br.json" paginated="false" pageLength="6" >
<b:dataTableColumn header-style-class="hidden" styleClass="col-md-4">
<b:selectOneMenu id="congenere" value="#{e.congenere.id}">
<!-- required="true" requiredMessage="Congenere é obrigatório"> -->
<f:selectItem noSelectionOption="true" itemLabel="[Selecione...]"
itemValue="#{null}" />
<f:selectItems value="#{recController.congeneres}" var="c"
itemLabel="#{c.nome}" itemValue="#{c.id}" />
</b:selectOneMenu>
</b:dataTableColumn>
<b:dataTableColumn styleClass="col-md-4" header-style-class="hidden">
<b:inputText id="nomeEmpresa" value="#{e.nomeEmpresa}" size="50" disabled="#{!e.ehOutros()}" />
</b:dataTableColumn>
<b:dataTableColumn styleClass="col-md-4" header-style-class="hidden">
<b:row>
<b:column styleClass="col-md-10">
<b:inputText value="#{e.cnpj}" size="50" required="false"
validatorMessage="CNPJ invalido 21" placeholder="CNPJ Recolhimento">
<f:validator validatorId="cnpjValidador" />
</b:inputText>
</b:column>
<ui:debug hotkey="j" />
<b:commandButton value=" - " action="#{recController.removeItem(e)}" update="dtEmpresas" />
<b:commandButton id="btAdd" value=" + " action="#{recController.addItem()}"
update="dtEmpresas" process="dtEmpresas" />
</b:row>
</b:dataTableColumn>
</b:dataTable>
这些按钮都没有在支持 bean 中触发他们的方法。但是,如果我移到 dataTable 之外,它们就可以正常工作。
这是 back bean,在带有 Deltaspike 的 WildFly 8 上运行:
@ViewScoped
@ManagedBean
public class RecController implements Serializable{
private static final long serialVersionUID = 1L;
private List<EmpresaRecolheInss> empresas = new ArrayList<>();
@Inject
private BaseDAO dao;
@PostConstruct
public void init(){
congeneres = dao.listar(Congenere.class);
empresas.add(new EmpresaRecolheInss());
}
public void salvar(){
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Salvo", null);
FacesContext.getCurrentInstance().addMessage(null, message);
}
public void addItem(){
empresas.add(new EmpresaRecolheInss());
}
public void removeItem(Empresa eri){
empresas.remove(eri);
}
有任何想法吗?