-1

I need to update a select menu of one another JSF page. I've tried all ways and always occurs the component not found error This my xhtml page:

<?xml version='1.0' encoding='ISO-8859-1' ?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition 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"
    xmlns:pe="http://primefaces.org/ui/extensions"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:forgeview="http://jboss.org/forge/view"   
    xmlns:p="http://primefaces.org/ui"
    template="/resources/scaffold/pageTemplate.xhtml">

    <f:metadata>
        <f:viewParam name="id" value="#{voucherBean.id}"/>
        <f:event type="preRenderView" listener="#{voucherBean.retrieve}"/>

    </f:metadata>

    <ui:param name="pageTitle" value="Create Voucher"/>

    <ui:define name="header">

    </ui:define>

    <ui:define name="subheader">
        <c:choose>
            <c:when test="#{!empty voucherBean.id}">
                Edição 
            </c:when>
            <c:otherwise>
                Emissão
            </c:otherwise>
        </c:choose>
    </ui:define>

    <ui:define name="footer"/>

    <ui:define name="main" >
        <h:form role="form" prependId="false" id="create"  acceptcharset="ISO-8859-1">
            <h:messages globalOnly="true" styleClass="error"/>

            <h:panelGrid columnClasses="label,component,required" columns="3">
                <h:outputLabel for="voucherBeanVoucherDataEmissao" value="Data Emissão:"/>
                <h:panelGroup>
                    <h:inputText styleClass="form-control"  id="voucherBeanVoucherDataEmissao" value="#{voucherBean.voucher.dataEmissao}" readonly="true">
                        <f:convertDateTime type="date"/>
                    </h:inputText>
                    <h:message for="voucherBeanVoucherDataEmissao" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherHora" value="Hora:"/>
                <h:panelGroup>
                    <h:inputText styleClass="form-control" id="voucherBeanVoucherHora" value="#{voucherBean.voucher.hora}" readonly="true">
                        <f:convertDateTime type="time"/>
                    </h:inputText>
                    <h:message for="voucherBeanVoucherHora" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherBandeiraIntervalo" value="Bandeira:"/>
                <h:panelGroup>
                    <h:inputText styleClass="form-control" value="#{voucherBean.voucher.bandeiraIntervalo.bandeira.nome}" readonly="true" />
                    <h:inputHidden id="voucherBeanVoucherBandeiraIntervalo" value="#{voucherBean.voucher.bandeiraIntervalo}" placeholder="#{voucherBean.voucher.bandeiraIntervalo.bandeira.nome}" readonly="true" />
                    <h:message for="voucherBeanVoucherBandeiraIntervalo" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherOrigem" value="Origem:"/>
                <h:panelGroup>
                    <h:selectOneMenu styleClass="form-control" disabled="true" converter="#{origemBean.converter}" readonly="true"  id="voucherBeanVoucherOrigem" value="#{voucherBean.voucher.origem}">
                        <f:selectItem/>
                        <f:selectItems itemLabel="#{forgeview:display(_item.nome)}" itemValue="#{_item}" value="#{origemBean.all}" var="_item"/>
                    </h:selectOneMenu>
                    <h:message for="voucherBeanVoucherOrigem" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherDestinoVoucher" value="Destino:"/>
                <h:panelGroup>
                    <h:inputText styleClass="form-control" id="voucherBeanVoucherDestinoVoucher" value="#{voucherBean.voucher.destinoVoucher}" readonly="true"/>
                    <h:message for="voucherBeanVoucherDestinoVoucher" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherDistanciaKm" value="Distancia Km:"/>
                <h:panelGroup>
                    <h:inputText styleClass="form-control" id="voucherBeanVoucherDistanciaKm" value="#{voucherBean.voucher.distanciaKm}" readonly="true"/>
                    <h:message for="voucherBeanVoucherDistanciaKm" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherTarifaCorrida" value="Valor km rodado:"/>
                <h:panelGroup>
                    <h:selectOneMenu styleClass="form-control" disabled="true" converter="#{tarifaCorridaBean.converter}" id="voucherBeanVoucherTarifaCorrida" value="#{voucherBean.voucher.tarifaCorrida}" readonly="true">
                        <f:selectItem/>
                        <f:selectItems itemLabel="#{forgeview:display(_item.valorKm)}" itemValue="#{_item}" value="#{tarifaCorridaBean.all}" var="_item"/>
                    </h:selectOneMenu>
                    <h:message for="voucherBeanVoucherTarifaCorrida" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherVolumePequeno" value="Quantidade de Volumes Pequenos:"/>
                <h:panelGroup>
                    <h:inputHidden id="tarifaVPequenos" value="#{searchBean.valorVPequenos}"/>
                    <h:inputHidden id="isentoVPequenos" value="#{searchBean.isentoVolumesMao}"/>
                    <h:inputText styleClass="form-control" id="voucherBeanVoucherVolumePequeno" value="#{voucherBean.voucher.volumePequeno}"  onkeyup="calculaTarifaVolumesPequenos()" required="true"/>
                    <h:message for="voucherBeanVoucherVolumePequeno" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherTotalVolumesPequenos" value="Total Cobrado por Volumes Pequenos:"/>
                <h:panelGroup>
                    <h:inputText styleClass="form-control" id="voucherBeanVoucherTotalVolumesPequenos"  readonly="true" />
                    <h:inputHidden id="voucherBeanVoucherTotalVolumesPequenos1" value="#{voucherBean.voucher.totalVolumesPequenos}" />
                    <h:message for="voucherBeanVoucherTotalVolumesPequenos" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherVolumeNormal" value="Quantidade de Volumes Normais:"/>
                <h:panelGroup>
                    <h:inputHidden id="tarifaVNormais" value="#{searchBean.valorVNormais}" readonly="true"/>
                    <h:inputHidden id="isentoVNormais" value="#{searchBean.isentoVolumesNormais}"/>
                    <h:inputText styleClass="form-control" id="voucherBeanVoucherVolumeNormal" value="#{voucherBean.voucher.volumeNormal}" onkeyup="calculaTarifaVolumesNormais()" required="true"/>
                    <h:message for="voucherBeanVoucherVolumeNormal" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherTotalVolumesNormais" value="Total Cobrado por Volumes Normais:"/>
                <h:panelGroup>
                    <h:inputText styleClass="form-control" id="voucherBeanVoucherTotalVolumesNormais" readonly="true" />
                    <h:inputHidden  id="voucherBeanVoucherTotalVolumesNormais1" value="#{voucherBean.voucher.totalVolumesNormais}"  />
                    <h:message for="voucherBeanVoucherTotalVolumesNormais" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherVolumeGrande" value="Quantidade de Volumes Grandes:"/>
                <h:panelGroup>
                    <h:inputHidden id="tarifaVGrandes" value="#{searchBean.valorVGrandes}" readonly="true"/>
                    <h:inputText styleClass="form-control" id="voucherBeanVoucherVolumeGrande" value="#{voucherBean.voucher.volumeGrande}" onkeyup="calculaTarifaVolumesGrandes()" required="true"/>
                    <h:message for="voucherBeanVoucherVolumeGrande" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherTotalVolumesGrandes" value="Total Volumes Grandes:"/>
                <h:panelGroup>
                    <h:inputText styleClass="form-control" id="voucherBeanVoucherTotalVolumesGrandes" readonly="true" />
                    <h:inputHidden id="isentoVGrandes" value="#{searchBean.isentoVolumesGrandes}"/>
                    <h:inputHidden id="voucherBeanVoucherTotalVolumesGrandes1" value="#{voucherBean.voucher.totalVolumesGrandes}" />
                    <h:message for="voucherBeanVoucherTotalVolumesGrandes" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherVeiculo" value="Prefixo:"/>
                <h:panelGroup styleClass="form-group"> 
                    <h:selectOneMenu converter="#{veiculoBean.converter}" id="voucherBeanVoucherVeiculo" styleClass="form-control" value="#{voucherBean.voucher.veiculo}">
                        <f:selectItem/>
                        <f:selectItems itemLabel="#{forgeview:display(_item.prefixo)}" itemValue="#{_item}" value="#{veiculoBean.all}" var="_item" />
                    </h:selectOneMenu>

                     <h:link outcome="prefixoModal.xhtml" value="+" target="_new"   styleClass="btn btn-success" 
                        style="vertical-align:bottom"/>
                        <h:message for="voucherBeanVoucherVeiculo" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>             
                <h:outputLabel for="voucherBeanVoucherPessoa" value="Passageiro:"/>
                <h:panelGroup>
                    <h:selectOneMenu styleClass="form-control" converter="#{pessoaBean.converter}" id="voucherBeanVoucherPessoa" value="#{voucherBean.voucher.pessoa}" >
                        <f:selectItem/>
                        <f:selectItems itemLabel="#{forgeview:display(_item.nome)}" itemValue="#{_item}" value="#{pessoaBean.all}" var="_item"/>
                    </h:selectOneMenu>
                     <div  class="btn-group">
                     <h:link outcome="/voucher/passageiromodal.xhtml" value="+" target="_new"   styleClass="btn btn-success" 
                        style="vertical-align:bottom" />                
                     </div>
                    <h:message for="voucherBeanVoucherPessoa" styleClass="error"/>      
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherValorCorrida" value="Valor Corrida:"/>
                <h:panelGroup >
                    <h:inputText id="voucherBeanVoucherValorCorrida" value="#{voucherBean.voucher.valorCorrida}" 
                        styleClass="form-control" readonly="true"/>                         
                    <h:inputHidden  id="searchBeanValorCorrida" 
                        styleClass="form-control" readonly="true"/>                     
                    <h:inputHidden id="voucherBeanVoucherValorCorrida1" value="#{voucherBean.voucher.valorCorrida}" />
                    <h:message for="voucherBeanVoucherValorCorrida" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherValorExtras" value="Valor Extras:"/>
                <h:panelGroup>
                    <h:inputText styleClass="form-control" id="voucherBeanVoucherValorExtras" readonly="true"/>
                    <h:inputHidden  id="voucherBeanVoucherValorExtras1" value="#{voucherBean.voucher.valorExtras}"  /> 
                    <h:message for="voucherBeanVoucherValorExtras" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>         
                <h:outputLabel for="voucherBeanVoucherValorVoucher" value="Valor Total Voucher:"/>
                <h:panelGroup>
                    <h:inputText styleClass="form-control" id="voucherBeanVoucherValorVoucher" readonly="true" />
                    <h:inputHidden id="voucherBeanVoucherValorVoucher1" value="#{voucherBean.voucher.valorVoucher}" />      
                    <h:message for="voucherBeanVoucherValorVoucher" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/> 
                <h:outputLabel for="voucherBeanVoucherFormaPagamento" value="Forma Pagamento:"/>
                <h:panelGroup>
                    <h:selectOneMenu styleClass="form-control" converter="#{formaPagamentoBean.converter}" id="voucherBeanVoucherFormaPagamento" value="#{voucherBean.voucher.formaPagamento}">
                        <f:selectItem/>
                        <f:selectItems itemLabel="#{forgeview:display(_item.nome)}" itemValue="#{_item}" value="#{formaPagamentoBean.all}" var="_item"/>
                    </h:selectOneMenu>
                    <h:message for="voucherBeanVoucherFormaPagamento" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherConvenio" value="Convênio:"/>
                <h:panelGroup>
                    <h:selectOneMenu styleClass="form-control"  converter="#{convenioBean.converter}" id="voucherBeanVoucherConvenio" value="#{voucherBean.voucher.convenio}">
                        <f:selectItem/>
                        <f:selectItems itemLabel="#{forgeview:display(_item.nomeFantasia)}" itemValue="#{_item}" value="#{convenioBean.all}" var="_item"/>
                    </h:selectOneMenu>
                    <h:message for="voucherBeanVoucherConvenio" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>             
                <h:outputLabel for="voucherBeanVoucherObservacao" value="Observação:"/>
                <h:panelGroup>
                    <h:inputTextarea  styleClass="form-control" id="voucherBeanVoucherObservacao" value="#{voucherBean.voucher.observacao}"/>
                    <h:message for="voucherBeanVoucherObservacao" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherEmbarque" value="Embarque:"/>
                <h:panelGroup>
                    <h:selectBooleanCheckbox id="voucherBeanVoucherEmbarque" value="#{voucherBean.voucher.embarque}"/>
                    <h:message for="voucherBeanVoucherEmbarque" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>
                <h:outputLabel for="voucherBeanVoucherUsuario" value="Usuário:"/>
                <h:panelGroup>
                    <h:selectOneMenu styleClass="form-control" converter="#{usuarioBean.converter}" id="voucherBeanVoucherUsuario" value="#{voucherBean.voucher.usuario}" disabled="true">
                        <f:selectItem/>
                        <f:selectItems itemLabel="#{forgeview:display(_item.nome
                        )}" itemValue="#{_item}" value="#{usuarioBean.all}" var="_item"/>
                    </h:selectOneMenu>
                    <h:message for="voucherBeanVoucherUsuario" styleClass="error"/>
                </h:panelGroup>
                <h:outputText/>

            </h:panelGrid>      
            <div class="buttons">
                <h:commandButton value="#{msg['btn-save']}" action="#{voucherBean.update}" styleClass="btn btn-primary"/>
                <c:choose>
                    <c:when test="#{!empty voucherBean.id}">
                        <h:link value="#{msg['btn-cancel']}" outcome="view" styleClass="btn btn-primary">
                            <f:param name="id" value="#{voucherBean.id}"/>
                        </h:link>
                        <h:commandButton value="#{msg['btn-delete']}" action="#{voucherBean.delete}" styleClass="btn btn-primary"/>
                    </c:when>
                    <c:otherwise>
                        <h:link value="#{msg['btn-cancel']}" outcome="search" styleClass="btn btn-primary"/>
                    </c:otherwise>
                </c:choose>

            </div>
        </h:form>   
    </ui:define>                    
</ui:composition>

I looked in the browser and it is compiled as:

<select id="j_idt30:voucherBeanVoucherVeiculo" name="j_idt30:voucherBeanVoucherVeiculo" class="form-control" size="1">  <option value="" selected="selected"></option>
    <option value="61">1560</option>
    <option value="97">1870</option>
    ...............
</select>

I try to update this button to select one menu:

<p:commandButton action="#{veiculoBean.updateModal()}" value="#{msg['btn-save']}" styleClass="btn btn-primary"  >
    <p:ajax update=":j_idt30:voucherBeanVoucherVeiculo"/>       
</p:commandButton> 
csf
  • 961
  • 3
  • 13
  • 28

1 Answers1

2

You have prependId=false on your form. This is ignored (according to specs) by ajax calls. So remove that, give the form an id and use that in the update. See also UIForm with prependId="false" breaks <f:ajax render>

Community
  • 1
  • 1
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • I had already trying this. Removed ``prependId = false`` and use ``id = "create"``. And on page is: `` `` And change to ``update=":j_idt30:create:voucherBeanVoucherVeiculo"/> `` and gave component not found error ``:j_idt30`` – csf Mar 13 '15 at 13:10
  • Please help me http://stackoverflow.com/questions/29547315/cannot-find-component-with-expression – csf Apr 09 '15 at 19:32