One more thing. The Connector JavaScript is included in the parent page(jsp
that contains the div), not at the form page. So my form page doesn't
contain any javascript(maybe there are some in the future) . So I don't
think the value of executeScripts will affect the result. Moreover I found
out that the block of code, 
<script type="text/javascript">
        dojo.require("dojo.widget.Tooltip");
        dojo.require("dojo.fx.html");
</script>
, is also provided after the form submit in AJAX.



FanCo wrote:
> 
> Hi musachy,
>       Thanks for your reply. It doesn’t work even I set the executeScripts to
> true. One thing I didn’t mention is I set the “href” attribute of the DIV
> to an action that will return the form page. So after the page load, the
> div will request and show the form page asynchronously. In this way, the
> form submission works in AJAX. But the same page doesn’t work after I
> click the button, trigger the JavaScript and return the same form page.
> 
> The page is shown first without the content in the div(request
> asynchronously). Then it becomes a blank page and provides a “dojo is not
> defined” JavaScript error, if I set the executeScripts of div to true and
> add the <struts:head theme="ajax"/> to the form page. Although I remove
> the <struts:head theme="ajax"/>, set the executeScripts to true and the
> page shown correctly, the form still doesn’t work in ajax and refresh
> after submission.
> 
> I use the firebug for debugging and find one strange thing. The form in
> the div doesn’t contain the following the first time (The content of the
> whole form page is returned asynchronously).
> 
> <script type="text/javascript">
>       dojo.require("dojo.widget.Tooltip");
>       dojo.require("dojo.fx.html");
> </script>
> But the form returned by the JavaScript contains it. Is this what make the
> form doesn’t work in AJAX? Why is this block of code provided?
> 
> 
> Musachy Barroso wrote:
>> 
>> Scripts in the html returned will be executed (<script>...</script>)
>> 
>> http://struts.apache.org/2.x/docs/ajax-and-javascript-recipes.html#AjaxandJavaScriptRecipes-ExecuteJavaScriptinthereturnedcontent
>> 
>> musachy
>> 
>> On 6/20/07, FanCo <[EMAIL PROTECTED]> wrote:
>>>
>>>
>>> I didn't set the executeScripts attribute for the DIV. So the default
>>> value
>>> should be false. What is the function of this attribute if it is true?
>>>
>>>
>>> newton.dave wrote:
>>> >
>>> > Does your <s:div.../> have executeScripts="true"?
>>> >
>>> > d.
>>> >
>>> > --- FanCo <[EMAIL PROTECTED]> wrote:
>>> >
>>> >>
>>> >>      I am developing a web page which contains two
>>> >> layouts (left & right). On the
>>> >> left side, there are some buttons. And the right
>>> >> side, it is a DIV which use
>>> >> <s:div/> to create. It will invoke the JavaScript to
>>> >> send a request to one
>>> >> specific S2 action and updates the div with the
>>> >> return page when click the
>>> >> button. The updated page on the right side is always
>>> >> a form containing some
>>> >> fields. I want to send the form with AJAX without
>>> >> refresh the whole page.
>>> >> The JavaScript is using the dojo.io.bind() to send
>>> >> an asynchronous request
>>> >> to S2 action to obtain the web page. Then use the
>>> >> callback to update the
>>> >> DIV. It works fine with the JavaScript to update the
>>> >> DIV. My problem is the
>>> >> AJAX of the form in the updated page doesn’t work.
>>> >> When I click the submit
>>> >> button, it works like the normal form and refresh
>>> >> the whole page.
>>> >> The code of the form is something like the
>>> >> following:
>>> >> <struts:head theme="ajax"/>
>>> >> ……
>>> >> <struts:form method="post" id="testForm"
>>> >> action="update" theme="ajax" >
>>> >> <TABLE>
>>> >>      <tr>
>>> >>              <td><struts:textfield name="descBean.name"/></td>
>>> >>      </tr>
>>> >>      <tr>
>>> >>              <td><struts:textfield
>>> >> name="descBean.address"/></td>
>>> >>      </tr>
>>> >>      <tr>
>>> >>              <td>
>>> >>                      <struts:submit value="Save" align="left"
>>> >> targets="updateDiv"/>
>>> >>              </td>
>>> >>      </tr>
>>> >> </table>
>>> >> </struts:form>
>>> >>
>>> >> And the JavaScript is the following:
>>> >> function Connector(updateTargetArray){
>>> >>      // the ids of the target div
>>> >>      this.targetsArray = updateTargetArray;
>>> >> }
>>> >>
>>> >> Connector.prototype.send = function(location){
>>> >>      dojo.io.bind({
>>> >>              url: location,
>>> >>              handle: dojo.lang.hitch(this, this.bindHandler),
>>> >>              mimetype: "text/html"
>>> >>      });
>>> >> }
>>> >>
>>> >> Connector.prototype.bindHandler = function(type,
>>> >> data, e) {
>>> >>      if(type == "load") {
>>> >>              this.setContent(data);
>>> >> }
>>> >> }
>>> >>
>>> >> Connector.prototype.setContent = function(text){
>>> >> if(this.targetsArray) {
>>> >>              if (this.targetsArray instanceof Array){
>>> >>                      for( var i=0; i<this.targetsArray.length; i++){
>>> >>                              var node = dojo.byId(this.targetsArray
>>> [i]);
>>> >>                              node.innerHTML = text;
>>> >>                      }
>>> >>              }
>>> >>              else {
>>> >>                      var node = dojo.byId(this.targetsArray);
>>> >>                      node.innerHTML = text;
>>> >>              }
>>> >> }
>>> >>
>>> >> The onClick event of the button will invoke the
>>> >> Connector.send(location) to
>>> >> send the request.  The form code works fine in an
>>> >> individual page. I am not
>>> >> quite sure which part is wrong. Does anyone can help
>>> >> me? Thank you so
>>> >> much!~~~
>>> >>
>>> >> --
>>> >> View this message in context:
>>> >>
>>> >
>>> http://www.nabble.com/Ajax-form-submission-doesn%27t-work-after-the-DIV-is-updated-tf3952031.html#a11212235
>>> >> Sent from the Struts - User mailing list archive at
>>> >> Nabble.com.
>>> >>
>>> >>
>>> >>
>>> > ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail:
>>> >> [EMAIL PROTECTED]
>>> >> For additional commands, e-mail:
>>> >> [EMAIL PROTECTED]
>>> >>
>>> >>
>>> >
>>> >
>>> >
>>> >
>>> >
>>> ____________________________________________________________________________________
>>> > Luggage? GPS? Comic books?
>>> > Check out fitting gifts for grads at Yahoo! Search
>>> > http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> > For additional commands, e-mail: [EMAIL PROTECTED]
>>> >
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Ajax-form-submission-doesn%27t-work-after-the-DIV-is-updated-tf3952031.html#a11214704
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>> 
>> 
>> -- 
>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Ajax-form-submission-doesn%27t-work-after-the-DIV-is-updated-tf3952031.html#a11225568
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to