Re: Struts and AJAX

2006-07-03 Thread Frank W. Zammetti
Well that's a bit embarassing, to say the least :(  I think I flubbed 
the build process, although it would have been flubbed days ago, so I'm 
not sure how it was working during testing.


In any case, the TLD isn't in the right place in the JAR, so it isn't 
being found.  Until a new build can be rolled, a quick work-around is to 
extract the file javawebparts_ajaxparts.tld from the 
javawebparts-ajaxparts-1.0-beta5.jar JAR and place it in WEB-INF.  That 
should do the trick (did for me).


Sorry about that!

Frank

draegoon Z wrote:

I think we were just on two different brainwaves.

If APT still goes through the ActionForm.validate() and returns
to input page upon ActionErrors, as it should,

then APT serves all my purposes with a lot less javascript!

PS: just downloaded beta5, installed and got:

org.apache.jasper.JasperException: 
/packages_jsp/ajaxparts/index.jsp(15,0) File 
"/packages_jsp/ajaxparts/javawebparts/ajaxparts/taglib" not found


Think the problem is first line of packages_jsp/ajaxparts/content.jsp

-Joe

--- 



WEB DESIGN BY DRAEGOONZ

Joseph "DraegoonZ" McGranaghan

http://www.draegoonZ.com

603-620-0854

[EMAIL PROTECTED]





From: "Frank W. Zammetti" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" 
To: Struts Users Mailing List 
Subject: Re: Struts and AJAX
Date: Mon, 03 Jul 2006 18:51:43 -0400

draegoon Z wrote:

Why doesn't APT get this same response?


What response does it get?  As far as I can see, it *SHOULD* get the 
same response, the only difference would be what happens on the 
client-side with it.


Why doesn't it get forwarded to the "input" page automatically, 
returning it in the response?


That's exactly what should happen.  If your seeing something 
different, definitely let me know! :)



Does it go through the ActionForm.validate() method in the first place?


Yes, it will... assuming you were to use std:QueryString or 
std:Poster, the request to the server would look no different to 
Struts than a normal form submission, or GET request.  It will be 
processed in exactly the same way.  If you used, say, std:SimpleXML, 
then Struts would not automatically parse that XML or anything, you 
would have to do that on your own.


I could be missing something, so feel free to yell at me, but if dojo 
does it

I can't see why this shouldn't work for APT also.


Actually, I suspect it's *ME* that's missing something :)  I'm not an 
expert in Dojo, but I have worked with it a bit... from what you've 
described here, you should be able to do the exact same thing with APT 
without touching anything server-side... Well, hang on... I'm assuming 
that Dojo makes a request that either has a query string attached with 
the parameters, or a POST body with them... I'm pretty sure that's the 
case though.



-Joe


Frank

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





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






--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
Java Web Parts -
http://javawebparts.sourceforge.net
Supplying the wheel, so you don't have to reinvent it!

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



Re: Struts and AJAX

2006-07-03 Thread draegoon Z

I think we were just on two different brainwaves.

If APT still goes through the ActionForm.validate() and returns
to input page upon ActionErrors, as it should,

then APT serves all my purposes with a lot less javascript!

PS: just downloaded beta5, installed and got:

org.apache.jasper.JasperException: /packages_jsp/ajaxparts/index.jsp(15,0) 
File "/packages_jsp/ajaxparts/javawebparts/ajaxparts/taglib" not found


Think the problem is first line of packages_jsp/ajaxparts/content.jsp

-Joe

---

WEB DESIGN BY DRAEGOONZ

Joseph "DraegoonZ" McGranaghan

http://www.draegoonZ.com

603-620-0854

[EMAIL PROTECTED]





From: "Frank W. Zammetti" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" 
To: Struts Users Mailing List 
Subject: Re: Struts and AJAX
Date: Mon, 03 Jul 2006 18:51:43 -0400

draegoon Z wrote:

Why doesn't APT get this same response?


What response does it get?  As far as I can see, it *SHOULD* get the same 
response, the only difference would be what happens on the client-side with 
it.


Why doesn't it get forwarded to the "input" page automatically, returning 
it in the response?


That's exactly what should happen.  If your seeing something different, 
definitely let me know! :)



Does it go through the ActionForm.validate() method in the first place?


Yes, it will... assuming you were to use std:QueryString or std:Poster, the 
request to the server would look no different to Struts than a normal form 
submission, or GET request.  It will be processed in exactly the same way.  
If you used, say, std:SimpleXML, then Struts would not automatically parse 
that XML or anything, you would have to do that on your own.


I could be missing something, so feel free to yell at me, but if dojo does 
it

I can't see why this shouldn't work for APT also.


Actually, I suspect it's *ME* that's missing something :)  I'm not an 
expert in Dojo, but I have worked with it a bit... from what you've 
described here, you should be able to do the exact same thing with APT 
without touching anything server-side... Well, hang on... I'm assuming that 
Dojo makes a request that either has a query string attached with the 
parameters, or a POST body with them... I'm pretty sure that's the case 
though.



-Joe


Frank

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





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



Re: Struts and AJAX

2006-07-03 Thread Frank W. Zammetti

draegoon Z wrote:

Why doesn't APT get this same response?


What response does it get?  As far as I can see, it *SHOULD* get the 
same response, the only difference would be what happens on the 
client-side with it.


Why doesn't it get forwarded to the "input" page automatically, 
returning it in the response?


That's exactly what should happen.  If your seeing something different, 
definitely let me know! :)



Does it go through the ActionForm.validate() method in the first place?


Yes, it will... assuming you were to use std:QueryString or std:Poster, 
the request to the server would look no different to Struts than a 
normal form submission, or GET request.  It will be processed in exactly 
the same way.  If you used, say, std:SimpleXML, then Struts would not 
automatically parse that XML or anything, you would have to do that on 
your own.


I could be missing something, so feel free to yell at me, but if dojo 
does it

I can't see why this shouldn't work for APT also.


Actually, I suspect it's *ME* that's missing something :)  I'm not an 
expert in Dojo, but I have worked with it a bit... from what you've 
described here, you should be able to do the exact same thing with APT 
without touching anything server-side... Well, hang on... I'm assuming 
that Dojo makes a request that either has a query string attached with 
the parameters, or a POST body with them... I'm pretty sure that's the 
case though.



-Joe


Frank

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



Re: Struts and AJAX

2006-07-03 Thread draegoon Z

Hey Frank,

Check out this code from my first post using dojo.io.bind() :


function submitNewMail(){

  //validateNewMail(form);  //use javascript validate before form 
submit


  var bindArgs = {
  url: "",
  error: function(type, data, evt){
  alert("An error occurred submitting new mail: " + data);
  },
  load: function(type, data, evt){

  DWRUtil.setValue("social_mail_right_con", data);/* setValue 
doesn't execute javascript! */   
document.getElementById('social_popup_layer_container').innerHTML=document.getElementById('ajax_hidden_helper').innerHTML;

  popup('social_popup_layer_container',true);

  },
  mimetype: "text/html",
  formNode: document.getElementById("compose_mail_form")
  };

  dojo.io.bind(bindArgs);
  }

I'm sure you're probably familiar with dojo, so forgive me if I'm beating a 
dead horse.


What happens here is that my action, /process_new_mail.do, processes like
a normal struts app,i.e., ActionForm.validate() gets called first.

If there are ActionErrors, the "input mapping" page is returned via the 
'data' object.

It is the 'responseText'.

The error: argument:

error: function(type, data, evt){
  alert("An error occurred submitting new mail: " + data);
  }

is NOT called because no Javascript error was thrown.

Instead, the load: function is called:

function(type, data, evt){

  DWRUtil.setValue("social_mail_right_con", data);/* setValue 
doesn't execute javascript! */   
document.getElementById('social_popup_layer_container').innerHTML=document.getElementById('ajax_hidden_helper').innerHTML;

  popup('social_popup_layer_container',true);

  }


The line:

 DWRUtil.setValue("social_mail_right_con", data);

is what displays the response, which is the "input" page.

Anyways, if there are ActionErrors in the ActionForm and the server 
naturally forwards to

the input mapping in the struts-config,

Why doesn't APT get this same response?

Why doesn't it get forwarded to the "input" page automatically, returning it 
in the response?


Does it go through the ActionForm.validate() method in the first place?

If this could happen, you would pretty much have a drop-in solution!

I could be missing something, so feel free to yell at me, but if dojo does 
it

I can't see why this shouldn't work for APT also.

-Joe

---

WEB DESIGN BY DRAEGOONZ

Joseph "DraegoonZ" McGranaghan

http://www.draegoonZ.com

603-620-0854

[EMAIL PROTECTED]





From: "Frank W. Zammetti" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" 
To: Struts Users Mailing List 
Subject: Re: Struts and AJAX
Date: Mon, 03 Jul 2006 17:47:06 -0400

draegoon Z wrote:

That CodeExecuter is nice!


Thanks!  The interesting thing is that as of beta5, it doesn't matter what 
response handler you use, the script blocks will ALWAYS be executed.  
That's why there's a seemingly superfluous DoNothing handler... you may 
want to use that instead of CodeExecuter in some cases.


About below, I'm talking about when my MyForm (extends ActionForm, not 
Action) returns
an ActionErrors object as it is configured in the example struts-config 
below.


Like if "to"  parameter was supposed to be a valid email address and 
someone

entered: blah blah blah

Will this be handled normally, like a Non-Ajax struts action app, 
returning the

input mapping to display the errors, or whatever else.


That's what I kinda thought you meant :)  I got confused because you showed 
an action mapping... anyway... if you took an existing Struts app that 
handled this, then no, APT would probably not work right... although it 
still could... imagine if the page that the input JSP renders is displayed 
in an iFrame... in that case, you could use the std:IFrame handler to 
re-render it, so you wouldn't have to change a thing about your app.  
Likewise, you could display it in a  and get the same effect.


However, more than likely your app isn't built this way today, so it 
wouldn't work unaltered.  What you would more than likely do is copy the 
action mapping that uses that MyForm, and change the input attribute to 
point to a JSP that renders just a snippet of markup displaying the error.  
Then, insert that markup into a  using std:InnerHTML, or maybe pop it 
in an alert() with std:Alerter, etc.  This way, you kind of have a 
"parallel" action mapping, one for the AJAX request, one for the regular 
form submission (I've done this in a proof of concept by the way, it works 
great).



-Joe


Frank

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





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



Re: Struts and AJAX

2006-07-03 Thread Frank W. Zammetti

draegoon Z wrote:

That CodeExecuter is nice!


Thanks!  The interesting thing is that as of beta5, it doesn't matter 
what response handler you use, the script blocks will ALWAYS be 
executed.  That's why there's a seemingly superfluous DoNothing 
handler... you may want to use that instead of CodeExecuter in some cases.


About below, I'm talking about when my MyForm (extends ActionForm, not 
Action) returns
an ActionErrors object as it is configured in the example struts-config 
below.


Like if "to"  parameter was supposed to be a valid email address and 
someone

entered: blah blah blah

Will this be handled normally, like a Non-Ajax struts action app, 
returning the

input mapping to display the errors, or whatever else.


That's what I kinda thought you meant :)  I got confused because you 
showed an action mapping... anyway... if you took an existing Struts app 
that handled this, then no, APT would probably not work right... 
although it still could... imagine if the page that the input JSP 
renders is displayed in an iFrame... in that case, you could use the 
std:IFrame handler to re-render it, so you wouldn't have to change a 
thing about your app.  Likewise, you could display it in a  and get 
the same effect.


However, more than likely your app isn't built this way today, so it 
wouldn't work unaltered.  What you would more than likely do is copy the 
action mapping that uses that MyForm, and change the input attribute to 
point to a JSP that renders just a snippet of markup displaying the 
error.  Then, insert that markup into a  using std:InnerHTML, or 
maybe pop it in an alert() with std:Alerter, etc.  This way, you kind of 
have a "parallel" action mapping, one for the AJAX request, one for the 
regular form submission (I've done this in a proof of concept by the 
way, it works great).



-Joe


Frank

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



Re: Struts and AJAX

2006-07-03 Thread Frank W. Zammetti

Michael Jouravlev wrote:
Frank, please ignore my ignorance, 


Ignorance is thinking you know something when you don't... not knowing 
something you have no experience with isn't :)


> if I understand correctly, an

Action still returns a full page, but your JS engine parses the
response and pulls out only relevant "ajaxified" parts and replaces
them in a page? So, if I need to print out error messages, I just need
to mark  tag with  ? 


No, that isn't quite right...

What APT does is "attaches" AJAX events to an element on a page (it can 
theoretically be any DOM element).  This attached event fires in 
response to one of the usual event handlers, i.e., onClick, onBlur, 
whatever (you can also have an AJAX event that fires continuously via 
timer, and you can also have a function rendered that you can call at 
will to fire an AJAX event which is still configured like any other).


So, when working with Struts, your Action (or more usually, a JSP) can 
really render whatever it wants... APT has nothing to say about that (at 
this point... some plans in the works).  Most of the time is would 
probably NOT be a full page... then, back on the client, APT kicks in 
again via a response handler, and does something with the response. 
That "something" can be updating a , populating a , doing 
an XSLT transformation, popping an alert, or a number of other things 
(and that's the just standard handlers... with a custom handlers, the 
possibilities are limited only by your imagination).


Now, one new capability that a lot of people were asking for is the 
ability to use APT tags in a response rendered by a JSP that is itself 
called as the result of an AJAX call... imagine a button on a page that, 
when clicked, adds a new item entry line to a list.  This new line will 
contain two text fields, one of which you want to fire an AJAX event 
onBlur for.  Previously, you had to do some somewhat annoying things to 
make that happen, now it's perfectly natural: just use the tags in a JSP 
that renders the markup for that new item line.


Specifically on your question of rendering , you would 
first need to decide how you want to display the errors... in a popup? 
In a ?  Something else?  Whatever the case, you create a JSP that 
contains that  tag, and that might in fact be the ONLY 
thing in that JSP.  Then, you configure a response handler to display it 
however you want.  Nothing more to it.


> What if I print

errors separately for every input field, will this still work?


Yes, it can, it all depends on what events fire the AJAX call, and what 
you do with the response.  APT is a bit more low-level than some other 
libraries in that we don't really say much about what you do or how you 
do it, we just provide tools that we feel makes it really easy to do 
whatever you want, and saves you from doing Javascript coding yourself 
(usually, custom handlers excepted).


I think grabbing JWP and looking at the sample app is the best way to 
go... there is a page with probably close to 20 different usages of APT, 
and I think if you look at that and then glance at the JSP, it'll become 
clear pretty quickly (there's also a cookbook that might be helpful, 
although it hasn't been updated for beta5 yet).


Frank

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



Re: Struts and AJAX

2006-07-03 Thread draegoon Z

That CodeExecuter is nice!

With dojo.io.bind() I use DWRUtil.setValue() to load the response into my 
,

which doesn't execute any 

Re: Struts and AJAX

2006-07-03 Thread Michael Jouravlev

On 7/3/06, Frank W. Zammetti <[EMAIL PROTECTED]> wrote:

draegoon Z wrote:
> Sounds great so far, but I think I lost you on the first part.
> Let's work through a simple problem...
>
> Let's say I have in my struts-config:
>
> 
> 
> 
>
>  scope="request" type="com.draegoonZ.action.MyAction">
> 
> 
> 
>
> First, what happens if MyForm just simply returns an ActionError?

MyForm, which I assume extends from Action, would have to return an
ActionForward, or null... if null, then the response would have to be
fully formed by the Action, otherwise it presumably returns a forward to
a JSP that renders some response.  That JSP would have to make use of
the ActionErrors, and render a response appropriate for what you want to
happen on the client, whether that's updating a , popping an
alert(), or something else.

I feel like I'm not understanding what your getting at though :)


Frank, please ignore my ignorance, if I understand correctly, an
Action still returns a full page, but your JS engine parses the
response and pulls out only relevant "ajaxified" parts and replaces
them in a page? So, if I need to print out error messages, I just need
to mark  tag with  ? What if I print
errors separately for every input field, will this still work?

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



Re: Struts and AJAX

2006-07-03 Thread Rick Reumann

Just wanted to say +1 for the JWP tags. Plus the support you get it is
top-notch. Use them.

On 7/3/06, Frank W. Zammetti <[EMAIL PROTECTED]> wrote:


draegoon Z wrote:
> Sounds great so far, but I think I lost you on the first part.
> Let's work through a simple problem...
>
> Let's say I have in my struts-config:
>
> 
> 
> 
>
>  scope="request" type="com.draegoonZ.action.MyAction">
> 
> 
> 
>
> First, what happens if MyForm just simply returns an ActionError?

MyForm, which I assume extends from Action, would have to return an
ActionForward, or null... if null, then the response would have to be
fully formed by the Action, otherwise it presumably returns a forward to
a JSP that renders some response.  That JSP would have to make use of
the ActionErrors, and render a response appropriate for what you want to
happen on the client, whether that's updating a , popping an
alert(), or something else.

I feel like I'm not understanding what your getting at though :)

> Second, what if MyAction has ActionErrors and forwards to its 'error'
page?

Same basic answer as above... you wouldn't, in all probability, reuse
the same JSP as rendered the form, as is typical in Struts apps.  In
this case, you would probably be submitting to some mapping that is
expressly set up to handle the AJAX request.  That means that the input
attribute would make to some JSP that renders the response appropriate
for the error condition (the same basic mechanism as described above).

> Are you saying that APT gets the response (JSP,text,HTML, whatever) and
> matches
> the regex to that entire response string?

That's correct, it executes the regex against responseText of
XMLHttpRequest.

> If so, how do you advise setting flags in the response to ensure the
> proper responseHandler
> is called without neccessarily displaying the flag itself. Like,
>
>
THIS_IS_MY_UGLY_FLAG_BEFORE_CONTENT_AND_FIRST_IN_THE_RESPONSE:content

I think more than likely you would key off of some text in a real
response... i.e., if the error message is something like "To field
cannot be blank", then check for something like "/cannot be blank/".  If
you wanted to do something like you show above, you probably would need
to write a custom handler because there would be no opportunity to
essentially strip the flag from the response... the post-processing
function does not fire until AFTER all the response handlers have fired.
  I think you've found a good enhancement opportunity :)

Another possibility is to return Javascrpt... APT will always execute
any 

Re: Struts and AJAX

2006-07-03 Thread Frank W. Zammetti

draegoon Z wrote:

Sounds great so far, but I think I lost you on the first part.
Let's work through a simple problem...

Let's say I have in my struts-config:





scope="request" type="com.draegoonZ.action.MyAction">





First, what happens if MyForm just simply returns an ActionError?


MyForm, which I assume extends from Action, would have to return an 
ActionForward, or null... if null, then the response would have to be 
fully formed by the Action, otherwise it presumably returns a forward to 
a JSP that renders some response.  That JSP would have to make use of 
the ActionErrors, and render a response appropriate for what you want to 
happen on the client, whether that's updating a , popping an 
alert(), or something else.


I feel like I'm not understanding what your getting at though :)


Second, what if MyAction has ActionErrors and forwards to its 'error' page?


Same basic answer as above... you wouldn't, in all probability, reuse 
the same JSP as rendered the form, as is typical in Struts apps.  In 
this case, you would probably be submitting to some mapping that is 
expressly set up to handle the AJAX request.  That means that the input 
attribute would make to some JSP that renders the response appropriate 
for the error condition (the same basic mechanism as described above).


Are you saying that APT gets the response (JSP,text,HTML, whatever) and 
matches

the regex to that entire response string?


That's correct, it executes the regex against responseText of 
XMLHttpRequest.


If so, how do you advise setting flags in the response to ensure the 
proper responseHandler

is called without neccessarily displaying the flag itself. Like,

THIS_IS_MY_UGLY_FLAG_BEFORE_CONTENT_AND_FIRST_IN_THE_RESPONSE:content 


I think more than likely you would key off of some text in a real 
response... i.e., if the error message is something like "To field 
cannot be blank", then check for something like "/cannot be blank/".  If 
you wanted to do something like you show above, you probably would need 
to write a custom handler because there would be no opportunity to 
essentially strip the flag from the response... the post-processing 
function does not fire until AFTER all the response handlers have fired. 
 I think you've found a good enhancement opportunity :)


Another possibility is to return Javascrpt... APT will always execute 
any 

Re: Struts and AJAX

2006-07-03 Thread draegoon Z

Sounds great so far, but I think I lost you on the first part.
Let's work through a simple problem...

Let's say I have in my struts-config:





scope="request" type="com.draegoonZ.action.MyAction">





First, what happens if MyForm just simply returns an ActionError?

Second, what if MyAction has ActionErrors and forwards to its 'error' page?

Are you saying that APT gets the response (JSP,text,HTML, whatever) and 
matches

the regex to that entire response string?

If so, how do you advise setting flags in the response to ensure the proper 
responseHandler

is called without neccessarily displaying the flag itself. Like,

THIS_IS_MY_UGLY_FLAG_BEFORE_CONTENT_AND_FIRST_IN_THE_RESPONSE:content


-Joe

---

WEB DESIGN BY DRAEGOONZ

Joseph "DraegoonZ" McGranaghan

http://www.draegoonZ.com

603-620-0854

[EMAIL PROTECTED]





From: "Frank W. Zammetti" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" 
To: Struts Users Mailing List 
Subject: Re: Struts and AJAX
Date: Mon, 03 Jul 2006 14:54:47 -0400

Good questions!  Let me see if I can answer them...

draegoon Z wrote:

What about errors in the ActionForm?


APT doesn't say anything at all about what happens on the server, so, the 
short answer is its up to you :)  The longer answer is that each of the 
response handlers (as of the latest beta5 release) has a matchPattern 
parameter, which is a regex... with that, you can examine the response and 
either fire the handler or skip it.


So, for instance, it may be that you want to make an AJAX request when the 
user clicks a button to do some validations... there are two possible 
outcomes... one is an "OK" response, for which you just want to put the 
returned message into a  let's say... the other outcome is validation 
errors, in which case you want to pop the response via alert() let's say.  
So, configure two response handlers:



  myResultDiv


  


Now, my regex is a bit rusty, so pay attention more to the theory than the 
details :)  The idea is that the first handler will only fire is "ok " is 
found in the response.  Likewise, the second one will only fire if "error" 
is found.  Since you can absolutely use a JSP to render the two responses, 
you use the same set of Struts skills as you always have to create the 
response.



What about firing javascript function before the submit?
I.e., to validate the form (I don't use Validator).


As of the latest beta5 release, you can specify both a post-processing and 
pre-processing function to do exactly that.  You can set this on the 
,  or  levels.


Alternatively, if your really doing something more complex, you can write a 
custom handler.  This amounts to an entry in the config file like so:



  MyJSHandler
  local


From then on, you can use MyHandler as the value of the type attribute of a 
 element.  You can do whatever you want there, and, you 
STILL won't have to write much code because you can use the built-in 
RequestSender() function, which takes care of all the AJAX details for 
you... you just write the "business logic", so to speak, and call 
RequestSender() to take care of all the call details.


Does the Action have to return 'null' and write directly to the response, 
or can the struts config still be used?


You can do either.  Your response can be rendered via JSP, which we 
actually recommend 99% of the time, so you can write your struts-config the 
same as always.  In fact, I've taken an existing Struts app and added AJAX 
to it using APT, and all I had to do was alter the JSPs, the actual code 
didn't even need a recompile!



-Joe


Frank

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





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



Re: Struts and AJAX

2006-07-03 Thread Frank W. Zammetti

Good questions!  Let me see if I can answer them...

draegoon Z wrote:

What about errors in the ActionForm?


APT doesn't say anything at all about what happens on the server, so, 
the short answer is its up to you :)  The longer answer is that each of 
the response handlers (as of the latest beta5 release) has a 
matchPattern parameter, which is a regex... with that, you can examine 
the response and either fire the handler or skip it.


So, for instance, it may be that you want to make an AJAX request when 
the user clicks a button to do some validations... there are two 
possible outcomes... one is an "OK" response, for which you just want to 
put the returned message into a  let's say... the other outcome is 
validation errors, in which case you want to pop the response via 
alert() let's say.  So, configure two response handlers:



  myResultDiv


  


Now, my regex is a bit rusty, so pay attention more to the theory than 
the details :)  The idea is that the first handler will only fire is "ok 
" is found in the response.  Likewise, the second one will only fire if 
"error" is found.  Since you can absolutely use a JSP to render the two 
responses, you use the same set of Struts skills as you always have to 
create the response.



What about firing javascript function before the submit?
I.e., to validate the form (I don't use Validator).


As of the latest beta5 release, you can specify both a post-processing 
and pre-processing function to do exactly that.  You can set this on the 
,  or  levels.


Alternatively, if your really doing something more complex, you can 
write a custom handler.  This amounts to an entry in the config file 
like so:



  MyJSHandler
  local


From then on, you can use MyHandler as the value of the type attribute 
of a  element.  You can do whatever you want there, and, 
you STILL won't have to write much code because you can use the built-in 
RequestSender() function, which takes care of all the AJAX details for 
you... you just write the "business logic", so to speak, and call 
RequestSender() to take care of all the call details.


Does the Action have to return 'null' and write directly to the 
response, or can the struts config still be used?


You can do either.  Your response can be rendered via JSP, which we 
actually recommend 99% of the time, so you can write your struts-config 
the same as always.  In fact, I've taken an existing Struts app and 
added AJAX to it using APT, and all I had to do was alter the JSPs, the 
actual code didn't even need a recompile!



-Joe


Frank

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



Re: Struts and AJAX

2006-07-03 Thread draegoon Z

This seems like a cleaner alternative.

What about errors in the ActionForm?

What about firing javascript function before the submit?
I.e., to validate the form (I don't use Validator).

Does the Action have to return 'null' and write directly to the response, or 
can the struts config still be used?



-Joe






---

WEB DESIGN BY DRAEGOONZ

Joseph "DraegoonZ" McGranaghan

http://www.draegoonZ.com

603-620-0854

[EMAIL PROTECTED]





From: "Frank W. Zammetti" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" 
To: Struts Users Mailing List 
Subject: Re: Struts and AJAX
Date: Mon, 03 Jul 2006 14:03:45 -0400

Oops, messed up my own config file!  Should be...


  

  

  to=to


  

  

  


Frank W. Zammetti wrote:

I'm a big fan of DWR as well, it's a very worthy alternative.

But, I don't mind a little self-promotion, so... how does this strike you? 
...



  

  target="/process_new_mail.do">

  to=to
  
  

  


Then, in your JSP:


class='error'>To:


 ...
//more form elements
...
SUBMIT



This would result in some Action, mapped to process_new_mail.do being 
executed, and you would get a single parameter submitted, "to", using the 
value of the form field "to".  The response from the server, whatever it 
is, would be displayed via alert().


This is what AjaxParts Taglib (APT) offers... you define an event in a 
config file, some user-initiated (usually) event that fires an AJAX 
request.  For each event, you define a request handler, which forms the 
request to the server... there are a number of "standard" handlers, for 
instance, if you want to construct XML from your form, that's standard.  
You also define one (or more) response handlers, which is something that 
happens when the response comes back.  Again, there are a number of 
standard handlers, like Alerter... there is also things like InnerHTML 
(populate a page element by updating innerHTML), stdXSLT (transform XML 
response via XSLT on client), and much more.


Note that you didn't have to right ANY Javascript whatsoever!  And the 
changes to your JSP amounts to adding an  tag to any element 
that will fire an AJAX event, and the  tag at the end (plus 
the taglib declaration of course).  Changing the AJAX functionality is as 
easy as modifying the config file, you wouldn't need to touch your JSP 
again!  And, should you need to do more advanced things that the standard 
handlers don't cover (they should do the job probably 80% of the time or 
better though), there is a pretty simple mechanism for writing your own 
custom handlers, which you can then use just like the standard handlers.


If the no coding approach sounds good, check it out further:

http://javawebparts.sourceforge.net/

I suggest clicking the Javadocs link and going to the first package 
listed, javawebparts.ajaxparts.taglib... all the details can be found 
there... then, download JWP and check out the sample app for all sorts of 
examples of APT usage.


Shill time over :)

Frank

draegoon Z wrote:

Hey,

I use DWR + dojo to use AJAX with struts:

http://getahead.ltd.uk/dwr/

http://dojotoolkit.com/

Although dojo has some flashy widgets and stuff, its power is the 
dojo.io.bind() function:


http://dojotoolkit.org/docs/intro_to_dojo_io.html



Here is an example of using Struts Actions with bind():


action="process_new_mail" enctype="multipart/form-data" focus="to">



property="to">class='error'>To:




...
//more form elements
...

SUBMIT


NOTE: form has been given a 'styleId' and using  
to display errors in form



function submitNewMail(){

   //validateNewMail(form);

   var bindArgs = {
   url: "",
   error: function(type, data, evt){
   alert("An error occurred submitting new mail: " + data);
   },
   load: function(type, data, evt){

   DWRUtil.setValue("social_mail_right_con", data);/* 
setValue doesn't execute javascript! */
   
document.getElementById('social_popup_layer_container').innerHTML=document.getElementById('ajax_hidden_helper').innerHTML;


   popup('social_popup_layer_container',true);

   },
   mimetype: "text/html",
   formNode: document.getElementById("compose_mail_form")
   };

   dojo.io.bind(bindArgs);
   }


NOTE:

1) the use of  for the 'url'

2) formNode is the 'styleId' of your 

3) the stuff you see in the load function is application specific. It is 
how I display 
   and  in a backwards-compatible manner for AJAX. I 
basically force
   the reloading 

Re: Struts and AJAX

2006-07-03 Thread draegoon Z

This seems like a cleaner alternative.

What about errors in the ActionForm?

What about firing javascript function before the submit?
I.e., to validate the form (I don't use Validator).

Does the Action have to return 'null' and write directly to the response, or 
can the struts config still be used?



-Joe






---

WEB DESIGN BY DRAEGOONZ

Joseph "DraegoonZ" McGranaghan

http://www.draegoonZ.com

603-620-0854

[EMAIL PROTECTED]





From: "Frank W. Zammetti" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" 
To: Struts Users Mailing List 
Subject: Re: Struts and AJAX
Date: Mon, 03 Jul 2006 14:03:45 -0400

Oops, messed up my own config file!  Should be...


  

  

  to=to


  

  

  


Frank W. Zammetti wrote:

I'm a big fan of DWR as well, it's a very worthy alternative.

But, I don't mind a little self-promotion, so... how does this strike you? 
...



  

  target="/process_new_mail.do">

  to=to
  
  

  


Then, in your JSP:


class='error'>To:


 ...
//more form elements
...
SUBMIT



This would result in some Action, mapped to process_new_mail.do being 
executed, and you would get a single parameter submitted, "to", using the 
value of the form field "to".  The response from the server, whatever it 
is, would be displayed via alert().


This is what AjaxParts Taglib (APT) offers... you define an event in a 
config file, some user-initiated (usually) event that fires an AJAX 
request.  For each event, you define a request handler, which forms the 
request to the server... there are a number of "standard" handlers, for 
instance, if you want to construct XML from your form, that's standard.  
You also define one (or more) response handlers, which is something that 
happens when the response comes back.  Again, there are a number of 
standard handlers, like Alerter... there is also things like InnerHTML 
(populate a page element by updating innerHTML), stdXSLT (transform XML 
response via XSLT on client), and much more.


Note that you didn't have to right ANY Javascript whatsoever!  And the 
changes to your JSP amounts to adding an  tag to any element 
that will fire an AJAX event, and the  tag at the end (plus 
the taglib declaration of course).  Changing the AJAX functionality is as 
easy as modifying the config file, you wouldn't need to touch your JSP 
again!  And, should you need to do more advanced things that the standard 
handlers don't cover (they should do the job probably 80% of the time or 
better though), there is a pretty simple mechanism for writing your own 
custom handlers, which you can then use just like the standard handlers.


If the no coding approach sounds good, check it out further:

http://javawebparts.sourceforge.net/

I suggest clicking the Javadocs link and going to the first package 
listed, javawebparts.ajaxparts.taglib... all the details can be found 
there... then, download JWP and check out the sample app for all sorts of 
examples of APT usage.


Shill time over :)

Frank

draegoon Z wrote:

Hey,

I use DWR + dojo to use AJAX with struts:

http://getahead.ltd.uk/dwr/

http://dojotoolkit.com/

Although dojo has some flashy widgets and stuff, its power is the 
dojo.io.bind() function:


http://dojotoolkit.org/docs/intro_to_dojo_io.html



Here is an example of using Struts Actions with bind():


action="process_new_mail" enctype="multipart/form-data" focus="to">



property="to">class='error'>To:




...
//more form elements
...

SUBMIT


NOTE: form has been given a 'styleId' and using  
to display errors in form



function submitNewMail(){

   //validateNewMail(form);

   var bindArgs = {
   url: "",
   error: function(type, data, evt){
   alert("An error occurred submitting new mail: " + data);
   },
   load: function(type, data, evt){

   DWRUtil.setValue("social_mail_right_con", data);/* 
setValue doesn't execute javascript! */
   
document.getElementById('social_popup_layer_container').innerHTML=document.getElementById('ajax_hidden_helper').innerHTML;


   popup('social_popup_layer_container',true);

   },
   mimetype: "text/html",
   formNode: document.getElementById("compose_mail_form")
   };

   dojo.io.bind(bindArgs);
   }


NOTE:

1) the use of  for the 'url'

2) formNode is the 'styleId' of your 

3) the stuff you see in the load function is application specific. It is 
how I display 
   and  in a backwards-compatible manner for AJAX. I 
basically force
   the reloading 

Re: Struts and AJAX

2006-07-03 Thread Frank W. Zammetti

Oops, messed up my own config file!  Should be...


  

  

  to=to


  

  

  


Frank W. Zammetti wrote:

I'm a big fan of DWR as well, it's a very worthy alternative.

But, I don't mind a little self-promotion, so... how does this strike 
you? ...



  

  
  to=to
  
  

  


Then, in your JSP:


class='error'>To:


 ...
//more form elements
...
SUBMIT



This would result in some Action, mapped to process_new_mail.do being 
executed, and you would get a single parameter submitted, "to", using 
the value of the form field "to".  The response from the server, 
whatever it is, would be displayed via alert().


This is what AjaxParts Taglib (APT) offers... you define an event in a 
config file, some user-initiated (usually) event that fires an AJAX 
request.  For each event, you define a request handler, which forms the 
request to the server... there are a number of "standard" handlers, for 
instance, if you want to construct XML from your form, that's standard. 
 You also define one (or more) response handlers, which is something 
that happens when the response comes back.  Again, there are a number of 
standard handlers, like Alerter... there is also things like InnerHTML 
(populate a page element by updating innerHTML), stdXSLT (transform XML 
response via XSLT on client), and much more.


Note that you didn't have to right ANY Javascript whatsoever!  And the 
changes to your JSP amounts to adding an  tag to any element 
that will fire an AJAX event, and the  tag at the end (plus 
the taglib declaration of course).  Changing the AJAX functionality is 
as easy as modifying the config file, you wouldn't need to touch your 
JSP again!  And, should you need to do more advanced things that the 
standard handlers don't cover (they should do the job probably 80% of 
the time or better though), there is a pretty simple mechanism for 
writing your own custom handlers, which you can then use just like the 
standard handlers.


If the no coding approach sounds good, check it out further:

http://javawebparts.sourceforge.net/

I suggest clicking the Javadocs link and going to the first package 
listed, javawebparts.ajaxparts.taglib... all the details can be found 
there... then, download JWP and check out the sample app for all sorts 
of examples of APT usage.


Shill time over :)

Frank

draegoon Z wrote:

Hey,

I use DWR + dojo to use AJAX with struts:

http://getahead.ltd.uk/dwr/

http://dojotoolkit.com/

Although dojo has some flashy widgets and stuff, its power is the 
dojo.io.bind() function:


http://dojotoolkit.org/docs/intro_to_dojo_io.html



Here is an example of using Struts Actions with bind():


action="process_new_mail" enctype="multipart/form-data" focus="to">



property="to">class='error'>To:




...
//more form elements
...

SUBMIT


NOTE: form has been given a 'styleId' and using 
 to display errors in form



function submitNewMail(){

   //validateNewMail(form);

   var bindArgs = {
   url: "",
   error: function(type, data, evt){
   alert("An error occurred submitting new mail: " + data);
   },
   load: function(type, data, evt){

   DWRUtil.setValue("social_mail_right_con", data);/* 
setValue doesn't execute javascript! */
   
document.getElementById('social_popup_layer_container').innerHTML=document.getElementById('ajax_hidden_helper').innerHTML; 


   popup('social_popup_layer_container',true);

   },
   mimetype: "text/html",
   formNode: document.getElementById("compose_mail_form")
   };

   dojo.io.bind(bindArgs);
   }


NOTE:

1) the use of  for the 'url'

2) formNode is the 'styleId' of your 

3) the stuff you see in the load function is application specific. It 
is how I display 
   and  in a backwards-compatible manner for AJAX. I 
basically force
   the reloading of a JSP (tile) that has the code:  
and relevant logic.



Ok, now for the good stuff:

1) Yes, your ActionForm will work as usual. If it is invalid, errors 
are displayed. If it validates, it goes

   on to the Action.

2) The action MUST RETURN "NULL", otherwise the page will reload to 
your 


3) You write your output to the response object in your action. 
Remember when it was just servlets?


public ActionForward execute(ActionMapping mapping, ActionForm form, 
HttpServletRequest request, HttpServletResponse response) throws 
IOException, ServletException {


//Make ActionMessages for business logic errors...
ActionMessages messages = new ActionMessages();
HttpSession session = request.getSession();
MyForm f = (MyForm)form;

response.setContentType("text/html");
PrintWriter out = response.getWriter();


out.print("ACTION_SUCCESS:Message Sent!");
out.close();


//return(mapping.findForward("success"));NOT AJAX WAY!

return(null);
}


There are many ways to handle the repsonse stuff with AJAX + 

Re: Struts and AJAX

2006-07-03 Thread Frank W. Zammetti

I'm a big fan of DWR as well, it's a very worthy alternative.

But, I don't mind a little self-promotion, so... how does this strike 
you? ...



  

  
  to=to
  
  

  


Then, in your JSP:


class='error'>To:


 ...
//more form elements
...
SUBMIT



This would result in some Action, mapped to process_new_mail.do being 
executed, and you would get a single parameter submitted, "to", using 
the value of the form field "to".  The response from the server, 
whatever it is, would be displayed via alert().


This is what AjaxParts Taglib (APT) offers... you define an event in a 
config file, some user-initiated (usually) event that fires an AJAX 
request.  For each event, you define a request handler, which forms the 
request to the server... there are a number of "standard" handlers, for 
instance, if you want to construct XML from your form, that's standard. 
 You also define one (or more) response handlers, which is something 
that happens when the response comes back.  Again, there are a number of 
standard handlers, like Alerter... there is also things like InnerHTML 
(populate a page element by updating innerHTML), stdXSLT (transform XML 
response via XSLT on client), and much more.


Note that you didn't have to right ANY Javascript whatsoever!  And the 
changes to your JSP amounts to adding an  tag to any element 
that will fire an AJAX event, and the  tag at the end (plus 
the taglib declaration of course).  Changing the AJAX functionality is 
as easy as modifying the config file, you wouldn't need to touch your 
JSP again!  And, should you need to do more advanced things that the 
standard handlers don't cover (they should do the job probably 80% of 
the time or better though), there is a pretty simple mechanism for 
writing your own custom handlers, which you can then use just like the 
standard handlers.


If the no coding approach sounds good, check it out further:

http://javawebparts.sourceforge.net/

I suggest clicking the Javadocs link and going to the first package 
listed, javawebparts.ajaxparts.taglib... all the details can be found 
there... then, download JWP and check out the sample app for all sorts 
of examples of APT usage.


Shill time over :)

Frank

draegoon Z wrote:

Hey,

I use DWR + dojo to use AJAX with struts:

http://getahead.ltd.uk/dwr/

http://dojotoolkit.com/

Although dojo has some flashy widgets and stuff, its power is the 
dojo.io.bind() function:


http://dojotoolkit.org/docs/intro_to_dojo_io.html



Here is an example of using Struts Actions with bind():


action="process_new_mail" enctype="multipart/form-data" focus="to">



property="to">class='error'>To:




...
//more form elements
...

SUBMIT


NOTE: form has been given a 'styleId' and using  
to display errors in form



function submitNewMail(){

   //validateNewMail(form);

   var bindArgs = {
   url: "",
   error: function(type, data, evt){
   alert("An error occurred submitting new mail: " + data);
   },
   load: function(type, data, evt){

   DWRUtil.setValue("social_mail_right_con", data);/* 
setValue doesn't execute javascript! */
   
document.getElementById('social_popup_layer_container').innerHTML=document.getElementById('ajax_hidden_helper').innerHTML; 


   popup('social_popup_layer_container',true);

   },
   mimetype: "text/html",
   formNode: document.getElementById("compose_mail_form")
   };

   dojo.io.bind(bindArgs);
   }


NOTE:

1) the use of  for the 'url'

2) formNode is the 'styleId' of your 

3) the stuff you see in the load function is application specific. It is 
how I display 
   and  in a backwards-compatible manner for AJAX. I 
basically force
   the reloading of a JSP (tile) that has the code:  and 
relevant logic.



Ok, now for the good stuff:

1) Yes, your ActionForm will work as usual. If it is invalid, errors are 
displayed. If it validates, it goes

   on to the Action.

2) The action MUST RETURN "NULL", otherwise the page will reload to your 



3) You write your output to the response object in your action. Remember 
when it was just servlets?


public ActionForward execute(ActionMapping mapping, ActionForm form, 
HttpServletRequest request, HttpServletResponse response) throws 
IOException, ServletException {


//Make ActionMessages for business logic errors...
ActionMessages messages = new ActionMessages();
HttpSession session = request.getSession();
MyForm f = (MyForm)form;

response.setContentType("text/html");
PrintWriter out = response.getWriter();


out.print("ACTION_SUCCESS:Message Sent!");
out.close();


//return(mapping.findForward("success"));NOT AJAX WAY!

return(null);
}


There are many ways to handle the repsonse stuff with AJAX + STRUTS. Use 
your imagination.


In this instance I just have a javascript function parse the output. You 
could return HTML and use

innerHTML(). You could parse a string l

RE: Struts and AJAX

2006-07-03 Thread draegoon Z

Hey,

I use DWR + dojo to use AJAX with struts:

http://getahead.ltd.uk/dwr/

http://dojotoolkit.com/

Although dojo has some flashy widgets and stuff, its power is the 
dojo.io.bind() function:


http://dojotoolkit.org/docs/intro_to_dojo_io.html



Here is an example of using Struts Actions with bind():


action="process_new_mail" enctype="multipart/form-data" focus="to">



property="to">class='error'>To:




...
//more form elements
...

SUBMIT


NOTE: form has been given a 'styleId' and using  to 
display errors in form



function submitNewMail(){

   //validateNewMail(form);

   var bindArgs = {
   url: "",
   error: function(type, data, evt){
   alert("An error occurred submitting new mail: " + data);
   },
   load: function(type, data, evt){

   DWRUtil.setValue("social_mail_right_con", data);/* setValue 
doesn't execute javascript! */
   
document.getElementById('social_popup_layer_container').innerHTML=document.getElementById('ajax_hidden_helper').innerHTML;

   popup('social_popup_layer_container',true);

   },
   mimetype: "text/html",
   formNode: document.getElementById("compose_mail_form")
   };

   dojo.io.bind(bindArgs);
   }


NOTE:

1) the use of  for the 'url'

2) formNode is the 'styleId' of your 

3) the stuff you see in the load function is application specific. It is how 
I display 
   and  in a backwards-compatible manner for AJAX. I 
basically force
   the reloading of a JSP (tile) that has the code:  and 
relevant logic.



Ok, now for the good stuff:

1) Yes, your ActionForm will work as usual. If it is invalid, errors are 
displayed. If it validates, it goes

   on to the Action.

2) The action MUST RETURN "NULL", otherwise the page will reload to your 



3) You write your output to the response object in your action. Remember 
when it was just servlets?


public ActionForward execute(ActionMapping mapping, ActionForm form, 
HttpServletRequest request, HttpServletResponse response) throws 
IOException, ServletException {


//Make ActionMessages for business logic errors...
ActionMessages messages = new ActionMessages();
HttpSession session = request.getSession();
MyForm f = (MyForm)form;

response.setContentType("text/html");
PrintWriter out = response.getWriter();


out.print("ACTION_SUCCESS:Message Sent!");
out.close();


//return(mapping.findForward("success")); NOT AJAX WAY!

return(null);
}


There are many ways to handle the repsonse stuff with AJAX + STRUTS. Use 
your imagination.


In this instance I just have a javascript function parse the output. You 
could return HTML and use

innerHTML(). You could parse a string like: "FORWARD:my_action_name".
You could have: "JAVASCRIPT-FUNCTION:handleSuccess()".

I often use dojo.io.bind() in conjunction with DWR.setValue():

http://getahead.ltd.uk/dwr/browser/util/setvalue

or using DWR to forward to a JSP:

http://getahead.ltd.uk/dwr/examples/text



Bottom line is that javascript will handle the forwarding instead of you 
struts config.

If some has a way to do it with the config, I'd love to hear from you.


BTW - I took the time to write this because after all the reading and 
searching I did,
I still didn't have a clue how to use all this stuff together. I hope this 
helps everyone.


-Joe




---

WEB DESIGN BY DRAEGOONZ

Joseph "DraegoonZ" McGranaghan

http://www.draegoonZ.com

603-620-0854

[EMAIL PROTECTED]





From: chamal desilva <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" 
To: user@struts.apache.org
Subject: Struts and AJAX
Date: Sun, 2 Jul 2006 20:57:52 -0700 (PDT)

Hi,

Can I use struts with AJAX. Does struts has classes
and tags for AJAX or do I have write my own code.

Thanking You,
Chamal.

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

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





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



Re: Struts and AJAX

2006-07-03 Thread Jorge Martín Cuervo
I use struts + DWR to develope ajax applications.

http://getahead.ltd.uk/dwr/

El lun, 03 de 07 de 2006 a las 05:57, chamal desilva escribió:

> Hi,
> 
> Can I use struts with AJAX. Does struts has classes
> and tags for AJAX or do I have write my own code.
> 
> Thanking You,
> Chamal.
> 
> __
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-- 
;-)

Jorge Martin Cuervo
Analista Programador

Outsourcing Emarketplace
deFacto Powered by Standards

email <[EMAIL PROTECTED]>
voz +34 985 129 820
voz +34 660 026 384



Re: Struts and AJAX

2006-07-03 Thread C. Grobmeier
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

> Can I use struts with AJAX. Does struts has classes
> and tags for AJAX or do I have write my own code.

i have used:
* http://dojotoolkit.org/
with struts recently.
I like this very much although this does not consist of taglibs but of
pure javascript.

Cheers
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2.1 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEqOHrkv8rKBUE/T4RAgzXAJ0chM3rJm2+8twqk6gO+yYpLFsHRwCeNvxQ
ZGRlnn/LUQvluRLV4JVT/Tk=
=dTJF
-END PGP SIGNATURE-

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



Re: Struts and AJAX

2006-07-02 Thread Frank W. Zammetti
Depending on what version of Struts you use, there *IS* in fact an 
AJAX-enabled version of the HTML taglib:


http://struts.sourceforge.net/ajaxtags/index.html

However, this taglib is now superseded by a far superior option:

http://javawebparts.sourceforge.net/javadocs/javawebparts/taglib/ajaxtags/package-summary.html

This is a part of the Java Web Parts project:

http://javawebparts.sourceforge.net

Note that this is a completely different thing than the AjaxTags the 
other poster mentioned.  They have quite different focuses, so check out 
both and see which suits your needs (I obviously have a bias as to which 
is better!)  Also note that in the next 24 hours or so, a new, almost 
completely rewritten version will be released (rechristened AjaxParta 
Taglib) which is considerably better in just about every way.


For more generic information on AJAX and Struts together, check out this 
Wiki page, which includes a link to an introductory article which 
includes a simple Struts-based example application that might be of 
interest:


http://wiki.apache.org/struts/AjaxStruts

Lastly, you could have a look at this example application that is a 
concrete and more substantial example of AJAX within a Struts app:


http://struts.sourceforge.net/ajaxchat/index.html

Note that this application is featured in the upcoming book "Practical 
Ajax Projects with Java":


http://www.amazon.com/gp/product/1590596951/ref=sr_11_1/002-4165389-6332051?ie=UTF8

I hear it's a pretty good book ;)

Frank


[EMAIL PROTECTED] wrote:

You can use...

There are no tag libraries in Struts for AJAX.

Thanks and regards,
Pazhanikanthan. P (Paz)

Consultant for AXA,
HCL Australia Services Pty. Ltd.
Off   : +61-3-9618-4085
Mob : +61-0411-354-838




chamal desilva <[EMAIL PROTECTED]>
03/07/2006 01:57 PM
Please respond to "Struts Users Mailing List"

 
To: user@struts.apache.org
cc: 
Subject:Struts and AJAX



Hi,

Can I use struts with AJAX. Does struts has classes
and tags for AJAX or do I have write my own code.

Thanking You,
Chamal.

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


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


_ 
This e-mail has been scanned for viruses by MCI's Internet Managed 
Scanning Services - powered by MessageLabs. For further information 
visit http://www.mci.com





*
Important Note
This email (including any attachments) contains information which is 
confidential and may be subject to legal privilege.  If you are not 
the intended recipient you must not use, distribute or copy this 
email.  If you have received this email in error please notify the 
sender immediately and delete this email. Any views expressed in this 
email are not necessarily the views of AXA.   Thank you.

**



--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
Java Web Parts -
http://javawebparts.sourceforge.net
Supplying the wheel, so you don't have to reinvent it!

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



Re: Struts and AJAX

2006-07-02 Thread thamizh arasu
Hi,

For ur purpose struts is having ajaxtags. through which you can use ajax in 
your struts application. Refer http://ajaxtags.sourceforge.net/. 

chamal desilva <[EMAIL PROTECTED]> wrote: Hi,

Can I use struts with AJAX. Does struts has classes
and tags for AJAX or do I have write my own code.

Thanking You,
Chamal.

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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




BY

Thamizharasu S

-
Yahoo! Music Unlimited - Access over 1 million songs.Try it free. 

Re: Struts and AJAX

2006-07-02 Thread paz . periasamy
You can use...

There are no tag libraries in Struts for AJAX.

Thanks and regards,
Pazhanikanthan. P (Paz)

Consultant for AXA,
HCL Australia Services Pty. Ltd.
Off   : +61-3-9618-4085
Mob : +61-0411-354-838




chamal desilva <[EMAIL PROTECTED]>
03/07/2006 01:57 PM
Please respond to "Struts Users Mailing List"

 
To: user@struts.apache.org
cc: 
Subject:Struts and AJAX


Hi,

Can I use struts with AJAX. Does struts has classes
and tags for AJAX or do I have write my own code.

Thanking You,
Chamal.

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


_ 
This e-mail has been scanned for viruses by MCI's Internet Managed 
Scanning Services - powered by MessageLabs. For further information 
visit http://www.mci.com




*
Important Note
This email (including any attachments) contains information which is 
confidential and may be subject to legal privilege.  If you are not 
the intended recipient you must not use, distribute or copy this 
email.  If you have received this email in error please notify the 
sender immediately and delete this email. Any views expressed in this 
email are not necessarily the views of AXA.   Thank you.
**


re: Struts and Ajax

2006-04-06 Thread mcmoisei
You also can do it transparently using 
ajaxanywhere.sourceforge.org

Define a refresh zone around that dropdown you want to populate and then your 
onchange will 
do the regular re-post to bring data from server then instruct your zone to 
refresh and data will appear miracoulosly... :)

There are three advantages
- don't need to get dirty handling and parsing data
- your code doesn't change much
- has failover support - if js is disabled your repost will happen and data 
will be right.

Give it a try ;-)
MC


 -- Original message --
From: "Dean, Michael" <[EMAIL PROTECTED]>
> Madhav:
> 
>  
> 
> I think the idea IS:   Once your data stream (drop-down content) is
> returned to the page (onReadyStateChange()), you'll have a JavasScript
> handler in place to refresh your drop-down (you manipulate and re-render
> the DOM node using Javascript).  It is all done on the front-end...
> 
>  
> 
> See:
> 
> Ajax In Action  
> 
>  
> 
>  
> 
> Michael Dean
> 
> Senior Java Programmer
> 
> Information Services Division/Application Development Section/CAPS
> Maintenance
> 
> Administrative Office of the Courts
> 
> 360.704.4008
> 
> [EMAIL PROTECTED]  
> 
>  
> 
> 



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



Re: Struts and Ajax

2006-04-06 Thread Frank W. Zammetti
On Thu, April 6, 2006 3:18 am, Madhav Bhargava said:
> I do not want to put any Html generating logic inside my action class. Is
> there any other elegant way in which i can generate the HTML for the drop
> down.
>
> I can very well write different methods to generate the HTML code and then
> call these methods from within my action class. But somehow this does not
> look very elegant to me.

There sure is: you can let a JSP do it!

Remember that a JSP can actually render anything you want.  It doesn't
have to be HTML.  But, in your case, it probably would be.  However, it
still doesn't have to be a full HTML document, it can be just a snippet of
markup.

For instance, let's say you have an Action that populates a List, where
each item in the list is a Map with two elements, optionValue and
optionText.  Create one Map for each  in your select.  Then, stick
that list in request as an attribute under the name "myOptions".  Then
forward to a JSP.

The JSP, in simplest terms, can just be this:


<%
  List options = (List)request.getAttribute("myOptions");
  for (Iterator it = options.iterator(); it.hasNext();) {
Map m = (Map)it.next();
%>
"><%=m.get("optionText")%>
<%
  }
%>


Of course, you would probably want to use JSTL or Struts tags to do it,
but you get the idea.

Then, since you made this request via AJAX, you will have some callback
function on the client.  This callback function simply takes the response
and inserts it into a  that was surrounding the  that you
want to update.  That's the basic theory.

You can of course do DOM manipulation instead of just updating a  via
innerHTML, and you can of course find a library that takes care of the
details for you (AjaxTags in Java Web Parts for instance handler
specifically for populating s, and it accepts XML, which you can
generate in the JSP just as easily... other libraries have similar
functionality), but the basics are pretty much these.

As another poster pointed out, there is indeed an example of doing this in
the JWP cookbook, and most other libraries will probably have a similar
example, since this is such a common thing to do.

> Any help will be appreciated.
>
> --Madhav

Frank

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



re: Struts and Ajax

2006-04-06 Thread Dean, Michael
Madhav:

 

I think the idea IS:   Once your data stream (drop-down content) is
returned to the page (onReadyStateChange()), you'll have a JavasScript
handler in place to refresh your drop-down (you manipulate and re-render
the DOM node using Javascript).  It is all done on the front-end...

 

See:

Ajax In Action  

 

 

Michael Dean

Senior Java Programmer

Information Services Division/Application Development Section/CAPS
Maintenance

Administrative Office of the Courts

360.704.4008

[EMAIL PROTECTED]  

 



Re: Struts and Ajax

2006-04-06 Thread [EMAIL PROTECTED]
If you would like to create a helper class for your ajax stuff, here is a link
to show you what your Java code would look like. Follow Setup Configuration to
see how to set it up.
http://www.xoscript.org/opencms/opencms/documentation/aboutjava.html

Here is what the JavaScript code would look like.

var combo = myHelperClass.getSomeData(intValue);

//where intValue represents the argument expected by your Java method.
//combo is now a Map so

var iterator = combo.keySet().iterator();

while(iterator.hasNext()){
 var theKey = iterator.next();
 someDropDownBox.options[someDropDownBox.options.length] =
 new Option(theKey,combo.get(theKey));
}

I am testing a new version of xoscript with Struts integration so you can push
action forwards through a method call, I hope to have it ready soon.

Bryan LaPlante

-- Original Message ---
From: "Madhav Bhargava" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" 
Sent: Thu, 6 Apr 2006 12:48:04 +0530
Subject: Struts and Ajax

> Hi All,
>
> I have 2 drop downs in my JSP. One drop down gets populated based on the
> value selected in the other drop down. At present this is done using a Tag
> handler call. The control goes to a rendering action which then forwards the
> call to the JSP. From within the JSP the tag handler is invoked passing all
> the necessary arguments. This all works fine except that now the client
> wants to introduce Ajax so that a page refresh is avoided.
>
> I do not want to put any Html generating logic inside my action class. Is
> there any other elegant way in which i can generate the HTML for the drop
> down.
>
> I can very well write different methods to generate the HTML code and then
> call these methods from within my action class. But somehow this does not
> look very elegant to me.
>
> Any help will be appreciated.
>
> --Madhav
>
> --
> When I tell the truth, it is not for the sake of convincing those who do not
> know it, but for the sake of defending those that do 


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



Re: Struts and Ajax

2006-04-06 Thread chuanjiang lo
go take a look at http://javawebparts.sourceforge.net

they have a ajax dynamic double select servlet..



On 4/6/06, Madhav Bhargava <[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
> I have 2 drop downs in my JSP. One drop down gets populated based on the
> value selected in the other drop down. At present this is done using a Tag
> handler call. The control goes to a rendering action which then forwards
> the
> call to the JSP. From within the JSP the tag handler is invoked passing
> all
> the necessary arguments. This all works fine except that now the client
> wants to introduce Ajax so that a page refresh is avoided.
>
> I do not want to put any Html generating logic inside my action class. Is
> there any other elegant way in which i can generate the HTML for the drop
> down.
>
> I can very well write different methods to generate the HTML code and then
> call these methods from within my action class. But somehow this does not
> look very elegant to me.
>
> Any help will be appreciated.
>
> --Madhav
>
> --
> When I tell the truth, it is not for the sake of convincing those who do
> not
> know it, but for the sake of defending those that do
>
>


Re: Struts and AJAX

2006-04-04 Thread Frank W. Zammetti

Struts Wiki page:

http://wiki.apache.org/struts/AjaxStruts

See especially the article referenced on this page for a decent 
introduction as well as example Struts app.  Probably the best starting 
point.


After that, have a look at AjaxTags here:

http://javawebparts.sourceforge.net

(Click javadocs and navigate to the AjaxTags package)

And also:

http://getahead.ltd.uk/dwr/

And also:

http://dojotoolkit.org/

There are TONS more libraries out there, so feel free to explore, but 
these three are the ones I would personally suggest.  If you are not too 
comfortable with Javascript, I would suggest AjaxTags might be your best 
bet.  If you want something that makes it all look like remote procedure 
calls, DWR is the way to go, and if you want a general-purpose library, 
and especially if widgets are something you are interested in, Dojo is 
worth a close look.


If you want a real-world example of a Struts apps with AJAX (just plain 
AJAX, no library at all), there is one here:


http://struts.sourceforge.net/ajaxchat/index.html

HTH,
Frank

thamizh arasu wrote:

Hi,

I have developed application with struts. now i want to use ajax in my struts 
application. using ajax we can avoid refreshing the whole page. instead of that 
it enough to refresh the part of the page.

I like this functionality. if any one know the way to start struts with ajax 
please let me know.

i need some basic steps document for "struts with Ajax"

By
Thamizh


-
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.


--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
Java Web Parts -
http://javawebparts.sourceforge.net
Supplying the wheel, so you don't have to reinvent it!

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



RE: Struts and AJAX

2006-04-04 Thread Rakesh.Bhat

This http://www.omnytex.com/articles/xhrstruts/ might help u.


 
Kind regards,
 
Rakesh Bhat 
PrimeSourcing(tm) 
The Global IT Services  business from i-flex - "Add Value Reduce Risk"
www.iflexsolutions.com/services/services.asp
i-flex solutions limited - Bangalore
Phone : +91(080) 5759-6873
Email :  Rakesh.Bhat@ iflexsolutions.com
 
-Original Message-
From: thamizh arasu [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 05, 2006 10:27 AM
To: user@struts.apache.org
Subject: Struts and AJAX

Hi,

I have developed application with struts. now i want to use ajax in my
struts application. using ajax we can avoid refreshing the whole page.
instead of that it enough to refresh the part of the page.

I like this functionality. if any one know the way to start struts with
ajax please let me know.

i need some basic steps document for "struts with Ajax"

By
Thamizh


-
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low
rates.



DISCLAIMER:
This message contains privileged and confidential information and is intended 
only for the individual named.If you are not the intended recipient you should 
not disseminate,distribute,store,print, copy or deliver this message.Please 
notify the sender immediately by e-mail if you have received this e-mail by 
mistake and delete this e-mail from your system.E-mail transmission cannot be 
guaranteed to be secure or error-free as information could be 
intercepted,corrupted,lost,destroyed,arrive late or incomplete or contain 
viruses.The sender therefore does not accept liability for any errors or 
omissions in the contents of this message which arise as a result of e-mail 
transmission. If verification is required please request a hard-copy version.

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