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 <[EMAIL PROTECTED]> 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
>
> <[EMAIL PROTECTED] 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to