1 Reply Latest reply on Oct 7, 2010 4:53 AM by Ilya Shaikovsky

    Doubts about RichFaces with Jquery.

    Jonathan Muniz Newbie

      I'm trying to disable an inputText when a comboBox has a certain value.

      If i use:

      <rich:jQuery selector="[id$=selectEmpresa]"  query="change(function() { alert(jQuery('#formAcademia:selectEmpresa option:selected').text());})"/> It returns the values of all selected comboBox.

      The part that I want to do that is bold.

      How can I do this?

       

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:t="http://myfaces.apache.org/tomahawk"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:rich="http://richfaces.org/rich"
          xmlns:a4j="http://richfaces.org/a4j"
          xmlns:ui="http://java.sun.com/jsf/facelets">
      <ui:composition template="templates/template.xhtml">
          <ui:define name="customScripts">
              <a4j:loadScript src="/js/jquery.meio.mask.min.js" />
          </ui:define>
          <ui:define name="caminhoFuncionalidade" class="txt_titulo">
              Condicionamento Físico 
              <img height="15" width="15" class="seta marginLeft05"
                  src="imagens/seta.gif" />
              <span class="marginLeft05">Cadastros</span>
              <img height="15" width="15" class="seta marginLeft05"
                  src="imagens/seta.gif" />
              <h:commandLink action="consultarAcademia"
                  styleClass="id_pagina marginLeft05" value="Academia" />
          </ui:define>
          <ui:define name="body">
              <h:form id="formAcademia">
                  <ul class="lista_form">
                      <li><span class="span_linha"> <h:outputLabel
                          value="Período" styleClass="txt_label" for="periodoInicial" /> </span> <span
                          class="span_left"> <rich:calendar id="periodoInicial"
                          inputClass="campo" label="Período Inicial" enableManualInput="true"
                          datePattern="dd/MM/yyyy" inputSize="10"
                          value="#{manterAcademiaMB.filtro.dataInicio}"/>
                          <rich:jQuery selector="[id$=periodoInicialInputDate]" query="setMask({mask:'39/19/9999',maxLength: 10})" />
                          
                      </span> <span class="span_left"> <h:outputLabel value="até"
                          styleClass="txt_label input_largura080 marginLeft05 marginRigth05"
                          for="periodoFinal" /> </span> <span class="span_left"> <rich:calendar
                          id="periodoFinal" inputClass="campo marginLeft05"
                          label="Período Final" enableManualInput="true"
                          datePattern="dd/MM/yyyy" inputSize="10"
                          value="#{manterAcademiaMB.filtro.dataFim}" />
                          <rich:jQuery selector="[id$=periodoFinalInputDate]" query="setMask({mask:'39/19/9999',maxLength: 10})" />
                           </span></li>
                  </ul>
      
      
                  <ul class="lista_form">
                      <li class="li_largura120"><span class="span_left span_linha">
                      <h:outputLabel value="Empresa" styleClass="txt_label"
                          for="selectEmpresa" /> </span> <span class="span_left"> 
                          <h:selectOneMenu id="selectEmpresa"
                          onchange="document.getElementById('formAcademia:processando_op').style.visibility='visible';submit();"
                          label="Empresa" styleClass="campo input_largura100" valueChangeListener="#{manterAcademiaMB.alterarEmpresaConsulta}"
                          value="#{manterAcademiaMB.filtro.orgaoMenor.empresa.id}">
                          <f:selectItem itemLabel="Selecione" itemValue="" />
                          <t:selectItems value="#{manterAcademiaMB.empresas}" var="empresa"
                              itemLabel="#{empresa.descricaoIBM}" itemValue="#{empresa.id}" />
                          <a4j:support reRender="textUnidade" event="onchange" ajaxSingle="true" />
                      </h:selectOneMenu> </span></li>
                      <li class="li_largura120"><span class="span_left span_linha">
                      <h:outputLabel value="Unidade Cliente" styleClass="txt_label"
                          for="textUnidade" /> </span> <span class="span_left"> 
                          <h:inputText value="#{manterAcademiaMB.filtro.orgaoMenor.sigla}" disabled="true"
                          id="textUnidade" size="40" label="Unidade Cliente" maxlength="100"
                          styleClass="campo input_largura230" /> 
                          <rich:suggestionbox id="selectUnidade" for="textUnidade" 
                          suggestionAction="#{manterAcademiaMB.autoCompleteUnidadeConsulta}"
                          var="unidade" fetchValue="#{unidade.sigla}" rows="20" width="240"
                          minChars="2"nothingLabel="Nenhuma unidade encontrada para a empresa selecionada"
                          columnClasses="center" usingSuggestObjects="true">
                          <h:column>
                              <h:outputText value="#{unidade.sigla}" />
                          </h:column>
                          <a4j:support event="onselect" ajaxSingle="true" reRender="desc">
                              <f:setPropertyActionListener value="#{unidade}"
                                  target="#{manterAcademiaMB.filtro.orgaoMenor}" />
                          </a4j:support>
                      </rich:suggestionbox> </span></li>
      
                      <rich:jQuery selector="[id$=selectEmpresa]"  query="change(function() { alert(jQuery('#formAcademia:selectEmpresa option:selected').text());})"/>
                      
                      
                  </ul>
      
      
                  <ul class="lista_form">
                      <li class="li_largura320"><span class="span_left span_linha">
                      <h:outputLabel value="Nome" styleClass="txt_label" for="txt_nome" />
                      </span> <span class="span_left"> <h:inputText id="txt_nome"
                          size="30" styleClass="campo input_largura300" maxlength="50"
                          value="#{manterAcademiaMB.filtro.academia.nome}" /> </span></li>
                      <li class="li_largura160"><span class="span_left span_linha">
                      <h:outputLabel value="Tipo" styleClass="txt_label" for="selectTipo" />
                      </span> <span class="span_left"> <h:selectOneMenu id="selectTipo"
                          label="Tipo" styleClass="campo input_largura140"
                          value="#{manterAcademiaMB.filtro.academia.tipo}">
                          <f:selectItem itemLabel="Selecione" itemValue="" />
                          <t:selectItems value="#{manterAcademiaMB.tiposAcademias}"
                              var="tipo" itemLabel="#{tipo.descricao}" itemValue="#{tipo}" />
                      </h:selectOneMenu> </span></li>
                      <li class="li_largura200"><span class="span_left span_linha">
                      <h:outputLabel value="Classificação" styleClass="txt_label"
                          for="selectClassificacao" /> </span> <span class="span_left"> <h:selectOneMenu
                          id="selectClassificacao" label="Tipo"
                          styleClass="campo input_largura160"
                          value="#{manterAcademiaMB.filtro.classificacao}">
                          <f:selectItem itemLabel="Selecione" itemValue="" />
                          <t:selectItems value="#{manterAcademiaMB.classificacoesAcademias}"
                              var="classificacao" itemLabel="#{classificacao.descricao}"
                              itemValue="#{classificacao}" />
                      </h:selectOneMenu> </span></li>
                  </ul>
      
      
                  <ul class="lista_form">
                      <li class="li_largura120"><span class="span_left span_linha">
                      <h:outputLabel value="Situação" styleClass="txt_label"
                          for="txt_situacao" /> </span> <span class="span_left"> <h:selectOneMenu
                          id="selectSituacao" label="Situação"
                          styleClass="campo input_largura100"
                          value="#{manterAcademiaMB.filtro.academia.situacao}">
                          <f:selectItem itemLabel="Selecione" itemValue="" />
                          <t:selectItems value="#{manterAcademiaMB.situacoesAcademias}"
                              var="situacao" itemLabel="#{situacao.descricao}"
                              itemValue="#{situacao}" />
                      </h:selectOneMenu> </span></li>
                      <li class="li_largura120"><span class="span_left span_linha">
                      <h:outputLabel value="Estado" styleClass="txt_label"
                          for="selectEstado" /> </span> <span class="span_left"> <h:selectOneMenu
                          id="selectEstado" label="Estado"
                          styleClass="campo input_largura100" converter="EstadoPkConverter"
                          valueChangeListener="#{manterAcademiaMB.alterarEstadoConsulta}"
                          value="#{manterAcademiaMB.filtro.estado.id}">
                          <f:selectItem itemLabel="Selecione" itemValue="" />
                          <t:selectItems value="#{manterAcademiaMB.estados}" var="estado"
                              itemLabel="#{estado.id.id}" itemValue="#{estado.id}" />
                          <a4j:support reRender="selectMunicipio,selectImovel"
                              event="onchange" ajaxSingle="true" />
                      </h:selectOneMenu> </span></li>
                      <li class="li_largura240"><span class="span_left span_linha">
                      <h:outputLabel value="Município" styleClass="txt_label"
                          for="selectMunicipio" /> </span> <span class="span_left"> <h:selectOneMenu
                          id="selectMunicipio" label="Município"
                          styleClass="campo input_largura220"
                          converter="MunicipioPkConverter"
                          value="#{manterAcademiaMB.filtro.municipio.id}">
                          <f:selectItem itemLabel="Selecione" itemValue="" />
                          <t:selectItems value="#{manterAcademiaMB.municipios}"
                              var="municipio" itemLabel="#{municipio.descricao}"
                              itemValue="#{municipio.id}" />
                      </h:selectOneMenu> </span></li>
                      <li class="li_largura160"><span class="span_left span_linha">
                      <h:outputLabel value="Imóvel" styleClass="txt_label"
                          for="selectImovel" /> </span> <span class="span_left"> <h:selectOneMenu
                          id="selectImovel" label="Município"
                          styleClass="campo input_largura160" converter="javax.faces.Long"
                          value="#{manterAcademiaMB.filtro.imovel.id}">
                          <f:selectItem itemLabel="Selecione" itemValue="" />
                          <t:selectItems value="#{manterAcademiaMB.imoveis}" var="imovel"
                              itemLabel="#{imovel.descricao}" itemValue="#{imovel.id}" />
                      </h:selectOneMenu> </span></li>
                  </ul>
      
      
                  <div class="div_botao">
      
      
                  <ul class="ul_botao">
                      <li class="li_largura120"><h:commandButton id="bt_pesquisar"
                          styleClass="botao" value="Pesquisar"
                          action="#{manterAcademiaMB.consultar}" /></li>
                      <li class="li_largura120"><h:commandButton id="bt_limpar"
                          styleClass="botao" value="Limpar"
                          action="#{manterAcademiaMB.prepararConsulta}" /></li>
                      <li class="li_largura120"><h:commandButton id="bt_incluir"
                          styleClass="botao" value="Incluir"
                          action="#{manterAcademiaMB.prepararInclusao}" /></li>
                  </ul>
                  </div>
                  <t:div styleClass="tabContainer est_tabela" id="div_tabela_academia">
                      <rich:dataTable value="#{manterAcademiaMB.academias}" rows="10"
                          rendered="#{manterAcademiaMB.total > 0}"
                          columnsWidth="1%,1%,1%,1%,46%,10%,10%,30%" id="tabelaAcademia"
                          var="academia" reRender="datascroller,messages">
                          <rich:column>
                              <h:commandButton image="imagens/detalhar.gif" styleClass="icone"
                                  action="#{manterAcademiaMB.detalhar}" value="Detalhar"
                                  title="Detalhar" />
                          </rich:column>
                          <rich:column>
                              <h:commandButton image="imagens/anexar.gif" styleClass="icone"
                                  action="#{manterAcademiaMB.prepararInclusaoAvaliacoes}"
                                  value="Incluir Avaliação" title="Incluir Avaliação" />
                          </rich:column>
                          <rich:column>
                              <h:commandButton image="imagens/editar.gif" styleClass="icone"
                                  action="#{manterAcademiaMB.prepararEdicao}" value="Editar"
                                  title="Alterar Modalidade de Atividade Física" />
                          </rich:column>
                          <rich:column>
                              <h:commandButton image="imagens/excluir.gif" styleClass="icone"
                                  action="#{manterAcademiaMB.confirmarExclusao}"
                                  onclick='return confirm("Confirma Exclusão do Item Selecionado ? ")'
                                  value="Excluir" title="Excluir Modalidade de Atividade Física" />
                          </rich:column>
                          <rich:column sortBy="#{academia.nome}" sortOrder="ASCENDING">
                              <f:facet name="header">Academia</f:facet>
                              <h:outputText value="#{academia.nome}" />
                          </rich:column>
                          <rich:column sortBy="#{academia.tipo.descricao}"
                              sortOrder="ASCENDING">
                              <f:facet name="header">Tipo</f:facet>
                              <h:outputText value="#{academia.tipo.descricao}" />
                          </rich:column>
                          <rich:column sortBy="#{academia.situacao.descricao}"
                              sortOrder="ASCENDING">
                              <f:facet name="header">Situação</f:facet>
                              <h:outputText value="#{academia.situacao.descricao}" />
                          </rich:column>
                          <rich:column sortBy="#{academia.municipio.estado.descricao}"
                              sortOrder="ASCENDING">
                              <f:facet name="header">Estado</f:facet>
                              <h:outputText value="#{academia.municipio.estado.descricao}" />
                          </rich:column>
                          <f:facet name="footer">
                              <rich:columnGroup rendered="#{manterAcademiaMB.total > 0}">
                                  <rich:column colspan="8">
                                      <h:outputText
                                          value="Total de Resultados : #{manterAcademiaMB.total}" />
                                  </rich:column>
                              </rich:columnGroup>
                          </f:facet>
                      </rich:dataTable>
                  </t:div>
                  <div id="div_datascroller"><rich:datascroller
                      for="tabelaAcademia" id="datascroller" renderIfSinglePage="false" />
                  </div>
                  <div style="width: 128px; margin: 0 auto"><h:graphicImage
                      id="processando_op" style="visibility:hidden"
                      value="/imagens/bar-loader.gif" alt="Processando..." /> <a4j:status
                      id="statusAtualizandoProducao">
                      <f:facet name="start">
                          <h:graphicImage value="/imagens/bar-loader.gif"
                              alt="Processando..." />
                      </f:facet>
                  </a4j:status></div>
              </h:form>
          </ui:define>
      </ui:composition>
      </html>