I think those tags are deprecated, so I'd be cautious of using them.

Mike.

-----Original Message-----
From: Eric Zhao [mailto:z...@utsc.utoronto.ca] 
Sent: Monday, April 13, 2009 1:19 PM
To: Struts Users Mailing List
Subject: struts2.1.6 dojo ajax tags conflict with fileupload interceptor?

repost, since last one went as a reply under another topic

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? Or is there some better approach for ajax in struts2?

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-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org


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

Reply via email to