You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Stéphane Zuckerman <st...@gmail.com> on 2005/03/30 11:07:17 UTC

Struts + Ajax + Firefox (was: Best practice for "dynamic reloading" of a part of the JSP ?)

Frank W. Zammetti a écrit :
> I reposted it at the same address.
> 
> Of perhaps more interest though... I am working on an article covering
> this in more details with a few more examples.  I'm hoping to finish it
> today, tomorrow at the latest.
> 

Back to Struts ;-)

I did a little something so I could test AJAX development with Struts.

Basically here is what I do :

For the javascript :

I get an XMLHttpRequest/ActiveXObject("Microsoft.XMLHTTP") object, on an 
onclick event.

I retrieve the values stored in result.responseText (I don't need XML 
for the kind of processing I need). I contains something like :

label1;value1:label2;value2:label3;value3:... (1)

which I split() and process accordingly.


On the Struts side :

I have an action which does "nothing", except set an attribute for the 
request with (1) as the output :

----- MyAction -----

public ActionForward execute(...) {
	// retrieve values in the Database ...
	MyBean result = new MyBean(...);
	request.setAttribute("result", result.toString());
	return mapping.findForward(Constants.OK);
}


... and forwards to a JSP which contains the following line :

---- JSP ----
<%@ taglib uri="..." prefix="bean" %>
<bean:write name="result"/>

This is working fine AFAIK, but while in IE it displays the result and 
that is all, in Firefox the page is still in a loading process... even 
though it has displayed all there was to be displayed !


I don't think this is a problem with Struts, rather with Firefox and its 
way of handling XMLHttpRequest... But is there a way to bypass this 
behaviour ?

-- 
Stéphane Zuckerman

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


Re: Struts + Ajax + Firefox

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
Ok,

thanks!

-Matthias

Frank W. Zammetti wrote:
> Actually, I didn't intend for it to be private :)
> 
> I'm not writing it for any publication in particular, although it could
> wind up one one somewhere.
> 
> I'll certainly announce it here when it's done.
> 

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


Re: Struts + Ajax + Firefox

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Nope, I haven't looked at it at all.  I just checked out the home page for
Struts Flow though, where do you see the announcement?

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Wed, March 30, 2005 12:11 pm, Matthias Wessendorf said:
> Frank,
>
> did you took a look at Struts Flow allready?
>
> I just surfed the subproject and saw that
> AJAX is announced there.
>
> Thanks,
> Matthias
>
> Frank W. Zammetti wrote:
>> Actually, I didn't intend for it to be private :)
>>
>> I'm not writing it for any publication in particular, although it could
>> wind up one one somewhere.
>>
>> I'll certainly announce it here when it's done.
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


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


Re: Struts + Ajax + Firefox

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
Frank,

did you took a look at Struts Flow allready?

I just surfed the subproject and saw that
AJAX is announced there.

Thanks,
Matthias

Frank W. Zammetti wrote:
> Actually, I didn't intend for it to be private :)
> 
> I'm not writing it for any publication in particular, although it could
> wind up one one somewhere.
> 
> I'll certainly announce it here when it's done.
>

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


Re: Struts + Ajax + Firefox

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Actually, I didn't intend for it to be private :)

I'm not writing it for any publication in particular, although it could
wind up one one somewhere.

I'll certainly announce it here when it's done.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Wed, March 30, 2005 11:08 am, Matthias Wessendorf said:
> Hi Frank,
>
> a private email ;)
>
> For what portal or magazine you are writing?
> Will you announce it on Struts Mailing list?
>
> Thanks!
>

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


Re: Struts + Ajax + Firefox

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
I don't know of any right now, but there *will* be one by the weekend :)

(I'm working on an article on this all, and it will include a Struts-based
application showing a number of usages... I had hoped to be done already,
but you know, life gets in the way...)

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Wed, March 30, 2005 10:56 am, Matthias Wessendorf said:
> I started reading on ajax technology bundle
>
> and now I am wondering if anybody knows a *deployable*
> WAR that demonstrates Struts Actions and *AJAX*
>
> :-)
>
> -Matthias
>
> Stéphane Zuckerman wrote:
>> Joe Germuska a écrit :
>>
>>>> I don't think this is a problem with Struts, rather with Firefox and
>>>> its way of handling XMLHttpRequest... But is there a way to bypass
>>>> this behaviour ?
>>>
>>>
>>>
>>> I don't think you can use ActiveXObjects in Firefox -- you certainly
>>> wouldn't be able to reach users of non-Windows systems.
>>
>>
>> I am not (in fact it wouldn't be working at all if it were an ActiveX
>> object :-) ).
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


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


Re: Struts + Ajax + Firefox

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
I started reading on ajax technology bundle

and now I am wondering if anybody knows a *deployable*
WAR that demonstrates Struts Actions and *AJAX*

:-)

-Matthias

Stéphane Zuckerman wrote:
> Joe Germuska a écrit :
> 
>>> I don't think this is a problem with Struts, rather with Firefox and 
>>> its way of handling XMLHttpRequest... But is there a way to bypass 
>>> this behaviour ?
>>
>>
>>
>> I don't think you can use ActiveXObjects in Firefox -- you certainly 
>> wouldn't be able to reach users of non-Windows systems.
> 
> 
> I am not (in fact it wouldn't be working at all if it were an ActiveX 
> object :-) ).

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


Re: Struts + Ajax + Firefox

Posted by Stéphane Zuckerman <st...@gmail.com>.
Joe Germuska a écrit :
>> I don't think this is a problem with Struts, rather with Firefox and 
>> its way of handling XMLHttpRequest... But is there a way to bypass 
>> this behaviour ?
> 
> 
> I don't think you can use ActiveXObjects in Firefox -- you certainly 
> wouldn't be able to reach users of non-Windows systems.

I am not (in fact it wouldn't be working at all if it were an ActiveX 
object :-) ).

-- 
Stéphane Zuckerman

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


Re: Struts + Ajax + Firefox (was: Best practice for "dynamic reloading" of a part of the JSP ?)

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Yes, Joe is correct... As per the sample I posted a day or so ago, in
simplest terms, use the following Javascript to get the object:

if (window.XMLHttpRequest) { // Non-IE browsers
  req = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
  req = new ActiveXObject("Microsoft.XMLHTTP");
}

In any browser other than IE, XMLHttpRequest is implemented as a native
object, so the branching is required.  No need to sniff browsers or
anything, this should do the trick across the board.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Wed, March 30, 2005 9:34 am, Joe Germuska said:
>>This is working fine AFAIK, but while in IE it displays the result
>>and that is all, in Firefox the page is still in a loading
>>process... even though it has displayed all there was to be
>>displayed !
>>
>>I don't think this is a problem with Struts, rather with Firefox and
>>its way of handling XMLHttpRequest... But is there a way to bypass
>>this behaviour ?
>
> I don't think you can use ActiveXObjects in Firefox -- you certainly
> wouldn't be able to reach users of non-Windows systems.
>
> Here's a scrap I borrowed last time I was doing some experimenting
> with this approach:
>
> // Browser-independent way to get an XMLHttpRequest
> // borrowed from
> // http://www.peej.co.uk/articles/rich-user-experience.html
> function getHTTPObject() {
>      var xmlhttp;
> 	 /*@cc_on
>   @if (@_jscript_version >= 5)
>      try {
>          xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
>      } catch (e) {
>          try {
>              xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
>          } catch (E)  {
>              xmlhttp = false;
>          }
>       }
>   @else xmlhttp = false;
>   @end @*/
>      if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
>          try {
>              xmlhttp = new XMLHttpRequest();
>          } catch (e) {
>              xmlhttp = false;
>          }
>      }
>      return xmlhttp;
> }
>
>
> I haven't explored it much, but this XML.com article describes a
> Javascript library called "Sarissa" which is intended to (among many
> more things) smooth over this cross-browser difference in actually
> obtaining an XMLHttpRequest object.
>
> http://www.xml.com/pub/a/2005/02/23/sarissa.html
>
>
> Joe
>
> --
> Joe Germuska
> Joe@Germuska.com
> http://blog.germuska.com
> "Narrow minds are weapons made for mass destruction"  -The Ex
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


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


Re: Struts + Ajax + Firefox (was: Best practice for "dynamic reloading" of a part of the JSP ?)

Posted by Joe Germuska <Jo...@Germuska.com>.
>This is working fine AFAIK, but while in IE it displays the result 
>and that is all, in Firefox the page is still in a loading 
>process... even though it has displayed all there was to be 
>displayed !
>
>I don't think this is a problem with Struts, rather with Firefox and 
>its way of handling XMLHttpRequest... But is there a way to bypass 
>this behaviour ?

I don't think you can use ActiveXObjects in Firefox -- you certainly 
wouldn't be able to reach users of non-Windows systems.

Here's a scrap I borrowed last time I was doing some experimenting 
with this approach:

// Browser-independent way to get an XMLHttpRequest
// borrowed from
// http://www.peej.co.uk/articles/rich-user-experience.html
function getHTTPObject() {
     var xmlhttp;
	 /*@cc_on
  @if (@_jscript_version >= 5)
     try {
         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
         try {
             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
         } catch (E)  {
             xmlhttp = false;
         }
      }
  @else xmlhttp = false;
  @end @*/
     if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
         try {
             xmlhttp = new XMLHttpRequest();
         } catch (e) {
             xmlhttp = false;
         }
     }
     return xmlhttp;
}


I haven't explored it much, but this XML.com article describes a 
Javascript library called "Sarissa" which is intended to (among many 
more things) smooth over this cross-browser difference in actually 
obtaining an XMLHttpRequest object.

http://www.xml.com/pub/a/2005/02/23/sarissa.html


Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex

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