You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Eric Zhao <zh...@utsc.utoronto.ca> on 2009/04/13 17:10:17 UTC

struts2.1.6 dojo ajax tags conflict with fileupload interceptor?

Hello:

I am trying to use struts2.1.6 dojo tags (<%@ taglib prefix="sx" 
uri="/struts-dojo-tags" %>) within a multipart form which also uses 
fileupload interceptor, but  with no success.

My dojo tags is to populate a second drop down based on selection of 
first dropdown. This works fine on regular form. But once the form 
becomes mulitpart with file uploads, dojo tags stop working. Core 
elements from the form looks like this:

<%@ taglib prefix="s" uri="/struts-tags" %>
 <%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
 <jsp:include page="/includes/struts2/header.jsp"/>
   <head>
       <sx:head parseContent="true"/>   
  </head>
  <script language="JavaScript">
    function show_courses() {    
      document.a_form.selected_userid.value = 
document.getElementById("for_id_list").value;
      dojo.event.topic.publish("show_courses");
  }
</script>

<s:form action="%{actionName}" method="post" 
enctype="multipart/form-data" theme="simple" id="a_form" name="a_form">
<s:select list="mygroup" name="for_id_list" id="for_id_list" 
listKey="key" listValue="value" name="scheduledFor" value="scheduledFor"   
     onchange="show_courses();return false;"/>
<s:file label="attach file" name="upload" value="uploadFileNames"/>
    <s:hidden name="selected_userid"/>
    <s:url id="d_url" action="CourseAction"/>
    <sx:div  id="course_list" href="%{d_url}" 
listenTopics="show_courses" formId="a_form" >
    </sx:div>
</s:form>

There is the normal fileupload code in Action class like below:

private List<File> uploads = new ArrayList<File>();
private List<String> uploadFileNames = new ArrayList<String>();
private List<String> uploadContentTypes = new ArrayList<String>();
private void uploadFiles() {
        try {
            if (uploads != null) {
                for (int i = 0; i < uploads.size(); i++) {
                    File theFile = new File(getFileSavingPath()  + 
uploadFileNames.get(i));
                    FileUtils.copyFile(uploads.get(i), theFile);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

Does anyone have experience using dojo tags successfully with file 
upload interceptor? Any suggestions and pointers are greatly appreciated!

Have a good day!

-- 
Eric Zhao					     
Application Developer    
IITS, University of Toronto Scarborough	
Office#: 416-208-2676			     




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org