1
(PS:我的英語很抱歉)事件並不RichFaces的叫
我在應用該文本框有一個文本字段我有一個A4J:支持,應該在onchange事件工作!所以我對Include和Update有相同的表單。 用戶用代碼填充文本字段,並在我的bean中我有一個方法,搜索等價的組合框,如果該值存在,然後將其設置爲我的bean的對象,這適用於包括但不適用於更新!我不知道這可能是什麼。我將發佈代碼。
我的XHTML頁面
<ui:decorate template="../templates/edit.xhtml">
<ui:param name="idComponente" value="codTipoVinculo" />
<ui:define name="label">Tipo Vínculo: </ui:define>
<h:inputText id="codTipoVinculo"
value="#{cadastroPrestadorBean.codTipoVinculo}"
size="4" maxlength="1"
styleClass="#{validationUtil.invalid('codTipoVinculo', facesContext) ? 'invalido' : ''}"
onkeypress="return(soEntraNumero(event,this));"
onmouseout="soArrastaNumero(this);"
onblur="soArrastaNumero(this);">
<a4j:support event="onchange"
action="#{cadastroPrestadorBean.findByKey(cadastroPrestadorBean.prestador.tipoVinculo)}"
ajaxSingle="true"
immediate="true"
focus="codTipoPgtoMatmed"
reRender="nomeTipoVinculo, codTipoVinculo, outputMessagesInForm">
<a4j:actionparam noEscape="true"
value="(document.getElementById('formPrestador:codTipoVinculo').value == '' ? '-11111' : document.getElementById('formPrestador:codTipoVinculo').value)"
assignTo="#{cadastroPrestadorBean.codTipoVinculo}" />
</a4j:support>
</h:inputText>
<rich:comboBox enableManualInput="false" defaultLabel="Selecione uma opção" id="nomeTipoVinculo"
value="#{cadastroPrestadorBean.prestador.tipoVinculo}"
converter="simpleIndexConverterTipoVinculo">
<f:selectItems
value="#{cadastroPrestadorBean.listaTipoVinculo }" />
<a4j:support event="onchange" reRender="codTipoVinculo, outputMessagesInForm"
ajaxSingle="true" limitToList="true"
action="#{cadastroPrestadorBean.findByKey(cadastroPrestadorBean.prestador.tipoVinculo)}" />
</rich:comboBox>
</ui:decorate>
我的bean方法
if (object instanceof TipoVinculo) {
if (codTipoVinculo == null || codTipoVinculo == -11111) {
prestador.setTipoVinculo(new TipoVinculo());
return;
}
for (SelectItem element : listItemsTipoVinculo) {
if ((((TipoVinculo)element.getValue()).getCodTipoVinculo().intValue()) == codTipoVinculo){
prestador.setTipoVinculo((TipoVinculo)BeanUtils.cloneBean(element.getValue()));
achou = true;
}
}
if (!achou){
prestador.setTipoVinculo(new TipoVinculo());
addMessageInfo("Tipo Vínculo inválido.");
}
achou = false;
}
這是填充listItemsTipoVinculo
public List<SelectItem> getListaTipoVinculo() {
try {
if (listItemsTipoVinculo.size() == 0){
List<TipoVinculo> list = tipoVinculoBusiness.listaTiposVinculos();
for (TipoVinculo item : list) {
listItemsTipoVinculo.add(new SelectItem(item));
}
}
} catch (CommonBusinessException e) {
addMessageError(e);
}
return listItemsTipoVinculo;
}
組合框先前居住在listItemsTipoVinculo的方法,以便當頁面開始我有它填充。當用戶將代碼放入文本框時,它應該調用findbykey方法,但它們不會!只是在我的更新屏幕上,當我的對象'prestador'被填充。