4 Replies Latest reply on May 20, 2009 11:25 PM by lazygeek

    File upload with icefaces and Seam Conversation Scope

    lazygeek
      I am trying to upload file with <ice:inputFile>. Every thing works , if i use Session scope. But file data is not retained , with @Scope(ScopeType.CONVERSATION).

      This is how our Action class look like


      @Scope(ScopeType.SESSION)
      @Name("documentAction")
      public class DocumentAction extends BaseAction<Document> implements
                      java.io.Serializable {

              @In(create = true)
              @Out(required = false)
              @DataModelSelection
              private Document document;
             
              private FileInfo currentFile;

             

              public void uploadFile(ActionEvent event) {
                        InputFile inputFile = (InputFile) event.getSource();
                      FileInfo fileInfo = inputFile.getFileInfo();
                      if (fileInfo.getStatus() == FileInfo.SAVED) {
                          // reference our newly updated file for display purposes and
                          // added it to our history file list.
                          currentFile = fileInfo;
                      }

              }

              public String save() {
                      //When form submit is clicked this method is called
                      // with conversation scope currentFile is null
                      if(currentFile != null){
                       //  Save Entity in Database
                      }
                      
                     
              }
             
             
      }

      JSPX code

              <html
      xmlns="http://www.w3.org/1999/xhtml"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:s="http://jboss.com/products/seam/taglib"
              xmlns:ice="http://www.icesoft.com/icefaces/component"
              xmlns:c="http://java.sun.com/jstl/core"
              xmlns:fn="http://java.sun.com/jsp/jstl/functions"
              xmlns:wc="http://witchcraft.sourceforge.net/jsf"
      >  
              <ice:panelGroup  >
                      <s:validateAll>
                      <h:panelGrid columns="3" styleClass="viewInfo" columnClasses="leftCol, rightCol">
                      <f:facet name="header">
                              <h:outputText value="Document " />
                      </f:facet>
                     
                     
              <h:outputText value="#{msg.document_patient}  "/>
                     
             
              <h:selectOneMenu id="Document_patient" value="#{document.patient}" required="true">
                      <s:selectItems value="#{patientList}" var="itemIter"
                              label="#{itemIter.displayName}"
                              noSelectionLabel="Please Select..." />
                      <s:convertEntity />
              </h:selectOneMenu>
                     
              <h:message styleClass="error errors" for="Document_patient" />
                     
              <h:outputText value="#{msg.document_name} * "/>

              <ice:inputText  id="Document_name" required="true"  value="#{document.name}" />
             
              <h:message styleClass="error errors" for="Document_name" />
                     
              <h:message styleClass="error errors" for="Document_file" />
                     
              <ice:inputFile id="inputFileName"
                             submitOnUpload="postUpload"
                             actionListener="#{documentAction.uploadFile}"/>
               <ice:panelGroup>
                  <h:messages layout="table"
                          globalOnly="false"
                          showDetail="true"
                          showSummary="false"/>
              </ice:panelGroup>

                      </h:panelGrid>
             
                      </s:validateAll>
                     
              <div class="buttonBox">
                     
                      <h:commandButton value="Save" action="#{documentAction.save}" />
                      <h:outputText value=" " />
                      <h:commandButton value="Cancel" immediate="true" action="#{documentAction.cancel}" />
                     
              </div>

              </ice:panelGroup>
              </html>


      So what am i doing wrong.