6 Replies Latest reply on Feb 9, 2009 5:45 AM by adubovsky

    selectOneMenu with security-constraint

    rogerioag

      Even upgrading my versions of MyFaces and Richfaces, I still having a problem rendering it unable to solve, so I ask the help of colleagues.

      In a page that contains two component h: selectOneMenu, and the second items are obtained from the selection of any item in the first, with the help of the a4j: support event = onchange ..., everything works normally.

      But when I enter this page to have access control using the Tomcat by entering the configuration in web.xml

      <security-constraint>
       <web-resource-collection>
       <url-pattern>mypage.jsf</url-pattern>
       <\web-resource-collection>
       .
       .
       .
      <\security-constraint>
      


      the behavior becomes incorrect in Firefox. When I try to access this page, it opens normally, with the first selectOneMenu completed. When you select an item, only now the screen of login/password for access control in Tomcat is displayed. Fill out the information, and instead of the back page, complete with the items of the second selectOneMenu, displays a blank page containing only a select component in pure HTML. When use the IE7, it operates normally.

      What should I do to work properly in Firefox too?

        • 1. Re: selectOneMenu with security-constraint
          nbelaevski

          Hi,

          Can you please paste page and bean code here?

          • 2. Re: selectOneMenu with security-constraint
            rogerioag

            * JSF page

            <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
            <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
            <%@taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
            <%@taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
            <%@taglib uri="http://richfaces.org/rich" prefix="rich"%>
            
            <f:view>
            
            <%@include file="abrePagina.jspf"%>
            <%@include file="menuLateral.jspf"%>
            <%@include file="camadaCentral.jspf"%>
            
             <a4j:form id="form1" focus="marca">
             <h:panelGrid columns="3">
             <f:facet name="header">
             <h:outputText value="Informe os dados do novo veÃÂculo:" styleClass="tituloFormulario"/>
             </f:facet>
            
             <f:verbatim><br></f:verbatim>
             <f:verbatim><br></f:verbatim>
             <f:verbatim><br></f:verbatim>
            
             <h:outputText value="Marca do veÃÂculo:" style="font=12px"/>
             <h:selectOneMenu id="marca" valueChangeListener="#{afcMB.selecionarMarca}" styleClass="listbox" validator="#{afcMB.validaMarca}">
             <f:selectItems value="#{afcMB.marcas}"/>
             <a4j:support event="onchange" reRender="tipo" focus="tipo"/>
             </h:selectOneMenu>
             <h:message for="marca" styleClass="mensagemErro"/>
            
             <h:outputText value="Tipo do veÃÂculo:" style="font=12px"/>
             <h:selectOneMenu id="tipo" valueChangeListener="#{afcMB.selecionarTipoVeiculo}" styleClass="listbox" validator="#{afcMB.validaTipo}">
             <f:selectItems value="#{afcMB.tiposPorMarca}"/>
             <a4j:support event="onchange" reRender="veiculo" focus="veiculo"/>
             </h:selectOneMenu>
             <h:message for="tipo" styleClass="mensagemErro"/>
            
             <h:outputText value="Placa do veÃÂculo:" style="font=12px"/>
             <h:inputText id="veiculo" required="true" value="" size="40" styleClass="listbox"/>
            
             <h:inputHidden/>
             <h:panelGrid style="align:center">
             <h:commandButton id="inserirVeiculo" value="OK" action="#{afcMB.inserirVeiculo}"/>
             </h:panelGrid>
             <h:inputHidden/>
             </h:panelGrid>
             </a4j:form>
            </f:view>
            
            <%@include file="fechaPagina.jspf"%>
            


            P.S.: The code of the pages included through <%@ include file =...%> operate normally in other pages with access control, and should not affect this code.

            * AfcMB.java (managed bean)

            .
            .
             public void selecionarMarca(ValueChangeEvent evento){
             try{
             //cria a primeira opção para a caixa de seleção
             tiposPorMarca.clear();
             tiposPorMarca.add(new SelectItem(" -- selecione o tipo --"));
             for(TipoVeiculo t : tipoVeiculoFacade.getTiposVeiculos(evento.getNewValue().toString())){
             tiposPorMarca.add(new SelectItem(t.getDescricao()));
             }
             } catch (PropertiesFileException e) {
             exibeMensagem(e.getMessage());
             e.printStackTrace();
             }
             }
            
            .
            .
            .
             public List<SelectItem> getMarcas(){
             List<SelectItem> itens = new ArrayList<SelectItem>();
             try{
             //cria a opção em branco para marcas
             itens.add(new SelectItem("-- selecione a marca --"));
             for(Marca marca : marcaFacade.getMarcas()){
             itens.add(new SelectItem(marca.getDescricao()));
             }
             return itens;
             } catch (PropertiesFileException e) {
             exibeMensagem(e.getMessage());
             e.printStackTrace();
             return null;
             }
             }
            
            .
            .
            .
             public void selecionarTipoVeiculo(ValueChangeEvent evento){
             try{
             //cria a primeira opção para a caixa de seleção
             veiculosPorTipo.clear();
             veiculosPorTipo.add(new SelectItem("-- selecione a placa --"));
             if(!evento.getNewValue().toString().equals(" -- selecione o tipo --")){
             for(Veiculo v : veiculoFacade.getVeiculos(evento.getNewValue().toString())){
             veiculosPorTipo.add(new SelectItem(v.getPlaca()));
             }
             }
             } catch (PropertiesFileException e) {
             exibeMensagem(e.getMessage());
             e.printStackTrace();
             }
             }
            
             public List<SelectItem> getTiposPorMarca(){
             return this.tiposPorMarca;
             }
            
            .
            .
            .
            


            Using IE7, this page calls the request login/password and returns. When selecting an item in the first selectOneMenu, the second is completed.

            Now with Firefox, to request the page it is displayed directly. When selecting an item in the first selectOneMenu is that the screen displays the login/password and not back it. Return to a blank screen with the HTML Select component filled with the items of the second selectOneMenu.


            • 3. Re: selectOneMenu with security-constraint
              adubovsky

              Hi rogerioag

              We have verified usage security for provided page and seems like all works fine on our side.

              Our environment:
              myfaces 1.2.5
              jsp
              richfaces 3.3.1.snapshot
              java 1.5_12

              Could you please to send us the simplest war file with described problem.

              • 4. Re: selectOneMenu with security-constraint
                rogerioag

                Sorry, how can I send you the war file (I'm a beginner, never send files through the forum)?

                • 5. Re: selectOneMenu with security-constraint
                  adubovsky

                  You could send me war on my email directly: mailto:adubovsky@exadel.com

                  • 6. Re: selectOneMenu with security-constraint
                    adubovsky

                    Issue was opened. You could comment it on https://jira.jboss.org/jira/browse/RF-6129
                    Behaviout on our environment some different from you described (in FF the same, but in IE7 ajax request is not triggered at all).