This discussion is archived
5 Replies Latest reply: Jul 13, 2012 11:20 AM by 948283 RSS

RichFaces editor , popup and upload problems

948283 Newbie
Currently Being Moderated
Hello,
I am building a JSF 2.0 page like this: after a selection in a combobox in the page top, a pair of RadioButton items opens, each one with an edition option of a field: text (via rich:editor, RichFaces 4) or file upload (a javax.faces.component.html.HtmlInputText descendent component , built here). The clicked option opens a popup (rich:popupPanel). However, the upload popup doesn't make the upload (it makes it in other pages of the system), reload the whole page after clicking "upload" (this effect is like this in all other local pages), and this reload erases all previous data page, even the first combobox selection (this couldn't happen). Plus, in the "text" option, the typed text disappears after "save" command - the saved text is the previously loaded text.

Thanks,
Fabio

Below, the respective codes - ManagedBean and page codes:


RestricaoMB.java:

package xxxxxxxxxxxxx.controle;

................................

/**
*
*/
@ViewScoped
@ManagedBean(name = "restricaoMB")
public class RestricaoMB extends GenericMB implements Serializable {

     private static final long serialVersionUID = 7847200068974402190L;

     private static final String MSG_ERRO_UPLOAD = "MSG_erroUploadUnidade";

     private Restricao restricaoRN; // Regras de negócio

..........................................

     private SFI_AnaliseRestricaoCA analiseRestricaoSelecionada;

     private File arquivoUnidade;
     private String arquivoUnidadeTmpNome;
     private String tipoRespostaUnidade;

     /**
     * chamado para inicialização do managed bean
     */
     @PostConstruct
     public void inicializaBean() {
......................
     }


/**
* Faz upload do arquivo de resposta de Unidade para área temporária.
*
* @return
*/
     public String uploadUnidade() {
          try {
               arquivoUnidadeTmpNome = this.restricaoRN.uploadArquivoToTmp(arquivoUnidade);

          } catch (IOException e) {
               this.logErro(e);
               FacesUtils.Mensagem.adicionaMensagem(this.getMessages()
                         .getMensagem(MSG_ERRO_UPLOAD), FacesMessage.SEVERITY_ERROR);
          }
          return null;
     }

.....................................................
     
}




restricao.xhtml:

<?xml version='1.0' encoding='UTF-8' ?>
<html 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:rich="http://richfaces.org/rich"
     xmlns:a4j="http://richfaces.org/a4j"
     xmlns:xxxxxxx="http://xxxxxxxx">

<ui:composition template="/pages/template/base.xhtml">
     <ui:param name="titulo" value="#{bundle.restricoes}" />

     <ui:define name="messages" />
     <ui:define name="content">

          <h:panelGrid id="selecionaANACA">
               <rich:panel>
                    <rich:messages globalOnly="true" />
                    <h:panelGroup id="selecaoGroup">
                         <h:panelGrid columns="3"
                              columnClasses="colunaDescricao, colunaValor, colunaMensagem">

                              <h:outputLabel value="#{bundle.tipoDeRestricao}" for="cbRestricao" />
                              <h:selectOneMenu id="cbRestricao"
                                        valueChangeListener="#{restricaoMB.selecionaRestricao}"
                                        converter="conversorGenerico" style="width: 458px">
                                   <f:selectItem value="#{null}" itemLabel="#{bundle.selecione}" />
                                   <f:selectItems value="#{restricaoMB.comboRestricao}" />
                                   <f:ajax execute="@this" render="@form" />

                                   <a4j:ajax execute="@this" render="outBranco"
                                        onbegin="#{rich:component('aguarde')}.show();"
                                        oncomplete="#{rich:component('aguarde')}.hide();"
                                        onerror="#{rich:component('aguarde')}.hide();" />

                              </h:selectOneMenu>
                              <rich:message for="cbRestricao" />

                         </h:panelGrid>
                    </h:panelGroup>

                    <ui:include src="/pages/template/painelEspera.xhtml">
                         <ui:param name="id" value="aguarde" />
                    </ui:include>

               </rich:panel>
          </h:panelGrid>

          <br></br>
          <p><h:outputText value=" " id="outBranco" /></p>
          <br></br>

          <p><h:outputText value="#{bundle.descricaoRestricao}" rendered="true" /></p>
          <rich:editor id="edDescricaoRestricao"
                    rendered="#{restricaoMB.permissaoEscrita and !restricaoMB.analiseRestricaoSelecionada.restricaoCA.tipoSistema}"
                    readonly="false" toolbar="custom"
                    value="#{restricaoMB.analiseRestricaoSelecionada.descRestricao}">
               <f:facet name="config">
                    toolbar_custom:
                    [                     
                         { name: 'insert', items : [ 'SpecialChar'] },
                         { name: 'basicstyles', items : [ 'Bold','Italic','-','RemoveFormat' ] },
                         { name: 'styles', items : [ 'Fon tSize' ] },
                         { name: 'colors', items : [ 'TextColor','BGColor' ] },
                         { name: 'tools', items : [ 'Maximize', 'ShowBlocks' ] }
                    ]
               </f:facet>
          </rich:editor>

          <rich:editor id="edDescricaoRestricaoRO"
                    rendered="#{!restricaoMB.permissaoEscrita or restricaoMB.analiseRestricaoSelecionada.restricaoCA.tipoSistema}"
                    readonly="true" toolbar="custom"
                    value="#{restricaoMB.analiseRestricaoSelecionada.descRestricao}">
               <f:facet name="config">
                    toolbar_custom:
                    [                     
                         { name: 'tools', items : [ 'Maximize', 'ShowBlocks' ] }
                    ]
               </f:facet>
          </rich:editor>


          <br></br>
          <p><h:outputText value=" " /></p>
          <br></br>

          <p><h:outputText value="#{bundle.respostaUnidade}" rendered="true" /></p>



          <h:selectOneRadio id="tipoRespostaUnidade" value="#{restricaoMB.tipoRespostaUnidade}">
               <f:selectItem id="respostaUnidadeItem1" itemLabel="Digitar texto" itemValue="1" />
               <f:selectItem id="respostaUnidadeItem2" itemLabel="Upload arquivo" itemValue="2" />
               <a4j:ajax execute="@this" render="outBranco"
                    onbegin="#{rich:component('aguarde')}.show();"
                    oncomplete="#{rich:component('aguarde')}.hide();
                         if( #{restricaoMB.tipoRespostaUnidade == 1} ) { #{rich:component('unidadeTextoMP')}.show(); };
                         if( #{restricaoMB.tipoRespostaUnidade == 2} ) { #{rich:component('unidadeArquivoMP')}.show(); }"
                    onerror="#{rich:component('aguarde')}.hide();" />
          </h:selectOneRadio>



          <rich:popupPanel modal="true" id="unidadeTextoMP" autosized="true"
                    rendered="#{menuMB.perfilEdicao}">
               <f:facet name="header">
                    <h:outputText value="#{bundle.digitaUnidade}" />
               </f:facet>
               <f:facet name="controls">
                    <h:graphicImage value="/resources/images/close.jpg"
                         onclick="#{rich:component('unidadeTextoMP')}.hide();"
                         styleClass="iconePainel" />
               </f:facet>

               <h:form acceptcharset="UTF-8">
                    <h:panelGroup id="arquivoPG">
                         <rich:editor id="edRespostaUnidade" rendered="true"
                                   toolbar="custom"
                                   value="#{restricaoMB.analiseRestricaoSelecionada.respostaUnidade}">
                              <f:facet name="config">
                                   toolbar_custom:
                                   [                     
                                        { name: 'insert', items : [ 'SpecialChar'] },
                                        { name: 'basicstyles', items : [ 'Bold','Italic','-','RemoveFormat' ] },
                                        { name: 'styles', items : [ 'FontSize' ] },
                                        { name: 'colors', items : [ 'TextColor','BGColor' ] },
                                        { name: 'tools', items : [ 'Maximize', 'ShowBlocks' ] }
                                   ]
                              </f:facet>
                         </rich:editor>

                         <div align="right">
                              <h:panelGrid columns="2">
                                   <h:commandButton value="#{bundle.salvar}" styleClass="botaoAcao"
                                        action="#{restricaoMB.uploadUnidade}" />
                                   <a4j:commandButton value="#{bundle.cancelar}"
                                        styleClass="botaoAcao" render="@none" execute="@none"
                                        immediate="true"
                                        oncomplete="#{rich:component('unidadeTextoMP')}.hide();" />
                              </h:panelGrid>
                         </div>
                    </h:panelGroup>
               </h:form>
          </rich:popupPanel>





          <!-- POPUP EM QUESTAO, COMENTADO ATE AQUI: -->

          <rich:popupPanel modal="true" id="unidadeArquivoMP" autosized="true"
                    rendered="#{menuMB.perfilEdicao}">
               <f:facet name="header">
                    <h:outputText value="#{bundle.uploadUnidade}" />
               </f:facet>
               <f:facet name="controls">
                    <h:graphicImage value="/resources/images/close.jpg"
                         onclick="#{rich:component('unidadeArquivoMP')}.hide();"
                         styleClass="iconePainel" />
               </f:facet>

               <h:form enctype="multipart/form-data" acceptcharset="UTF-8">
                    <h:panelGroup id="arquivoPG">
                         <xxxxxxxxx:inputFile id="arquivo"
                              value="#{restricaoMB.arquivoUnidade}" required="true" />
                         <div align="right">
                              <h:panelGrid columns="2">
                                   <h:commandButton value="#{bundle.upload}" styleClass="botaoAcao"
                                        action="#{restricaoMB.uploadUnidade}" />
                                   <a4j:commandButton value="#{bundle.cancelar}"
                                        styleClass="botaoAcao" render="@none" execute="@none"
                                        immediate="true"
                                        oncomplete="#{rich:component('unidadeArquivoMP')}.hide();" />
                              </h:panelGrid>
                         </div>
                    </h:panelGroup>
               </h:form>
          </rich:popupPanel>



          <br></br>
          <p><h:outputText value=" " /></p>
          <br></br>

          <p><h:outputText value="#{bundle.respostaTecnico}" rendered="true" /></p>
          <rich:editor id="edRespostaTecnico" rendered="true"
                    readonly="#{!restricaoMB.permissaoEscrita}" toolbar="custom"
                    value="#{restricaoMB.analiseRestricaoSelecionada.respostaTecnico}">
               <f:facet name="config">
                    toolbar_custom:
                    [                     
                         { name: 'insert', items : [ 'SpecialChar'] },
                         { name: 'basicstyles', items : [ 'Bold','Italic','-','RemoveFormat' ] },
                         { name: 'styles', items : [ 'FontSize' ] },
                         { name: 'colors', items : [ 'TextColor','BGColor' ] },
                         { name: 'tools', items : [ 'Maximize', 'ShowBlocks' ] }
                    ]
               </f:facet>
          </rich:editor>

          <br></br>
          <p><h:outputText value=" " /></p>
          <br></br>

          <h:outputLabel value="#{bundle.sanada}" for="cbSanada" rendered="true" />
          <h:selectOneMenu id="cbSanada" rendered="true"
                    disabled="#{!restricaoMB.permissaoEscrita or restricaoMB.analiseRestricaoSelecionada.restricaoCA.tipoSistema}"
                    value="#{restricaoMB.analiseRestricaoSelecionada.indicativoSanada}"
                    converter="conversorGenerico" style="width: 458px">
               <f:selectItems value="#{restricaoMB.comboSanada}" />
          </h:selectOneMenu>

          <br></br>
          <p><h:outputText value=" " /></p>
          <br></br>

          <div align="right">
               <a4j:commandButton value="#{bundle.salvar}"
                    style="text-align: center;"
                    disabled="false" styleClass="botaoAcao"
                    onclick="#{rich:component('aguarde')}.show()"
                    oncomplete="#{rich:component('aguarde')}.hide()"
                    action="#{restricaoMB.salvaAnalise}" id="botaoSeleciona" />
          </div>
          <br></br>
          <p><h:outputText value=" " /></p>
          <br></br>

     </ui:define>

</ui:composition>
</html>

Edited by: 945280 on 11/07/2012 16:31
  • 1. Re: RichFaces editor , popup and upload problems
    gimbal2 Guru
    Currently Being Moderated
    https://community.jboss.org/en/richfaces?view=discussions
  • 2. Re: RichFaces editor , popup and upload problems
    948283 Newbie
    Currently Being Moderated
    To help and clear more, here is the code of the question:

              <rich:popupPanel modal="true" id="unidadeArquivoMP" autosized="true"
                        rendered="#{menuMB.perfilEdicao}">
                   <f:facet name="header">
                        <h:outputText value="#{bundle.uploadUnidade}" />
                   </f:facet>
                   <f:facet name="controls">
                        <h:graphicImage value="/resources/images/close.jpg"
                             onclick="#{rich:component('unidadeArquivoMP')}.hide();"
                             styleClass="iconePainel" />
                   </f:facet>

                   <h:form enctype="multipart/form-data" acceptcharset="UTF-8">
                        <h:panelGroup id="arquivoPG">
                             <tcesc:inputFile id="arquivo"
                                  value="#{restricaoMB.arquivoUnidade}" required="true" />
                             <div align="right">
                                  <h:panelGrid columns="2">
                                       <h:commandButton value="#{bundle.upload}" styleClass="botaoAcao"
                                            action="#{restricaoMB.uploadUnidade}" />
                                       <a4j:commandButton value="#{bundle.cancelar}"
                                            styleClass="botaoAcao" render="@none" execute="@none"
                                            immediate="true"
                                            oncomplete="#{rich:component('unidadeArquivoMP')}.hide();" />
                                  </h:panelGrid>
                             </div>
                        </h:panelGroup>
                   </h:form>
              </rich:popupPanel>
  • 3. Re: RichFaces editor , popup and upload problems
    531266 Newbie
    Currently Being Moderated
    https://community.jboss.org/en/richfaces?view=discussions

    !
  • 5. Re: RichFaces editor , popup and upload problems
    948283 Newbie
    Currently Being Moderated
    Dear colleags,
    If you don't have an answer or specific contribution to my question, please don't send the same link a lot of times ! I know reading and this sending over and over again is a fault of respect to beginner people. Please, a little bit of R-e-s-p-e-c-t !
    Regards!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points