You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jeroen Simons <je...@gmail.com> on 2008/10/09 11:52:24 UTC

Dojo, input=file and struts2 problem

I have a very weird problem and I hope somebody can tell me where to  
look for a solution.

Using the code below everything works as expected. On form submission  
an ajax call is made to the alert() method which simply forwards to  
alert.jsp which alerts the filled in text and a dom reference of the  
form.

As soon as i add a <input type="file"> or <s:file> to my form, the  
alert does not have a reference to the form anymore and the 2nd alert  
fails.

Thanks,

Jeroen

This is my code:

@Namespace(value = "/ajax")
@Results({
     @Result(name = "success", value = "test.jsp"),
     @Result(name = "alert", value = "alert.jsp")
})
public class TestAction extends ActionSupport {

     public String alert() throws Exception {
         return "alert";
     }

     private String text;

     public String getText() {
         return text;
     }

     public void setText(String text) {
         this.text = text;
     }
}

alert.jsp:

<script type="text/javascript">
     alert("${text}");
     alert(document.getElementById("testForm"));
</script>

test.jsp:

<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
     <s:head theme="ajax" />
</head>
<body>

     <s:form id="testForm" name="testForm"  
onsubmit="dojo.event.topic.publish('alert_text');return false;"   
enctype="multipart/form-data">
         Text: <s:textfield name="text" />
         <br />
         <s:submit  />
     </s:form>

     <s:url id="url" action="test" method="alert" namespace="/ajax" />
     <s:div executeScripts="true" showLoadingText="false"  
id="testdiv" href="%{url}" theme="ajax"
            listenTopics="alert_text" formId="testForm" />

</body>
</html>

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