I was thinking the benefit would be a quicker, smoother refresh since
only one small piece of the page would be reloaded. Is that not correct?
I don't know that much about frames.
Erik
Bill Siggelkow wrote:
What is the benefit of the hidden frame? I guess that you can submit
an entire form ... however, most of the time I only need to drop an ID
as a request parameter. I dynamically populate select lists like this:
Use an onchange or onclick JavaScript listener to call a JavaScript
function that submits the form to a Struts Action. In the Action,
perform the necessary business logic to construct a new collection for
the select options, then forward control back to the original JSP
page. Example 3-11 shows a JSP page that submits the form to an Action
when the user clicks a radio button. The value of the radio button is
passed to the Action as a request parameter.
Example 3-11. Submitting a form using JavaScript
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html>
<head>
<title>Struts – JavaScript Example</title>
<script language="JavaScript">
function getOptions(control) {
form = control.form;
form.action = "SetOptions.do?someProp=";
form.action += control.value;
form.submit();
}
</script>
</head>
<body>
<html:form action="ProcessMyForm">
<html:radio property="someProp1" value="val1"
onclick="getOptions(this);"/> Value 1<br/>
<html:radio property="language" value="val2"
onclick="getOptions(this);"/> Value 2<br/>
SomeProp2:
<html:select property="someProp2">
<html:optionsCollection property="prop2Values"/>
</html:select>
</p>
<html:submit/>
</html:form>
</body>
</html>
Bill Siggelkow
[EMAIL PROTECTED] wrote:
Don't have any code handy, but it's quite straightforward:
- create a hidden frame
- on the select's onchange() do a submit on a form in the hidden
frame to
an action that gets the information from the database, passing in the
relevant parameter
- have the action forward to a jsp which is just a javascript call to
update the other select box - probably easiest just to delete the select
box options, iterate through the through the collection returned and for
each one create a javascript call on the other frame that adds an option
for it
let me know if you have any qu's.
cheers,
David
---------------------------------------------------------------------
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]