You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by aarthy <me...@yahoo.com> on 2007/10/10 17:26:14 UTC

Ajax Call from a html link

I have a jsp page named "tvshow.jsp", wherein I am populating the characters
dropdown as and when the TV Show dropdown value changes , by calling the
javascript in the “onchange()” of the select box.
have added a html link, and I want to call the same function from my action
class and I need to populate the character dropdown by clicking the html
link. I am stuck up with this issue.Character dropdown is not populated with
the data from tha action class. Need some help on this please!

<%@ page import="java.util.*"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<script language="javascript">
 function retrieveURL(url) {
    if (window.XMLHttpRequest) { // Non-IE browsers
      req = new XMLHttpRequest();
      req.onreadystatechange = processStateChange;
      try {
        req.open("GET", url, true);
        
      } catch (e) {
        alert(e);
      }
      req.send(null);
    } else if (window.ActiveXObject) { // IE
      req = new ActiveXObject("Microsoft.XMLHTTP");
      if (req) {
        req.onreadystatechange = processStateChange;
        req.open("GET", url, true);
        req.send();
          
      }
    }
  }

  function processStateChange() {
    if (req.readyState == 4) { // Complete
      if (req.status == 200) { // OK response
        document.getElementById("characters").innerHTML = req.responseText;
            } else {
        alert("Problem: " + req.statusText);
      }
    }
  }

</script>


<form action="ShowCharacters">
/jsp/tvshow.jsp Click here 

		TV Show:
		<select name="TVShowSelect"
onChange="retrieveURL('ShowCharacters.do?tvShow=' + this.value);">
		<option value="Lissie Maguire"> Lissie Maguire </option>
			<option value="That’s so Raven"> That’s so Raven </option>
			<option value="Dhoom machale"> Dhoom machale </option>
		</select>
		
		<br>
		Characters: 
	</form>	

ShowCharacters.jsp

<%@page import="java.util.ArrayList"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<select name="TVShowSelect"> 
<%  ArrayList ch =
(ArrayList)request.getSession().getAttribute("characters"); 
    String[] s = new String[ch.size()]; 
    ch.toArray(s); 
    for (int i = 0; i < s.length; i++) { 
        String name = s[i]; 
%> 
        <option><%=name%></option> 
<%  } 
%> 
</select> 

Thanks
-- 
View this message in context: http://www.nabble.com/Ajax-Call-from-a-html-link-tf4601558.html#a13138152
Sent from the Struts - User mailing list archive at Nabble.com.


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


RE: Ajax Call from a html link

Posted by Dave Newton <ne...@yahoo.com>.
--- aarthy <me...@yahoo.com> wrote:
> No.I am running in I.E.

Unless you are using one of the IE plugins for web
development you are making things more difficult than
necessary. Test on Firefox with the Firebug plugin
then verify it works under IE.

>> Have you examined the returned data to ensure it's
correct?
> returned data is correct.but I don't get any data
back from
> the action class.

What "returned data" are you talking about then?

It's not clear to me what "link" you're clicking; are
you talking about the <select...> tag onchange
handler?

d.



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


RE: Ajax Call from a html link

Posted by aarthy <me...@yahoo.com>.
No.I am running in I.E.

>Have you verified
that your Action is getting called?

Action class is not being called.

Have you examined the returned data
to ensure it's correct?
returned data is correct.but I don't get any data back from the action
class.


Frank W. Zammetti wrote:
> 
> Well, what debugging have you attempted?  Are you running in Firefox with
> Firebug for instance and seeing some client-side error?  Have you verified
> that your Action is getting called?  Have you examined the returned data
> to ensure it's correct?
> 
> -- 
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM/Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> Author of "Practical Ajax Projects With Java Technology"
>  (2006, Apress, ISBN 1-59059-695-1)
> and "JavaScript, DOM Scripting and Ajax Projects"
>  (2007, Apress, ISBN 1-59059-816-4)
> Java Web Parts - http://javawebparts.sourceforge.net
>  Supplying the wheel, so you don't have to reinvent it!
> 
> On Wed, October 10, 2007 3:30 pm, aarthy wrote:
>>
>> In my code
>>
>> " /jsp/tvshow.jsp Click here "
>> when the html link is clicked, it  does not populate the second drop down
>> box with values.
>> I dont know what the problem is?
>>
>>
>>
>> Frank W. Zammetti wrote:
>>>
>>> You already have the code, you posted it! :)  If you're having some
>>> *specific* problem, you'll find many helpful people here, but just
>>> saying
>>> "my code doesn't work, please help" won't elicit too many (helpful)
>>> replies.
>>>
>>> Frank
>>>
>>> --
>>> Frank W. Zammetti
>>> Founder and Chief Software Architect
>>> Omnytex Technologies
>>> http://www.omnytex.com
>>> AIM/Yahoo: fzammetti
>>> MSN: fzammetti@hotmail.com
>>> Author of "Practical Ajax Projects With Java Technology"
>>>  (2006, Apress, ISBN 1-59059-695-1)
>>> and "JavaScript, DOM Scripting and Ajax Projects"
>>>  (2007, Apress, ISBN 1-59059-816-4)
>>> Java Web Parts - http://javawebparts.sourceforge.net
>>>  Supplying the wheel, so you don't have to reinvent it!
>>>
>>> On Wed, October 10, 2007 3:13 pm, aarthy wrote:
>>>>
>>>> Can someone  provide me with an example code.I need to implement ajax
>>>> in
>>>> my
>>>> struts project, when html link is clicked.
>>>>
>>>>
>>>>
>>>> ghodgins wrote:
>>>>>
>>>>> Not to detract at all from the great JWP project but you can also do
>>>>> this with AjaxTags.
>>>>>
>>>>> The ajax:select tag is described here:
>>>>> http://ajaxtags.sourceforge.net/usage.html
>>>>>
>>>>> I used ajax:select to call an action that returned XML using the handy
>>>>> AjaxXmlBuilder that came with AjaxTags.
>>>>>
>>>>> Cheers,
>>>>> Grant
>>>>>
>>>>>
>>>>> -----Original Message-----
>>>>> From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
>>>>> Sent: Wednesday, October 10, 2007 11:31 AM
>>>>> To: Struts Users Mailing List
>>>>> Cc: Struts Users Mailing List
>>>>> Subject: Re: Ajax Call from a html link
>>>>>
>>>>> Just an FYI, that article is a little outdated... APT's feature set is
>>>>> a
>>>>> bit larger than the article talks about now for one thing, although in
>>>>> glancing over it again, I don't see anything that's not applicable
>>>>> now.
>>>>>
>>>>> Also note that the link to Rick Reumann's article is no longer valid,
>>>>> it
>>>>> is now here:
>>>>> http://www.learntechnology.net/content/ajax/ajax_select_alter.jsp ...
>>>>> Rick also updated that article for APT fairly recently, so it's even
>>>>> better than it was.
>>>>>
>>>>> Lastly, I didn't provide a link to my own book in that article!  D'oh!
>>>>> Here's one:
>>>>> http://apress.com/book/search?searchterm=zammetti&act=search
>>>>> ...
>>>>> chapters 4 and 6 there are what's of interest, although as the note in
>>>>> the article says, they aren't based on the latest version, so although
>>>>> the underlying concepts are pretty much the same, some of the details
>>>>> are slightly different now.
>>>>>
>>>>> --
>>>>> Frank W. Zammetti
>>>>> Founder and Chief Software Architect
>>>>> Omnytex Technologies
>>>>> http://www.omnytex.com
>>>>> AIM/Yahoo: fzammetti
>>>>> MSN: fzammetti@hotmail.com
>>>>> Author of "Practical Ajax Projects With Java Technology"
>>>>>  (2006, Apress, ISBN 1-59059-695-1)
>>>>> and "JavaScript, DOM Scripting and Ajax Projects"
>>>>>  (2007, Apress, ISBN 1-59059-816-4)
>>>>> Java Web Parts - http://javawebparts.sourceforge.net
>>>>>  Supplying the wheel, so you don't have to reinvent it!
>>>>>
>>>>> On Wed, October 10, 2007 12:50 pm, Ted Husted wrote:
>>>>>> I believe this exact example is included with the AjaxParts Taglib,
>>>>>> which works well with Struts (1 or 2). If anyone is going to be using
>>>>>> Ajax and JSP tags together, AjaxParts is a great way to go  (and easy
>>>>>> to learn!).
>>>>>>
>>>>>>  * http://www.omnytex.com/articles/apt/
>>>>>>
>>>>>> HTH, Ted.
>>>>>> <http://husted.com/ted/blog>
>>>>>>
>>>>>>
>>>>>> On 10/10/07, aarthy <me...@yahoo.com> wrote:
>>>>>>>
>>>>>>> I have a jsp page named "tvshow.jsp", wherein I am populating the
>>>>>>> characters dropdown as and when the TV Show dropdown value changes ,
>>>>>>> by calling the javascript in the "onchange()" of the select box.
>>>>>>> have added a html link, and I want to call the same function from my
>>>>>>> action class and I need to populate the character dropdown by
>>>>>>> clicking the html link. I am stuck up with this issue.Character
>>>>>>> dropdown is not populated with the data from tha action class. Need
>>>>>>> some help on this please!
>>>>>>>
>>>>>>> <%@ page import="java.util.*"%>
>>>>>>> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
>>>>>>> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"
>>>>>>> %> <script language="javascript">  function retrieveURL(url) {
>>>>>>>     if (window.XMLHttpRequest) { // Non-IE browsers
>>>>>>>       req = new XMLHttpRequest();
>>>>>>>       req.onreadystatechange = processStateChange;
>>>>>>>       try {
>>>>>>>         req.open("GET", url, true);
>>>>>>>
>>>>>>>       } catch (e) {
>>>>>>>         alert(e);
>>>>>>>       }
>>>>>>>       req.send(null);
>>>>>>>     } else if (window.ActiveXObject) { // IE
>>>>>>>       req = new ActiveXObject("Microsoft.XMLHTTP");
>>>>>>>       if (req) {
>>>>>>>         req.onreadystatechange = processStateChange;
>>>>>>>         req.open("GET", url, true);
>>>>>>>         req.send();
>>>>>>>
>>>>>>>       }
>>>>>>>     }
>>>>>>>   }
>>>>>>>
>>>>>>>   function processStateChange() {
>>>>>>>     if (req.readyState == 4) { // Complete
>>>>>>>       if (req.status == 200) { // OK response
>>>>>>>         document.getElementById("characters").innerHTML =
>>>>>>> req.responseText;
>>>>>>>             } else {
>>>>>>>         alert("Problem: " + req.statusText);
>>>>>>>       }
>>>>>>>     }
>>>>>>>   }
>>>>>>>
>>>>>>> </script>
>>>>>>>
>>>>>>>
>>>>>>> <form action="ShowCharacters">
>>>>>>> /jsp/tvshow.jsp Click here
>>>>>>>
>>>>>>>                 TV Show:
>>>>>>>                 <select name="TVShowSelect"
>>>>>>> onChange="retrieveURL('ShowCharacters.do?tvShow=' + this.value);">
>>>>>>>                 <option value="Lissie Maguire"> Lissie Maguire
>>>>> </option>
>>>>>>>                         <option value="That's so Raven"> That's so
>>>>>>> Raven </option>
>>>>>>>                         <option value="Dhoom machale"> Dhoom machale
>>>>>>> </option>
>>>>>>>                 </select>
>>>>>>>
>>>>>>>                 <br>
>>>>>>>                 Characters:
>>>>>>>         </form>
>>>>>>>
>>>>>>> ShowCharacters.jsp
>>>>>>>
>>>>>>> <%@page import="java.util.ArrayList"%>
>>>>>>>
>>>>>>> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
>>>>>>> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
>>>>>>> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"
>>>>>>> %>
>>>>>>>
>>>>>>> <select name="TVShowSelect">
>>>>>>> <%  ArrayList ch =
>>>>>>> (ArrayList)request.getSession().getAttribute("characters");
>>>>>>>     String[] s = new String[ch.size()];
>>>>>>>     ch.toArray(s);
>>>>>>>     for (int i = 0; i < s.length; i++) {
>>>>>>>         String name = s[i];
>>>>>>> %>
>>>>>>>         <option><%=name%></option>
>>>>>>> <%  }
>>>>>>> %>
>>>>>>> </select>
>>>>>>>
>>>>>>> Thanks
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> 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
>>>>>
>>>>>
>>>>>
>>>>> ----Notice Regarding Confidentiality----
>>>>> This email, including any and all attachments, (this "Email") is
>>>>> intended
>>>>> only for the party to whom it is addressed and may contain information
>>>>> that is confidential or privileged.  Sierra Systems Group Inc. and its
>>>>> affiliates accept no responsibility for any loss or damage suffered by
>>>>> any
>>>>> person resulting from any unauthorized use of or reliance upon this
>>>>> Email.
>>>>> If you are not the intended recipient, you are hereby notified that
>>>>> any
>>>>> dissemination, copying or other use of this Email is prohibited.
>>>>> Please
>>>>> notify us of the error in communication by return email and destroy
>>>>> all
>>>>> copies of this Email.  Thank you.
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Ajax-Call-from-a-html-link-tf4601558.html#a13142624
>>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Ajax-Call-from-a-html-link-tf4601558.html#a13142912
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Ajax-Call-from-a-html-link-tf4601558.html#a13143332
Sent from the Struts - User mailing list archive at Nabble.com.


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


RE: Ajax Call from a html link

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Well, what debugging have you attempted?  Are you running in Firefox with
Firebug for instance and seeing some client-side error?  Have you verified
that your Action is getting called?  Have you examined the returned data
to ensure it's correct?

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
 (2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Wed, October 10, 2007 3:30 pm, aarthy wrote:
>
> In my code
>
> " /jsp/tvshow.jsp Click here "
> when the html link is clicked, it  does not populate the second drop down
> box with values.
> I dont know what the problem is?
>
>
>
> Frank W. Zammetti wrote:
>>
>> You already have the code, you posted it! :)  If you're having some
>> *specific* problem, you'll find many helpful people here, but just
>> saying
>> "my code doesn't work, please help" won't elicit too many (helpful)
>> replies.
>>
>> Frank
>>
>> --
>> Frank W. Zammetti
>> Founder and Chief Software Architect
>> Omnytex Technologies
>> http://www.omnytex.com
>> AIM/Yahoo: fzammetti
>> MSN: fzammetti@hotmail.com
>> Author of "Practical Ajax Projects With Java Technology"
>>  (2006, Apress, ISBN 1-59059-695-1)
>> and "JavaScript, DOM Scripting and Ajax Projects"
>>  (2007, Apress, ISBN 1-59059-816-4)
>> Java Web Parts - http://javawebparts.sourceforge.net
>>  Supplying the wheel, so you don't have to reinvent it!
>>
>> On Wed, October 10, 2007 3:13 pm, aarthy wrote:
>>>
>>> Can someone  provide me with an example code.I need to implement ajax
>>> in
>>> my
>>> struts project, when html link is clicked.
>>>
>>>
>>>
>>> ghodgins wrote:
>>>>
>>>> Not to detract at all from the great JWP project but you can also do
>>>> this with AjaxTags.
>>>>
>>>> The ajax:select tag is described here:
>>>> http://ajaxtags.sourceforge.net/usage.html
>>>>
>>>> I used ajax:select to call an action that returned XML using the handy
>>>> AjaxXmlBuilder that came with AjaxTags.
>>>>
>>>> Cheers,
>>>> Grant
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
>>>> Sent: Wednesday, October 10, 2007 11:31 AM
>>>> To: Struts Users Mailing List
>>>> Cc: Struts Users Mailing List
>>>> Subject: Re: Ajax Call from a html link
>>>>
>>>> Just an FYI, that article is a little outdated... APT's feature set is
>>>> a
>>>> bit larger than the article talks about now for one thing, although in
>>>> glancing over it again, I don't see anything that's not applicable
>>>> now.
>>>>
>>>> Also note that the link to Rick Reumann's article is no longer valid,
>>>> it
>>>> is now here:
>>>> http://www.learntechnology.net/content/ajax/ajax_select_alter.jsp ...
>>>> Rick also updated that article for APT fairly recently, so it's even
>>>> better than it was.
>>>>
>>>> Lastly, I didn't provide a link to my own book in that article!  D'oh!
>>>> Here's one:
>>>> http://apress.com/book/search?searchterm=zammetti&act=search
>>>> ...
>>>> chapters 4 and 6 there are what's of interest, although as the note in
>>>> the article says, they aren't based on the latest version, so although
>>>> the underlying concepts are pretty much the same, some of the details
>>>> are slightly different now.
>>>>
>>>> --
>>>> Frank W. Zammetti
>>>> Founder and Chief Software Architect
>>>> Omnytex Technologies
>>>> http://www.omnytex.com
>>>> AIM/Yahoo: fzammetti
>>>> MSN: fzammetti@hotmail.com
>>>> Author of "Practical Ajax Projects With Java Technology"
>>>>  (2006, Apress, ISBN 1-59059-695-1)
>>>> and "JavaScript, DOM Scripting and Ajax Projects"
>>>>  (2007, Apress, ISBN 1-59059-816-4)
>>>> Java Web Parts - http://javawebparts.sourceforge.net
>>>>  Supplying the wheel, so you don't have to reinvent it!
>>>>
>>>> On Wed, October 10, 2007 12:50 pm, Ted Husted wrote:
>>>>> I believe this exact example is included with the AjaxParts Taglib,
>>>>> which works well with Struts (1 or 2). If anyone is going to be using
>>>>> Ajax and JSP tags together, AjaxParts is a great way to go  (and easy
>>>>> to learn!).
>>>>>
>>>>>  * http://www.omnytex.com/articles/apt/
>>>>>
>>>>> HTH, Ted.
>>>>> <http://husted.com/ted/blog>
>>>>>
>>>>>
>>>>> On 10/10/07, aarthy <me...@yahoo.com> wrote:
>>>>>>
>>>>>> I have a jsp page named "tvshow.jsp", wherein I am populating the
>>>>>> characters dropdown as and when the TV Show dropdown value changes ,
>>>>>> by calling the javascript in the "onchange()" of the select box.
>>>>>> have added a html link, and I want to call the same function from my
>>>>>> action class and I need to populate the character dropdown by
>>>>>> clicking the html link. I am stuck up with this issue.Character
>>>>>> dropdown is not populated with the data from tha action class. Need
>>>>>> some help on this please!
>>>>>>
>>>>>> <%@ page import="java.util.*"%>
>>>>>> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
>>>>>> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"
>>>>>> %> <script language="javascript">  function retrieveURL(url) {
>>>>>>     if (window.XMLHttpRequest) { // Non-IE browsers
>>>>>>       req = new XMLHttpRequest();
>>>>>>       req.onreadystatechange = processStateChange;
>>>>>>       try {
>>>>>>         req.open("GET", url, true);
>>>>>>
>>>>>>       } catch (e) {
>>>>>>         alert(e);
>>>>>>       }
>>>>>>       req.send(null);
>>>>>>     } else if (window.ActiveXObject) { // IE
>>>>>>       req = new ActiveXObject("Microsoft.XMLHTTP");
>>>>>>       if (req) {
>>>>>>         req.onreadystatechange = processStateChange;
>>>>>>         req.open("GET", url, true);
>>>>>>         req.send();
>>>>>>
>>>>>>       }
>>>>>>     }
>>>>>>   }
>>>>>>
>>>>>>   function processStateChange() {
>>>>>>     if (req.readyState == 4) { // Complete
>>>>>>       if (req.status == 200) { // OK response
>>>>>>         document.getElementById("characters").innerHTML =
>>>>>> req.responseText;
>>>>>>             } else {
>>>>>>         alert("Problem: " + req.statusText);
>>>>>>       }
>>>>>>     }
>>>>>>   }
>>>>>>
>>>>>> </script>
>>>>>>
>>>>>>
>>>>>> <form action="ShowCharacters">
>>>>>> /jsp/tvshow.jsp Click here
>>>>>>
>>>>>>                 TV Show:
>>>>>>                 <select name="TVShowSelect"
>>>>>> onChange="retrieveURL('ShowCharacters.do?tvShow=' + this.value);">
>>>>>>                 <option value="Lissie Maguire"> Lissie Maguire
>>>> </option>
>>>>>>                         <option value="That's so Raven"> That's so
>>>>>> Raven </option>
>>>>>>                         <option value="Dhoom machale"> Dhoom machale
>>>>>> </option>
>>>>>>                 </select>
>>>>>>
>>>>>>                 <br>
>>>>>>                 Characters:
>>>>>>         </form>
>>>>>>
>>>>>> ShowCharacters.jsp
>>>>>>
>>>>>> <%@page import="java.util.ArrayList"%>
>>>>>>
>>>>>> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
>>>>>> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
>>>>>> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"
>>>>>> %>
>>>>>>
>>>>>> <select name="TVShowSelect">
>>>>>> <%  ArrayList ch =
>>>>>> (ArrayList)request.getSession().getAttribute("characters");
>>>>>>     String[] s = new String[ch.size()];
>>>>>>     ch.toArray(s);
>>>>>>     for (int i = 0; i < s.length; i++) {
>>>>>>         String name = s[i];
>>>>>> %>
>>>>>>         <option><%=name%></option>
>>>>>> <%  }
>>>>>> %>
>>>>>> </select>
>>>>>>
>>>>>> Thanks
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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
>>>>
>>>>
>>>>
>>>> ----Notice Regarding Confidentiality----
>>>> This email, including any and all attachments, (this "Email") is
>>>> intended
>>>> only for the party to whom it is addressed and may contain information
>>>> that is confidential or privileged.  Sierra Systems Group Inc. and its
>>>> affiliates accept no responsibility for any loss or damage suffered by
>>>> any
>>>> person resulting from any unauthorized use of or reliance upon this
>>>> Email.
>>>> If you are not the intended recipient, you are hereby notified that
>>>> any
>>>> dissemination, copying or other use of this Email is prohibited.
>>>> Please
>>>> notify us of the error in communication by return email and destroy
>>>> all
>>>> copies of this Email.  Thank you.
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Ajax-Call-from-a-html-link-tf4601558.html#a13142624
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Ajax-Call-from-a-html-link-tf4601558.html#a13142912
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: Ajax Call from a html link

Posted by aarthy <me...@yahoo.com>.
In my code 

" /jsp/tvshow.jsp Click here "
when the html link is clicked, it  does not populate the second drop down
box with values.
I dont know what the problem is?



Frank W. Zammetti wrote:
> 
> You already have the code, you posted it! :)  If you're having some
> *specific* problem, you'll find many helpful people here, but just saying
> "my code doesn't work, please help" won't elicit too many (helpful)
> replies.
> 
> Frank
> 
> -- 
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM/Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> Author of "Practical Ajax Projects With Java Technology"
>  (2006, Apress, ISBN 1-59059-695-1)
> and "JavaScript, DOM Scripting and Ajax Projects"
>  (2007, Apress, ISBN 1-59059-816-4)
> Java Web Parts - http://javawebparts.sourceforge.net
>  Supplying the wheel, so you don't have to reinvent it!
> 
> On Wed, October 10, 2007 3:13 pm, aarthy wrote:
>>
>> Can someone  provide me with an example code.I need to implement ajax in
>> my
>> struts project, when html link is clicked.
>>
>>
>>
>> ghodgins wrote:
>>>
>>> Not to detract at all from the great JWP project but you can also do
>>> this with AjaxTags.
>>>
>>> The ajax:select tag is described here:
>>> http://ajaxtags.sourceforge.net/usage.html
>>>
>>> I used ajax:select to call an action that returned XML using the handy
>>> AjaxXmlBuilder that came with AjaxTags.
>>>
>>> Cheers,
>>> Grant
>>>
>>>
>>> -----Original Message-----
>>> From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
>>> Sent: Wednesday, October 10, 2007 11:31 AM
>>> To: Struts Users Mailing List
>>> Cc: Struts Users Mailing List
>>> Subject: Re: Ajax Call from a html link
>>>
>>> Just an FYI, that article is a little outdated... APT's feature set is a
>>> bit larger than the article talks about now for one thing, although in
>>> glancing over it again, I don't see anything that's not applicable now.
>>>
>>> Also note that the link to Rick Reumann's article is no longer valid, it
>>> is now here:
>>> http://www.learntechnology.net/content/ajax/ajax_select_alter.jsp ...
>>> Rick also updated that article for APT fairly recently, so it's even
>>> better than it was.
>>>
>>> Lastly, I didn't provide a link to my own book in that article!  D'oh!
>>> Here's one: http://apress.com/book/search?searchterm=zammetti&act=search
>>> ...
>>> chapters 4 and 6 there are what's of interest, although as the note in
>>> the article says, they aren't based on the latest version, so although
>>> the underlying concepts are pretty much the same, some of the details
>>> are slightly different now.
>>>
>>> --
>>> Frank W. Zammetti
>>> Founder and Chief Software Architect
>>> Omnytex Technologies
>>> http://www.omnytex.com
>>> AIM/Yahoo: fzammetti
>>> MSN: fzammetti@hotmail.com
>>> Author of "Practical Ajax Projects With Java Technology"
>>>  (2006, Apress, ISBN 1-59059-695-1)
>>> and "JavaScript, DOM Scripting and Ajax Projects"
>>>  (2007, Apress, ISBN 1-59059-816-4)
>>> Java Web Parts - http://javawebparts.sourceforge.net
>>>  Supplying the wheel, so you don't have to reinvent it!
>>>
>>> On Wed, October 10, 2007 12:50 pm, Ted Husted wrote:
>>>> I believe this exact example is included with the AjaxParts Taglib,
>>>> which works well with Struts (1 or 2). If anyone is going to be using
>>>> Ajax and JSP tags together, AjaxParts is a great way to go  (and easy
>>>> to learn!).
>>>>
>>>>  * http://www.omnytex.com/articles/apt/
>>>>
>>>> HTH, Ted.
>>>> <http://husted.com/ted/blog>
>>>>
>>>>
>>>> On 10/10/07, aarthy <me...@yahoo.com> wrote:
>>>>>
>>>>> I have a jsp page named "tvshow.jsp", wherein I am populating the
>>>>> characters dropdown as and when the TV Show dropdown value changes ,
>>>>> by calling the javascript in the "onchange()" of the select box.
>>>>> have added a html link, and I want to call the same function from my
>>>>> action class and I need to populate the character dropdown by
>>>>> clicking the html link. I am stuck up with this issue.Character
>>>>> dropdown is not populated with the data from tha action class. Need
>>>>> some help on this please!
>>>>>
>>>>> <%@ page import="java.util.*"%>
>>>>> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
>>>>> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"
>>>>> %> <script language="javascript">  function retrieveURL(url) {
>>>>>     if (window.XMLHttpRequest) { // Non-IE browsers
>>>>>       req = new XMLHttpRequest();
>>>>>       req.onreadystatechange = processStateChange;
>>>>>       try {
>>>>>         req.open("GET", url, true);
>>>>>
>>>>>       } catch (e) {
>>>>>         alert(e);
>>>>>       }
>>>>>       req.send(null);
>>>>>     } else if (window.ActiveXObject) { // IE
>>>>>       req = new ActiveXObject("Microsoft.XMLHTTP");
>>>>>       if (req) {
>>>>>         req.onreadystatechange = processStateChange;
>>>>>         req.open("GET", url, true);
>>>>>         req.send();
>>>>>
>>>>>       }
>>>>>     }
>>>>>   }
>>>>>
>>>>>   function processStateChange() {
>>>>>     if (req.readyState == 4) { // Complete
>>>>>       if (req.status == 200) { // OK response
>>>>>         document.getElementById("characters").innerHTML =
>>>>> req.responseText;
>>>>>             } else {
>>>>>         alert("Problem: " + req.statusText);
>>>>>       }
>>>>>     }
>>>>>   }
>>>>>
>>>>> </script>
>>>>>
>>>>>
>>>>> <form action="ShowCharacters">
>>>>> /jsp/tvshow.jsp Click here
>>>>>
>>>>>                 TV Show:
>>>>>                 <select name="TVShowSelect"
>>>>> onChange="retrieveURL('ShowCharacters.do?tvShow=' + this.value);">
>>>>>                 <option value="Lissie Maguire"> Lissie Maguire
>>> </option>
>>>>>                         <option value="That's so Raven"> That's so
>>>>> Raven </option>
>>>>>                         <option value="Dhoom machale"> Dhoom machale
>>>>> </option>
>>>>>                 </select>
>>>>>
>>>>>                 <br>
>>>>>                 Characters:
>>>>>         </form>
>>>>>
>>>>> ShowCharacters.jsp
>>>>>
>>>>> <%@page import="java.util.ArrayList"%>
>>>>>
>>>>> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
>>>>> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
>>>>> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"
>>>>> %>
>>>>>
>>>>> <select name="TVShowSelect">
>>>>> <%  ArrayList ch =
>>>>> (ArrayList)request.getSession().getAttribute("characters");
>>>>>     String[] s = new String[ch.size()];
>>>>>     ch.toArray(s);
>>>>>     for (int i = 0; i < s.length; i++) {
>>>>>         String name = s[i];
>>>>> %>
>>>>>         <option><%=name%></option>
>>>>> <%  }
>>>>> %>
>>>>> </select>
>>>>>
>>>>> Thanks
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>>
>>>
>>>
>>> ----Notice Regarding Confidentiality----
>>> This email, including any and all attachments, (this "Email") is
>>> intended
>>> only for the party to whom it is addressed and may contain information
>>> that is confidential or privileged.  Sierra Systems Group Inc. and its
>>> affiliates accept no responsibility for any loss or damage suffered by
>>> any
>>> person resulting from any unauthorized use of or reliance upon this
>>> Email.
>>> If you are not the intended recipient, you are hereby notified that any
>>> dissemination, copying or other use of this Email is prohibited.  Please
>>> notify us of the error in communication by return email and destroy all
>>> copies of this Email.  Thank you.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Ajax-Call-from-a-html-link-tf4601558.html#a13142624
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Ajax-Call-from-a-html-link-tf4601558.html#a13142912
Sent from the Struts - User mailing list archive at Nabble.com.


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


RE: Ajax Call from a html link

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
You already have the code, you posted it! :)  If you're having some
*specific* problem, you'll find many helpful people here, but just saying
"my code doesn't work, please help" won't elicit too many (helpful)
replies.

Frank

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
 (2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Wed, October 10, 2007 3:13 pm, aarthy wrote:
>
> Can someone  provide me with an example code.I need to implement ajax in
> my
> struts project, when html link is clicked.
>
>
>
> ghodgins wrote:
>>
>> Not to detract at all from the great JWP project but you can also do
>> this with AjaxTags.
>>
>> The ajax:select tag is described here:
>> http://ajaxtags.sourceforge.net/usage.html
>>
>> I used ajax:select to call an action that returned XML using the handy
>> AjaxXmlBuilder that came with AjaxTags.
>>
>> Cheers,
>> Grant
>>
>>
>> -----Original Message-----
>> From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
>> Sent: Wednesday, October 10, 2007 11:31 AM
>> To: Struts Users Mailing List
>> Cc: Struts Users Mailing List
>> Subject: Re: Ajax Call from a html link
>>
>> Just an FYI, that article is a little outdated... APT's feature set is a
>> bit larger than the article talks about now for one thing, although in
>> glancing over it again, I don't see anything that's not applicable now.
>>
>> Also note that the link to Rick Reumann's article is no longer valid, it
>> is now here:
>> http://www.learntechnology.net/content/ajax/ajax_select_alter.jsp ...
>> Rick also updated that article for APT fairly recently, so it's even
>> better than it was.
>>
>> Lastly, I didn't provide a link to my own book in that article!  D'oh!
>> Here's one: http://apress.com/book/search?searchterm=zammetti&act=search
>> ...
>> chapters 4 and 6 there are what's of interest, although as the note in
>> the article says, they aren't based on the latest version, so although
>> the underlying concepts are pretty much the same, some of the details
>> are slightly different now.
>>
>> --
>> Frank W. Zammetti
>> Founder and Chief Software Architect
>> Omnytex Technologies
>> http://www.omnytex.com
>> AIM/Yahoo: fzammetti
>> MSN: fzammetti@hotmail.com
>> Author of "Practical Ajax Projects With Java Technology"
>>  (2006, Apress, ISBN 1-59059-695-1)
>> and "JavaScript, DOM Scripting and Ajax Projects"
>>  (2007, Apress, ISBN 1-59059-816-4)
>> Java Web Parts - http://javawebparts.sourceforge.net
>>  Supplying the wheel, so you don't have to reinvent it!
>>
>> On Wed, October 10, 2007 12:50 pm, Ted Husted wrote:
>>> I believe this exact example is included with the AjaxParts Taglib,
>>> which works well with Struts (1 or 2). If anyone is going to be using
>>> Ajax and JSP tags together, AjaxParts is a great way to go  (and easy
>>> to learn!).
>>>
>>>  * http://www.omnytex.com/articles/apt/
>>>
>>> HTH, Ted.
>>> <http://husted.com/ted/blog>
>>>
>>>
>>> On 10/10/07, aarthy <me...@yahoo.com> wrote:
>>>>
>>>> I have a jsp page named "tvshow.jsp", wherein I am populating the
>>>> characters dropdown as and when the TV Show dropdown value changes ,
>>>> by calling the javascript in the "onchange()" of the select box.
>>>> have added a html link, and I want to call the same function from my
>>>> action class and I need to populate the character dropdown by
>>>> clicking the html link. I am stuck up with this issue.Character
>>>> dropdown is not populated with the data from tha action class. Need
>>>> some help on this please!
>>>>
>>>> <%@ page import="java.util.*"%>
>>>> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
>>>> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"
>>>> %> <script language="javascript">  function retrieveURL(url) {
>>>>     if (window.XMLHttpRequest) { // Non-IE browsers
>>>>       req = new XMLHttpRequest();
>>>>       req.onreadystatechange = processStateChange;
>>>>       try {
>>>>         req.open("GET", url, true);
>>>>
>>>>       } catch (e) {
>>>>         alert(e);
>>>>       }
>>>>       req.send(null);
>>>>     } else if (window.ActiveXObject) { // IE
>>>>       req = new ActiveXObject("Microsoft.XMLHTTP");
>>>>       if (req) {
>>>>         req.onreadystatechange = processStateChange;
>>>>         req.open("GET", url, true);
>>>>         req.send();
>>>>
>>>>       }
>>>>     }
>>>>   }
>>>>
>>>>   function processStateChange() {
>>>>     if (req.readyState == 4) { // Complete
>>>>       if (req.status == 200) { // OK response
>>>>         document.getElementById("characters").innerHTML =
>>>> req.responseText;
>>>>             } else {
>>>>         alert("Problem: " + req.statusText);
>>>>       }
>>>>     }
>>>>   }
>>>>
>>>> </script>
>>>>
>>>>
>>>> <form action="ShowCharacters">
>>>> /jsp/tvshow.jsp Click here
>>>>
>>>>                 TV Show:
>>>>                 <select name="TVShowSelect"
>>>> onChange="retrieveURL('ShowCharacters.do?tvShow=' + this.value);">
>>>>                 <option value="Lissie Maguire"> Lissie Maguire
>> </option>
>>>>                         <option value="That's so Raven"> That's so
>>>> Raven </option>
>>>>                         <option value="Dhoom machale"> Dhoom machale
>>>> </option>
>>>>                 </select>
>>>>
>>>>                 <br>
>>>>                 Characters:
>>>>         </form>
>>>>
>>>> ShowCharacters.jsp
>>>>
>>>> <%@page import="java.util.ArrayList"%>
>>>>
>>>> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
>>>> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
>>>> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"
>>>> %>
>>>>
>>>> <select name="TVShowSelect">
>>>> <%  ArrayList ch =
>>>> (ArrayList)request.getSession().getAttribute("characters");
>>>>     String[] s = new String[ch.size()];
>>>>     ch.toArray(s);
>>>>     for (int i = 0; i < s.length; i++) {
>>>>         String name = s[i];
>>>> %>
>>>>         <option><%=name%></option>
>>>> <%  }
>>>> %>
>>>> </select>
>>>>
>>>> Thanks
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>
>> ----Notice Regarding Confidentiality----
>> This email, including any and all attachments, (this "Email") is
>> intended
>> only for the party to whom it is addressed and may contain information
>> that is confidential or privileged.  Sierra Systems Group Inc. and its
>> affiliates accept no responsibility for any loss or damage suffered by
>> any
>> person resulting from any unauthorized use of or reliance upon this
>> Email.
>> If you are not the intended recipient, you are hereby notified that any
>> dissemination, copying or other use of this Email is prohibited.  Please
>> notify us of the error in communication by return email and destroy all
>> copies of this Email.  Thank you.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Ajax-Call-from-a-html-link-tf4601558.html#a13142624
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: Ajax Call from a html link

Posted by aarthy <me...@yahoo.com>.
Can someone  provide me with an example code.I need to implement ajax in my
struts project, when html link is clicked.



ghodgins wrote:
> 
> Not to detract at all from the great JWP project but you can also do
> this with AjaxTags.
> 
> The ajax:select tag is described here:
> http://ajaxtags.sourceforge.net/usage.html
> 
> I used ajax:select to call an action that returned XML using the handy
> AjaxXmlBuilder that came with AjaxTags.
> 
> Cheers,
> Grant
> 
> 
> -----Original Message-----
> From: Frank W. Zammetti [mailto:fzlists@omnytex.com] 
> Sent: Wednesday, October 10, 2007 11:31 AM
> To: Struts Users Mailing List
> Cc: Struts Users Mailing List
> Subject: Re: Ajax Call from a html link
> 
> Just an FYI, that article is a little outdated... APT's feature set is a
> bit larger than the article talks about now for one thing, although in
> glancing over it again, I don't see anything that's not applicable now.
> 
> Also note that the link to Rick Reumann's article is no longer valid, it
> is now here:
> http://www.learntechnology.net/content/ajax/ajax_select_alter.jsp ...
> Rick also updated that article for APT fairly recently, so it's even
> better than it was.
> 
> Lastly, I didn't provide a link to my own book in that article!  D'oh! 
> Here's one: http://apress.com/book/search?searchterm=zammetti&act=search
> ...
> chapters 4 and 6 there are what's of interest, although as the note in
> the article says, they aren't based on the latest version, so although
> the underlying concepts are pretty much the same, some of the details
> are slightly different now.
> 
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM/Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> Author of "Practical Ajax Projects With Java Technology"
>  (2006, Apress, ISBN 1-59059-695-1)
> and "JavaScript, DOM Scripting and Ajax Projects"
>  (2007, Apress, ISBN 1-59059-816-4)
> Java Web Parts - http://javawebparts.sourceforge.net
>  Supplying the wheel, so you don't have to reinvent it!
> 
> On Wed, October 10, 2007 12:50 pm, Ted Husted wrote:
>> I believe this exact example is included with the AjaxParts Taglib, 
>> which works well with Struts (1 or 2). If anyone is going to be using 
>> Ajax and JSP tags together, AjaxParts is a great way to go  (and easy 
>> to learn!).
>>
>>  * http://www.omnytex.com/articles/apt/
>>
>> HTH, Ted.
>> <http://husted.com/ted/blog>
>>
>>
>> On 10/10/07, aarthy <me...@yahoo.com> wrote:
>>>
>>> I have a jsp page named "tvshow.jsp", wherein I am populating the 
>>> characters dropdown as and when the TV Show dropdown value changes , 
>>> by calling the javascript in the "onchange()" of the select box.
>>> have added a html link, and I want to call the same function from my 
>>> action class and I need to populate the character dropdown by 
>>> clicking the html link. I am stuck up with this issue.Character 
>>> dropdown is not populated with the data from tha action class. Need 
>>> some help on this please!
>>>
>>> <%@ page import="java.util.*"%>
>>> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> 
>>> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" 
>>> %> <script language="javascript">  function retrieveURL(url) {
>>>     if (window.XMLHttpRequest) { // Non-IE browsers
>>>       req = new XMLHttpRequest();
>>>       req.onreadystatechange = processStateChange;
>>>       try {
>>>         req.open("GET", url, true);
>>>
>>>       } catch (e) {
>>>         alert(e);
>>>       }
>>>       req.send(null);
>>>     } else if (window.ActiveXObject) { // IE
>>>       req = new ActiveXObject("Microsoft.XMLHTTP");
>>>       if (req) {
>>>         req.onreadystatechange = processStateChange;
>>>         req.open("GET", url, true);
>>>         req.send();
>>>
>>>       }
>>>     }
>>>   }
>>>
>>>   function processStateChange() {
>>>     if (req.readyState == 4) { // Complete
>>>       if (req.status == 200) { // OK response
>>>         document.getElementById("characters").innerHTML = 
>>> req.responseText;
>>>             } else {
>>>         alert("Problem: " + req.statusText);
>>>       }
>>>     }
>>>   }
>>>
>>> </script>
>>>
>>>
>>> <form action="ShowCharacters">
>>> /jsp/tvshow.jsp Click here
>>>
>>>                 TV Show:
>>>                 <select name="TVShowSelect"
>>> onChange="retrieveURL('ShowCharacters.do?tvShow=' + this.value);">
>>>                 <option value="Lissie Maguire"> Lissie Maguire
> </option>
>>>                         <option value="That's so Raven"> That's so 
>>> Raven </option>
>>>                         <option value="Dhoom machale"> Dhoom machale 
>>> </option>
>>>                 </select>
>>>
>>>                 <br>
>>>                 Characters:
>>>         </form>
>>>
>>> ShowCharacters.jsp
>>>
>>> <%@page import="java.util.ArrayList"%>
>>>
>>> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> 
>>> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> 
>>> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" 
>>> %>
>>>
>>> <select name="TVShowSelect">
>>> <%  ArrayList ch =
>>> (ArrayList)request.getSession().getAttribute("characters");
>>>     String[] s = new String[ch.size()];
>>>     ch.toArray(s);
>>>     for (int i = 0; i < s.length; i++) {
>>>         String name = s[i];
>>> %>
>>>         <option><%=name%></option>
>>> <%  }
>>> %>
>>> </select>
>>>
>>> Thanks
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 
> 
> ----Notice Regarding Confidentiality----
> This email, including any and all attachments, (this "Email") is intended
> only for the party to whom it is addressed and may contain information
> that is confidential or privileged.  Sierra Systems Group Inc. and its
> affiliates accept no responsibility for any loss or damage suffered by any
> person resulting from any unauthorized use of or reliance upon this Email. 
> If you are not the intended recipient, you are hereby notified that any
> dissemination, copying or other use of this Email is prohibited.  Please
> notify us of the error in communication by return email and destroy all
> copies of this Email.  Thank you.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Ajax-Call-from-a-html-link-tf4601558.html#a13142624
Sent from the Struts - User mailing list archive at Nabble.com.


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


RE: Ajax Call from a html link

Posted by "Hodgins, Grant" <Gr...@SierraSystems.com>.
Not to detract at all from the great JWP project but you can also do
this with AjaxTags.

The ajax:select tag is described here:
http://ajaxtags.sourceforge.net/usage.html

I used ajax:select to call an action that returned XML using the handy
AjaxXmlBuilder that came with AjaxTags.

Cheers,
Grant


-----Original Message-----
From: Frank W. Zammetti [mailto:fzlists@omnytex.com] 
Sent: Wednesday, October 10, 2007 11:31 AM
To: Struts Users Mailing List
Cc: Struts Users Mailing List
Subject: Re: Ajax Call from a html link

Just an FYI, that article is a little outdated... APT's feature set is a
bit larger than the article talks about now for one thing, although in
glancing over it again, I don't see anything that's not applicable now.

Also note that the link to Rick Reumann's article is no longer valid, it
is now here:
http://www.learntechnology.net/content/ajax/ajax_select_alter.jsp ...
Rick also updated that article for APT fairly recently, so it's even
better than it was.

Lastly, I didn't provide a link to my own book in that article!  D'oh! 
Here's one: http://apress.com/book/search?searchterm=zammetti&act=search
...
chapters 4 and 6 there are what's of interest, although as the note in
the article says, they aren't based on the latest version, so although
the underlying concepts are pretty much the same, some of the details
are slightly different now.

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
 (2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Wed, October 10, 2007 12:50 pm, Ted Husted wrote:
> I believe this exact example is included with the AjaxParts Taglib, 
> which works well with Struts (1 or 2). If anyone is going to be using 
> Ajax and JSP tags together, AjaxParts is a great way to go  (and easy 
> to learn!).
>
>  * http://www.omnytex.com/articles/apt/
>
> HTH, Ted.
> <http://husted.com/ted/blog>
>
>
> On 10/10/07, aarthy <me...@yahoo.com> wrote:
>>
>> I have a jsp page named "tvshow.jsp", wherein I am populating the 
>> characters dropdown as and when the TV Show dropdown value changes , 
>> by calling the javascript in the "onchange()" of the select box.
>> have added a html link, and I want to call the same function from my 
>> action class and I need to populate the character dropdown by 
>> clicking the html link. I am stuck up with this issue.Character 
>> dropdown is not populated with the data from tha action class. Need 
>> some help on this please!
>>
>> <%@ page import="java.util.*"%>
>> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> 
>> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" 
>> %> <script language="javascript">  function retrieveURL(url) {
>>     if (window.XMLHttpRequest) { // Non-IE browsers
>>       req = new XMLHttpRequest();
>>       req.onreadystatechange = processStateChange;
>>       try {
>>         req.open("GET", url, true);
>>
>>       } catch (e) {
>>         alert(e);
>>       }
>>       req.send(null);
>>     } else if (window.ActiveXObject) { // IE
>>       req = new ActiveXObject("Microsoft.XMLHTTP");
>>       if (req) {
>>         req.onreadystatechange = processStateChange;
>>         req.open("GET", url, true);
>>         req.send();
>>
>>       }
>>     }
>>   }
>>
>>   function processStateChange() {
>>     if (req.readyState == 4) { // Complete
>>       if (req.status == 200) { // OK response
>>         document.getElementById("characters").innerHTML = 
>> req.responseText;
>>             } else {
>>         alert("Problem: " + req.statusText);
>>       }
>>     }
>>   }
>>
>> </script>
>>
>>
>> <form action="ShowCharacters">
>> /jsp/tvshow.jsp Click here
>>
>>                 TV Show:
>>                 <select name="TVShowSelect"
>> onChange="retrieveURL('ShowCharacters.do?tvShow=' + this.value);">
>>                 <option value="Lissie Maguire"> Lissie Maguire
</option>
>>                         <option value="That's so Raven"> That's so 
>> Raven </option>
>>                         <option value="Dhoom machale"> Dhoom machale 
>> </option>
>>                 </select>
>>
>>                 <br>
>>                 Characters:
>>         </form>
>>
>> ShowCharacters.jsp
>>
>> <%@page import="java.util.ArrayList"%>
>>
>> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> 
>> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> 
>> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" 
>> %>
>>
>> <select name="TVShowSelect">
>> <%  ArrayList ch =
>> (ArrayList)request.getSession().getAttribute("characters");
>>     String[] s = new String[ch.size()];
>>     ch.toArray(s);
>>     for (int i = 0; i < s.length; i++) {
>>         String name = s[i];
>> %>
>>         <option><%=name%></option>
>> <%  }
>> %>
>> </select>
>>
>> Thanks
>
> ---------------------------------------------------------------------
> 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



----Notice Regarding Confidentiality----
This email, including any and all attachments, (this "Email") is intended only for the party to whom it is addressed and may contain information that is confidential or privileged.  Sierra Systems Group Inc. and its affiliates accept no responsibility for any loss or damage suffered by any person resulting from any unauthorized use of or reliance upon this Email.  If you are not the intended recipient, you are hereby notified that any dissemination, copying or other use of this Email is prohibited.  Please notify us of the error in communication by return email and destroy all copies of this Email.  Thank you.

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


Re: Ajax Call from a html link

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Just an FYI, that article is a little outdated... APT's feature set is a
bit larger than the article talks about now for one thing, although in
glancing over it again, I don't see anything that's not applicable now.

Also note that the link to Rick Reumann's article is no longer valid, it
is now here:
http://www.learntechnology.net/content/ajax/ajax_select_alter.jsp ... Rick
also updated that article for APT fairly recently, so it's even better
than it was.

Lastly, I didn't provide a link to my own book in that article!  D'oh! 
Here's one: http://apress.com/book/search?searchterm=zammetti&act=search
...
chapters 4 and 6 there are what's of interest, although as the note in the
article says, they aren't based on the latest version, so although the
underlying concepts are pretty much the same, some of the details are
slightly different now.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
 (2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Wed, October 10, 2007 12:50 pm, Ted Husted wrote:
> I believe this exact example is included with the AjaxParts Taglib,
> which works well with Struts (1 or 2). If anyone is going to be using
> Ajax and JSP tags together, AjaxParts is a great way to go  (and easy
> to learn!).
>
>  * http://www.omnytex.com/articles/apt/
>
> HTH, Ted.
> <http://husted.com/ted/blog>
>
>
> On 10/10/07, aarthy <me...@yahoo.com> wrote:
>>
>> I have a jsp page named "tvshow.jsp", wherein I am populating the
>> characters
>> dropdown as and when the TV Show dropdown value changes , by calling the
>> javascript in the "onchange()" of the select box.
>> have added a html link, and I want to call the same function from my
>> action
>> class and I need to populate the character dropdown by clicking the html
>> link. I am stuck up with this issue.Character dropdown is not populated
>> with
>> the data from tha action class. Need some help on this please!
>>
>> <%@ page import="java.util.*"%>
>> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
>> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
>> <script language="javascript">
>>  function retrieveURL(url) {
>>     if (window.XMLHttpRequest) { // Non-IE browsers
>>       req = new XMLHttpRequest();
>>       req.onreadystatechange = processStateChange;
>>       try {
>>         req.open("GET", url, true);
>>
>>       } catch (e) {
>>         alert(e);
>>       }
>>       req.send(null);
>>     } else if (window.ActiveXObject) { // IE
>>       req = new ActiveXObject("Microsoft.XMLHTTP");
>>       if (req) {
>>         req.onreadystatechange = processStateChange;
>>         req.open("GET", url, true);
>>         req.send();
>>
>>       }
>>     }
>>   }
>>
>>   function processStateChange() {
>>     if (req.readyState == 4) { // Complete
>>       if (req.status == 200) { // OK response
>>         document.getElementById("characters").innerHTML =
>> req.responseText;
>>             } else {
>>         alert("Problem: " + req.statusText);
>>       }
>>     }
>>   }
>>
>> </script>
>>
>>
>> <form action="ShowCharacters">
>> /jsp/tvshow.jsp Click here
>>
>>                 TV Show:
>>                 <select name="TVShowSelect"
>> onChange="retrieveURL('ShowCharacters.do?tvShow=' + this.value);">
>>                 <option value="Lissie Maguire"> Lissie Maguire </option>
>>                         <option value="That's so Raven"> That's so Raven
>> </option>
>>                         <option value="Dhoom machale"> Dhoom machale
>> </option>
>>                 </select>
>>
>>                 <br>
>>                 Characters:
>>         </form>
>>
>> ShowCharacters.jsp
>>
>> <%@page import="java.util.ArrayList"%>
>>
>> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
>> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
>> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
>>
>> <select name="TVShowSelect">
>> <%  ArrayList ch =
>> (ArrayList)request.getSession().getAttribute("characters");
>>     String[] s = new String[ch.size()];
>>     ch.toArray(s);
>>     for (int i = 0; i < s.length; i++) {
>>         String name = s[i];
>> %>
>>         <option><%=name%></option>
>> <%  }
>> %>
>> </select>
>>
>> Thanks
>
> ---------------------------------------------------------------------
> 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: Ajax Call from a html link

Posted by Ted Husted <hu...@apache.org>.
I believe this exact example is included with the AjaxParts Taglib,
which works well with Struts (1 or 2). If anyone is going to be using
Ajax and JSP tags together, AjaxParts is a great way to go  (and easy
to learn!).

 * http://www.omnytex.com/articles/apt/

HTH, Ted.
<http://husted.com/ted/blog>


On 10/10/07, aarthy <me...@yahoo.com> wrote:
>
> I have a jsp page named "tvshow.jsp", wherein I am populating the characters
> dropdown as and when the TV Show dropdown value changes , by calling the
> javascript in the "onchange()" of the select box.
> have added a html link, and I want to call the same function from my action
> class and I need to populate the character dropdown by clicking the html
> link. I am stuck up with this issue.Character dropdown is not populated with
> the data from tha action class. Need some help on this please!
>
> <%@ page import="java.util.*"%>
> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
> <script language="javascript">
>  function retrieveURL(url) {
>     if (window.XMLHttpRequest) { // Non-IE browsers
>       req = new XMLHttpRequest();
>       req.onreadystatechange = processStateChange;
>       try {
>         req.open("GET", url, true);
>
>       } catch (e) {
>         alert(e);
>       }
>       req.send(null);
>     } else if (window.ActiveXObject) { // IE
>       req = new ActiveXObject("Microsoft.XMLHTTP");
>       if (req) {
>         req.onreadystatechange = processStateChange;
>         req.open("GET", url, true);
>         req.send();
>
>       }
>     }
>   }
>
>   function processStateChange() {
>     if (req.readyState == 4) { // Complete
>       if (req.status == 200) { // OK response
>         document.getElementById("characters").innerHTML = req.responseText;
>             } else {
>         alert("Problem: " + req.statusText);
>       }
>     }
>   }
>
> </script>
>
>
> <form action="ShowCharacters">
> /jsp/tvshow.jsp Click here
>
>                 TV Show:
>                 <select name="TVShowSelect"
> onChange="retrieveURL('ShowCharacters.do?tvShow=' + this.value);">
>                 <option value="Lissie Maguire"> Lissie Maguire </option>
>                         <option value="That's so Raven"> That's so Raven </option>
>                         <option value="Dhoom machale"> Dhoom machale </option>
>                 </select>
>
>                 <br>
>                 Characters:
>         </form>
>
> ShowCharacters.jsp
>
> <%@page import="java.util.ArrayList"%>
>
> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
>
> <select name="TVShowSelect">
> <%  ArrayList ch =
> (ArrayList)request.getSession().getAttribute("characters");
>     String[] s = new String[ch.size()];
>     ch.toArray(s);
>     for (int i = 0; i < s.length; i++) {
>         String name = s[i];
> %>
>         <option><%=name%></option>
> <%  }
> %>
> </select>
>
> Thanks

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