Hi all
I've got a piece of code for populating textfields that looks like this:
<blockquote>code:
<pre name="code" class="java">
function do(){
<%
String action = request.getParameter("action");
if(action != null && action == "A"){
MyBean theBean = MyJavaClass.myGetByMethod(request.getParameter("select_field"));
String text_field1 = theBean.getField1();
String text_field2 = theBean.getField2();
String text_field3 = theBean.getField3();
}
%>
document.forms[0].text_field1.value = '<%=text_field1%>';
document.forms[0].text_field2.value = '<%=text_field2%>';
document.forms[0].text_field3.value = '<%=text_field3%>';
}
function set_action(action_value){
document.forms[0].action.value = action_value;
document.forms[0].submit();
}
</pre>
</blockquote>
The do() function is called inside the body tag, through onLoad.
The set_action function is called inside the select field tag, through onChange, passing "A" as parameter.
I've also got a hidden input named "action".
MyJavaClass.myGetByMethod(String select_option) connects to a database and gets info based on the String that is passed as a parameter.
This code works fine for me. My question is: am I using jsp in a improper manner? Is there a better way to do this without using other technologies (Ajax for example)?
Thanks in advance
[ July 11, 2008: Message edited by: Carlos Herrera ]
I've got a piece of code for populating textfields that looks like this:
<blockquote>code:
<pre name="code" class="java">
function do(){
<%
String action = request.getParameter("action");
if(action != null && action == "A"){
MyBean theBean = MyJavaClass.myGetByMethod(request.getParameter("select_field"));
String text_field1 = theBean.getField1();
String text_field2 = theBean.getField2();
String text_field3 = theBean.getField3();
}
%>
document.forms[0].text_field1.value = '<%=text_field1%>';
document.forms[0].text_field2.value = '<%=text_field2%>';
document.forms[0].text_field3.value = '<%=text_field3%>';
}
function set_action(action_value){
document.forms[0].action.value = action_value;
document.forms[0].submit();
}
</pre>
</blockquote>
The do() function is called inside the body tag, through onLoad.
The set_action function is called inside the select field tag, through onChange, passing "A" as parameter.
I've also got a hidden input named "action".
MyJavaClass.myGetByMethod(String select_option) connects to a database and gets info based on the String that is passed as a parameter.
This code works fine for me. My question is: am I using jsp in a improper manner? Is there a better way to do this without using other technologies (Ajax for example)?
Thanks in advance
[ July 11, 2008: Message edited by: Carlos Herrera ]