voyent
InputFile and submitOnUpload  XML
Forum Index -> Components
Author Message
Newlukai

Joined: 29/Nov/2006 00:00:00
Messages: 125
Offline


Hello,

I'm developing my application with ICEfaces 1.7.1 and Seam 2.0.1 on a JBoss 4.2.2.

Now I've a problem with a page where I'm displaying an item. On this page the user can display an additional popupPanel. This popupPanel shows a list of files attached to the shown item and the inputFile component to give the user the opportunity to upload a new file. Downloading, viewing, removing even uploading a file works fine.
The problem I have is the following: After uploading a file via the inputFile the list which shows the attached files isn't updated. It doesn't contain the new file.
I know it worked some time ago without any problem. Then the attribute "submitOnUpload" caught my eyes and I tried it with "postUpload" and "preAndPostUpload". None of them did the job. So I think there's a more general problem.

So it would be really nice if someone could help me with this.

Here's the page which shows the item:
Code:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
           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:ui="http://java.sun.com/jsf/facelets"
           xmlns:ice="http://www.icesoft.com/icefaces/component"
           template="template.xhtml">
 
 <ui:define name="content">
   <s:div styleClass="formBox">
     <ice:form id="showTestactionForDeveloper">
       <ui:include src="inc/messages.xhtml" />
       
       <s:div styleClass="buttonLine">
         <ice:commandButton image="img/icon_buttonLine_attach.gif"
           styleClass="graphical" partialSubmit="true"
           actionListener="#{testactionDeveloper.showUpDownloadDialog}"
           title="#{ares_messages.tooltip_upDownload}" />
           
         <h:outputText value="(#{testactionDeveloper.countOfAttachedFiles})"
           converter="javax.faces.Long"
           rendered="#{testactionDeveloper.countOfAttachedFiles > 0}"
           styleClass="fileCounter" />
       </s:div>
       
       <s:div styleClass="clearButtonLineFloat" />
       
       <h:panelGrid cellpadding="0" cellspacing="0" border="0" columns="10"
         rowClasses="tableRowHeader, tableRowContent" styleClass="testaction">    
         <h:outputText value="#{ares_messages.label_testaction_ID}" />
         <h:outputText value="#{ares_messages.label_testaction_TDate}" />
         <h:outputText value="#{ares_messages.label_testaction_TCaseID}" />
 
       <!-- and so on ... -->
       
       <ui:include src="inc/popup_upDownload.xhtml">
         <ui:param name="fileProvider" value="#{testactionDeveloper}" />
       </ui:include>
     </ice:form>
   </s:div>
 </ui:define>
 </ui:composition>
 


That's the popup code:
Code:
<ui:composition 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">
 
   <ice:panelPopup modal="true"
     rendered="#{fileProvider.showUpDownloadDialog}"
     visible="#{fileProvider.showUpDownloadDialog}"
     style="width: 700px;"
     autoCentre="true">
     <f:facet name="header">
       <ice:panelGroup>
         <ice:outputText value="#{ares_messages.popuptitle_upDownload}"
           styleClass="popupTitle" />
         <ice:commandButton image="img/icon_popup_close.gif"
           id="upDownloadPopupClose"
           actionListener="#{fileProvider.closeUpDownloadDialog}"
           partialSubmit="true" styleClass="popupButton"
           style="background: transparent; width: 16px;" />
       </ice:panelGroup>
     </f:facet>
 
     <f:facet name="body">
       <ice:panelGrid columns="1" cellpadding="0" cellspacing="0" border="0">
         <h:dataTable value="#{fileProvider.attachedFiles}"
           var="attachedFile"
           rendered="#{!empty fileProvider.attachedFiles}"
           styleClass="testactionList" rowClasses="tableRowEven, tableRowOdd"
           style="text-align: center;">
           
           <!-- show some info and buttons -->
           
         </h:dataTable>
         
         <ice:inputFile
             id="upload"
             actionListener="#{fileProvider.upload}"
             submitOnUpload="preAndPostUpload"
             label="Hochladen"
           style="margin-top: 30px;" />
           
       </ice:panelGrid>
     </f:facet>
   </ice:panelPopup>
 </ui:composition>
 


This is the upload method:
Code:
public String upload(ActionEvent event) {
     InputFile uploadedFile = (InputFile) event.getSource();
     
     boolean success = false;
     if(uploadedFile.getStatus() == InputFile.SAVED) {
       if(testaction == null) {
         testaction = testactions.get(testactionIndex);
       }
       UpDownloadFileinfo fileInfo = new UpDownloadFileinfo();
       fileInfo.setName(uploadedFile.getFileInfo().getFileName());
       fileInfo.setFile(uploadedFile.getFile());
       fileInfo.setContentType(uploadedFile.getFileInfo().getContentType());
       fileInfo.setTestactionID(testaction.getID());
       success = upDownload.upload(fileInfo);
     }
     
     if( !success ) {
       return "failed";
     }
     
     return null;
 }


And here's the pages.xml (some time ago I had a problem with <render> vs. <redirect> ...):
Code:
<page view-id="/showTestactionForDeveloper.xhtml" login-required="true">
     <navigation>
       <rule if-outcome="browse">
         <redirect view-id="/showTestactionForDeveloper.xhtml" />
       </rule>
       <rule if-outcome="backToList">
         <redirect view-id="/showListForDeveloper.xhtml" />
       </rule>
       <rule if-outcome="failed">
         <redirect view-id="/showTestactionForDeveloper.xhtml" />
       </rule>
     </navigation>
     
     <navigation from-action="#{testactionDeveloper.refresh}">
       <redirect view-id="/showTestactionForDeveloper.xhtml" />
     </navigation>
     <navigation from-action="#{testactionDeveloper.saveTestactionAndNext}">
       <redirect view-id="/showTestactionForDeveloper.xhtml" />
     </navigation>
     <navigation from-action="#{testactionDeveloper.upload}">
       <redirect view-id="/showTestactionForDeveloper.xhtml" />
     </navigation>
     <navigation from-action="#{testactionDeveloper.viewFile}">
       <render view-id="/showTestactionForDeveloper.xhtml" />
     </navigation>
     <navigation from-action="#{testactionDeveloper.downloadFile}">
       <render view-id="/showTestactionForDeveloper.xhtml" />
     </navigation>
     <navigation from-action="#{testactionDeveloper.removeFile}">
       <redirect view-id="/showTestactionForDeveloper.xhtml" />
     </navigation>
 </page>


I hope there's someone who can tell me what's wrong.

Thanks in advance
Newlukai
connolly.st


Joined: 05/Jun/2008 00:00:00
Messages: 89
Offline


Can you try a couple of things for me:

- Put some System.out.println(...) statements in your upload method to make sure it is being called. I am getting a problem [http://www.icefaces.org/JForum/posts/list/9087.page] where the upload method isn't even getting called some time.

- Check the logs and see if any errors are being spit up.

- Put a commandButton on your page, after uploading (which doesn't seem to submit) click the button to submit the page and see if the list updates then. This way we can be sure everything is running fine, the form just isn't submitting so the page isn't refreshing.

-Sean
mark.collette


Joined: 07/Feb/2005 00:00:00
Messages: 1692
Offline


Can you verify that your bean methods which update the List are actually being called, and your List is being changed, it just that they're not being reflected in your web browser?

If you have Firebug installed, can you go to the Console, and post what it says from when you do an upload?
[Email]
Newlukai

Joined: 29/Nov/2006 00:00:00
Messages: 125
Offline


Thank you for your answers. I'll check all those things as soon as I'm at work again (i. e. on Friday).

But what I can tell is that the upload method is called and works. After uploading a file and closing the dialog the page where the popup is enclosed shows an updated number of attached files

Code:
<h:outputText value="(#{testactionDeveloper.countOfAttachedFiles})"
 


I'll explain it a little more detailed: I open the page with this popup enclosed. The outputText mentioned above shows that there are 3 files attached. I open the modal popup and upload an additional file. Nothing is updated but a request was made. Then I hit the close button. The popup closes and "countOfAttachedFiles" shows that there are 4 files attached. When I open the popup again, I get an updated list.
So I think that my list works. But as promised I'll check verything you mentioned on Friday. I can't make it earlier since I'm studying and preparing for the exams.

Thank you again
Newlukai
Newlukai

Joined: 29/Nov/2006 00:00:00
Messages: 125
Offline


Hello,

after fixing some other bugs in my application the upload works again. I don't think that I changed something which is directly related to this feature but it works. I'm sorry that this misbehavior is gone, but thanks for your help.

Newlukai
 
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team