2012-02-02 2 views
3
내가 rich:fileUploada4j:commandButton을 사용하는 페이지는 제가 페이지는 파일 업로드가 나타나지 말아야로드 처음이다 (렌더링, 내 backingBean 기본이 참 달성하고 싶은 것은 그래서 렌더링 한

제대로) 사용자가있는 명령을 칠 때 나는 이런 일이되지합니다 (파일 업로드를 숨길 사랑하고 outputText을 보여줄 것이다, 오류없는 전혀)Richfaces는 A4J 렌더링 : 아약스는

나는이 문제를 해결할 수있는 방법

<div id="content"> 
     <a4j:outputPanel id="contentForm"> 
      <h:form enctype="multipart/form-data" 
        rendered="#{uploadBean.formRendered}"> 

       <br/><br/> 

       <h:selectOneRadio value="#{uploadBean.selectedOption}"> 
        <f:selectItems value="#{uploadBean.loadOptions}"/> 
       </h:selectOneRadio> 

       <br/> 

       <rich:fileUpload addLabel="Agregar" clearAllLabel="Quitar todos" 
           clearLabel="Quitar" deleteLabel="Quitar" 
           doneLabel="Completado" uploadLabel="Subir archivos" 
           fileUploadListener="#{uploadBean.doUpload}" 
           acceptedTypes="txt, csv" 
           noDuplicate="true"/> 

       <a4j:commandButton value="Iniciar validación" 
            action="#{uploadBean.doLaunchProcess}" 
            render="processLabel" 
            execute="@form" 
            /> 

      </h:form> 
     </a4j:outputPanel> 
     <a4j:outputPanel id="processLabel"> 
      <h:outputText 
       value="#{uploadBean.processStarted}" 
       rendered="#{not uploadBean.formRendered}"/> 
     </a4j:outputPanel> 
    </div> 
처럼 내 pagelooks

이고 commandButton의 액션 코드는

입니다.
public String doLaunchProcess() { 
    formRendered = false; 
    InfoValidator iv = new InfoValidator(loadOptions, 
      selectedOption, userBean.getDependencia(), 
      userBean.getTipoDependencia(), userBean.getUsuario(), 
      userBean.getIdUsuario(), userBean.getEmail()); 
    iv.start(); 
    return "carga-archivos"; 
} 

되어 나는 그것이 사용자가 버튼 그래서 파일 업로드의 가죽을 클릭하면 거짓과이 outputText을 표시 할 때 formRendered 항상 true로 평가되는 것 같다.

UPDATE는 기본적으로 내가 원하는 파일을 업로드 할 수있는 사용자 인 경우 파일 업로드 컴포넌트 사라져과이 outputText가 나타나고 사용자가 버튼을 클릭 말했다 어쩌면

내 접근 "업로드 주셔서 감사합니다"같은 틀렸어. 그냥 올바른 방향으로 넣어 줘. 나는 아약스와 혼동스러워.

건배,

+0

render = "processLabel"대신 rerender = render "processLabel" – HRgiger

+0

a4j : commandButton에 'reRender' 속성이 없습니다. 나는 richfaces 4.1 및 Mojarra 2.1.6과 Tomcat – BRabbit27

+0

을 사용하고 있습니다. 사용중인 cas를 지원한다고 생각합니다. http://stackoverflow.com/a/2243473/706695 또는 http://docs.jboss.org/를 확인하십시오. richfaces/latest_3_3_X/ko/devguide/html/a4j_commandButton.html # 6.1.6.2. % 20Details % 20of % 20Usage – HRgiger

답변

2

마지막으로 해냈어!

수정 코드를 볼 수 있도록 코드는 다음과 같습니다. 기본적으로 a4j : commandButton이 이미 수행 한 전체 양식 (execute="@form")을 처리 한 다음 render="contentForm :processLabel"을 처리해야했습니다.

난 단지 (다시 렌더링?) 그냥 processLabel하고 양식을 렌더링했다가 '항상 거기 내가보기를 업데이트하지 않은 원인

(I이는 DOM 트리를 수 있다고 생각, 사람이 좀 명확하게)
<div id="content"> 
     <a4j:outputPanel id="contentForm"> 
      <h:form enctype="multipart/form-data" 
        rendered="#{uploadBean.formRendered}"> 

       <br/><br/> 

       <h:selectOneRadio value="#{uploadBean.selectedOption}"> 
        <f:selectItems value="#{uploadBean.loadOptions}"/> 
       </h:selectOneRadio> 

       <br/> 

       <rich:fileUpload addLabel="Agregar" clearAllLabel="Quitar todos" 
           clearLabel="Quitar" deleteLabel="Quitar" 
           doneLabel="Completado" uploadLabel="Subir archivos" 
           fileUploadListener="#{uploadBean.doUpload}" 
           acceptedTypes="txt, csv" 
           noDuplicate="true"/> 

       <a4j:commandButton value="Iniciar validación" 
            action="#{uploadBean.doLaunchProcess}" 
            render="contentForm :processLabel"/> 

      </h:form> 
     </a4j:outputPanel> 
     <a4j:outputPanel id="processLabel"> 
      <h:outputText 
       value="#{uploadBean.processStarted}" 
       rendered="#{not uploadBean.formRendered}"/> 
     </a4j:outputPanel> 
    </div> 

백킹 빈은 동일하게 유지됩니다.

건배 !!!