Problem if i use ajax in struts
hi,
i am working on struts, now i got one problem if i use ajax in jsp.
In my jsp page i have two dropdown lists, according to the first dropdown value second dropdown result will getting from the database by calling an action class.
but my requirement is for getting the second dropdown result page should not be refresh for this i am using ajax.
in ajax how can we call one action class what should we return in actionmapping.
If any one already written some code for this please send it to me.
please can anyone help on this its very urgent for me.
Hi
First of all you have to write on fnRetrieveURL which will be responsible for getting the connection and XML communication.
function fnRetrieveURL(strURL, strFnProcessStateChange)
if(window.XMLHttpRequest)
varXMLrequest = new XMLHttpRequest();
varXMLrequest.onreadystatechange = eval(strFnProcessStateChange);
try
varXMLrequest.open("POST",strURL,true);
catch(Exception)
alert("Problem in Getting data ");
varXMLrequest.send(null);
else if(window.ActiveXObject)
varXMLrequest = new ActiveXObject("Microsoft.XMLHTTP");
if(varXMLrequest)
varXMLrequest.onreadystatechange =eval(strFnProcessStateChange);
varXMLrequest.open("POST",strURL,true);
varXMLrequest.send();
}This method will be called in user written method in which request will be submitted to action class.
function fnGetAreaForRegion()
var iRegion = document.getElementById("region").value;
var strURL = "../getAreaForRegion.do"
strURL = strURL+"?methodName="+"getAreaForRegion";
strURL = strURL+"&controlName="+"area";
strURL = strURL+"&iRegion="+iRegion ;
fnRetrieveURL(strURL,"fnOnReturnFromRegion");
}Then there will be one on Return method i.e the method which will be called when the response will come back to JSP from fnGetAreaforRegion.
function fnOnReturnFromRegion()
if (varXMLrequest.readyState == 4)
if(varXMLrequest.status == 200)
var strSubClassValue = varXMLrequest.responseText;
if(strSubClassValue != '')
var strArray = strSubClassValue.split(",");
var iLength = strArray.length;
var strName = new Array();
var strID = new Array();
var j=0;
for(var i =0 ; i< iLength;i=i+2)
strName[j] = strArray;
j++;
var k=0;
for(var i =1 ; i< iLength;i=i+2)
strID[k] = strArray[i];
k++;
var iNewLength = strID.length;
var optnSelect = document.createElement("OPTION");
optnSelect.text = 'Select';
optnSelect.value = '';
document.getElementById("area").options.add(optnSelect);
for(var i =0 ; i< iNewLength;i++)
var optn = document.createElement("OPTION");
optn.text = strName[i];
optn.value = parseInt(strID[i]);
document.getElementById("area").options.add(optn);
Rest modification in struts-config, you can do by urself. and also you have to write one action class which will take care of parameters and all business logic.
Above code you can reuse by bit modification. Action class you have to write by your own.
let me know if you still face any issues
Similar Messages
-
Using ajax with struts 1.2.9
Hello Experts ,
First of all I am sorry if I have posted question in a wrong forum but I have tried posting my problem in struts forum also but didn't get reply & I am pretty new to struts.
I am trying to use ajax in struts 1.2.9.I have used 1 dependent combo.When I am changing value in 1 combo it will call an action class which will fetch data for 2nd combo .My problem is ,action class "success" has to be forwarded to some particular jsp.But I want to refresh only a part of page not the whole page.How to refresh just a part of page?? Any idea or any link which can help me.Any help in this will be highly appreciated.Many many Thanx in advance.Hello Shasi,
Lets take the sample code for one combo box (College) , one change of which I want to display the information of that college in the textboxes below it.So on change of college combo I am calling the action class which is retrieving info of college.My problem is now how to send this data to jsp & what should be the success & failure forward for my action class.
In my JSP I have written something like this....
createXMLHttpRequest();
queryString2 ="retrieve_college_info.do?";
queryString2 = queryString2 + "selcollege="+document.forms[0].college_name.options[document.forms[0].college_name.selectedIndex].value;
xmlHttp.open("GET", queryString2, true);
xmlHttp.onreadystatechange = handleCollegeRetrieve;
xmlHttp.send(null);My action class code goes like this
package ibm.tgmc_nextyear.actionclass;
import ibm.tgmc_nextyear.businesslogic.*;
import ibm.tgmc_nextyear.formbean.*;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import java.sql.*;
import java.util.ArrayList;
import org.apache.struts.util.LabelValueBean;
public class CollegeRetrieveInfoAjaxAction extends org.apache.struts.action.Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String optionSelected = request.getParameter("selcollege");
String responseText="";
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
TeamDetailsForm team_frm = null;
try {
conn = getDataSource(request).getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery("select name , address , city , pincode , ph_no , hod_name , principal_name , alt_no , website from user.college_table where college_id=" + optionSelected);
*//what after this ???*
} finally {
if (rs != null) {
rs.close();
if (stmt != null) {
stmt.close();
if (conn != null) {
conn.close();
*//what should be the value os success forward*
return(mapping.findForward("success"));
} -
Uploading a file to server using ajax and struts
My problem is i wrote a program to upload a file to the server using Ajax.
Here iam used Struts and Ajax.
The problem is when iam uploaded a file from my PC the file is uploading to the server in the upload folder located in the server my system.
Iam using Tomcat server 5.0
But when iam trying to access it through other system it is not doing so
Giving an internal server error i,e 500.
Iam putting the necessary documents for ur reference.
Plz help me soon .
My exact requirement is i have to upload a file to the upload folder located in the server.
And i have to get the path of that file and display the file path exactly below the browse button from where iam uploaded a file.
That should be done without page refresh and submit thats y iam used Ajax
Any help would greatly appreciated
Thanks and Regards
Meerasaaheb.
The action class is FilePathAction
package actions;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
public class FilePathAction extends Action{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
String contextPath1 = "";
String uploadDirName="";
String filepath="";
System.out.println(contextPath1 );
String inputfile = request.getParameter("filepath");
uploadDirName = getServlet().getServletContext().getRealPath("/upload");
File f=new File(inputfile);
FileInputStream fis=null;
FileOutputStream fo=null;
File f1=new File(uploadDirName+"/"+f.getName());
fis=new FileInputStream(f);
fo=new FileOutputStream(f1);
try
byte buf[] = new byte[1024*8]; /* declare a 8kB buffer */
int len = -1;
while((len = fis.read(buf)) != -1)
fo.write(buf, 0, len);
catch(Exception e)
e.printStackTrace();
filepath=f1.getAbsolutePath();
request.setAttribute("filepath", filepath);
return mapping.findForward("filepath");
the input jsp is
filename.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
alertflag = false;
var xmlHttp;
function startRequest()
if(alertflag)
alert("meera");
xmlHttp=createXmlHttpRequest();
var inputfile=document.getElementById("filepath").value;
xmlHttp.open("POST","FilePathAction.do",true);
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.send("filepath="+inputfile);
function createXmlHttpRequest()
//For IE
if(window.ActiveXObject)
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
//otherthan IE
else if(window.XMLHttpRequest)
xmlHttp=new XMLHttpRequest();
return xmlHttp;
//Next is the function that sets up the communication with the server.
//This function also registers the callback handler, which is handleStateChange. Next is the code for the handler.
function handleStateChange()
var message=" ";
if(xmlHttp.readyState==4)
if(alertflag)
alert(xmlHttp.status);
if(xmlHttp.status==200)
if(alertflag)
alert("here");
document.getElementById("div1").style.visibility = "visible";
var results=xmlHttp.responseText;
document.getElementById('div1').innerHTML = results;
else
alert("Error loading page"+xmlHttp.status+":"+xmlHttp.statusText);
</script></head><body><form name="thumbs" enctype="multipart/form-data" method="post" action="">
<input type="file" name="filepath" id="filepath" onchange="startRequest();"/>
</form>
<div id="div1" style="visibility:hidden;">
</div></body></html>
The ajax response is catching in a dummy.jsp
<%=(String)request.getAttribute("filepath")%>
corresponding action mapping
<action path="/FilePathAction" type="actions.FilePathAction">
<forward name="filepath" path="/dummy.jsp"/>
</action>
So plz help me to upload a file to the server from any PC.
Iam searched alot but didnt get any solution.Plz help me soon if it possible so
Iam in great need.
I have worked alot but not worked out.
Any help greatly appreciated -
I want to use Ajax in my struts framework.Can anyone please suggest me how
to do this
Thankshttp://www.google.com/search?hl=en&q=ajax+struts&btnG=Google+Search
-
How to upload a file to the server using ajax and struts
With the following code iam able to upload a file ato the server.
But my problem is It is working fine if iam doing in my system nd when iam trying to
access theis application from someother system in our office which are connected through lan
iam getting an error called 500 i,e internal server error.
Why it is so???????
Plz help me????????
It is required in my project.
I want the code to access from every system.
My exact requirement is i have to upload a file to the server and retrive its path and show it in the same page from which we
have uploaded a file.
Here the file has to be uploaded to the upload folder which is present in the server.Iam using Tomcat server.
Any help highly appreciated.
Thanks in Advance
This is my input jsp
filename.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
alertflag = true;
var xmlHttp;
function startRequest(file1)
if(alertflag)
alert("file1");
alert(file1);
xmlHttp=createXmlHttpRequest();
var video=document.getElementById("filepath").value;
xmlHttp.open("POST","FilePathAction.do",true);
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.setRequestHeader('Content-Type', application/x-www-form-urlencoded');
xmlHttp.send("filepath="+file1);
function createXmlHttpRequest()
//For IE
if(window.ActiveXObject)
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
//otherthan IE
else if(window.XMLHttpRequest)
xmlHttp=new XMLHttpRequest();
return xmlHttp;
//Next is the function that sets up the communication with the server.
//This function also registers the callback handler, which is handleStateChange. Next is the code for the handler.
function handleStateChange()
var message=" ";
if(xmlHttp.readyState==4)
if(alertflag)
alert(xmlHttp.status);
if(xmlHttp.status==200)
if(alertflag)
alert("here");
document.getElementById("div1").style.visibility = "visible";
var results=xmlHttp.responseText;
document.getElementById('div1').innerHTML = results;
else
alert("Error loading page"+xmlHttp.status+":"+xmlHttp.statusText);
</script></head><body><form >
<input type="file" name="filepath" id="filepath" onchange="startRequest(this.value);"/>
</form>
<div id="div1" style="visibility:hidden;">
</div></body></html>
The corresponding action class is FIlePathAction
package actions;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
public class FilePathAction extends Action{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
String contextPath1 = "";
String uploadDirName="";
String filepath="";
System.out.println(contextPath1 );
String inputfile = request.getParameter("filepath");
uploadDirName = getServlet().getServletContext().getRealPath("/upload");
File f=new File(inputfile);
FileInputStream fis=null;
FileOutputStream fo=null;
File f1=new File(uploadDirName+"/"+f.getName());
fis=new FileInputStream(f);
fo=new FileOutputStream(f1);
try
byte buf[] = new byte[1024*8]; /* declare a 8kB buffer */
int len = -1;
while((len = fis.read(buf)) != -1)
fo.write(buf, 0, len);
catch(Exception e)
e.printStackTrace();
filepath=f1.getAbsolutePath();
request.setAttribute("filepath", filepath);
return mapping.findForward("filepath");
Action-mappings in struts-config.xml
<action path="/FilePathAction"
type="actions.FilePathAction">
<forward name="filepath" path="/dummy.jsp"></forward>
</action>
and the dummy.jsp code is
<%=request.getAttribute("filepath")%>MESSAGE FROM THE FORUMS ADMINISTRATORS and COMMUNITY
This thread will be deleted within 24 business hours. You have posted an off-topic question in an area clearly designated for discussions
about Distributed Real-time Java. Community members looking to help you with your question won't be able to find it in this category.
Please use the "Search Forums" element on the left panel to locate a forum based on your topic. A more appropriate forum for this post
could be one of:
Enterprise Technologies http://forums.sun.com/category.jspa?categoryID=19
David Holmes -
Problems using messageLovInput within struts:datascope
hi all
its been a long time since i have been posting with a uix related problem. so its good to be back.
the problem is that the messageLovInput component ceases to function when used within the struts:datascope , but everthing works fine when used with the usual datascope tag.( that is minus the struts).
i need to use the struts:datascope because i need to display action errors inline.
i am using the uix version that ships with jdevelpoper 9.0.3.1035
does anyone know whats causing this problem, is this a problem that was subsequently fixed with 10g ?
any help in this regard is greatly appreciated.. and my thanks in advance.
regards
indrikain 10G we now have support for dragging your data onto your uix page as a messageLovInput. the system will wire everything up for you.
-
Problem pulling HTML region using AJAX
Hi,
I am using Ajax with Oracle apex, it pulls the report region ok, but when i try to pull the html region, it doesn't. I tried several different ways and in firefox, it does pull the html region but not also pulls the header and footer. On IE, it gives a javascript error.
Is there any way to pull the HTML region from a page using AJAX on IE. I am using the htmldb_get.js's functions for ajax.see
http://apex.oracle.com/pls/otn/f?p=11933:48
working perfectly with latest version of apex on ie, ffox and opera. -
Problems refreshing page with AJAX
Hello,
I have never used AJAX but today I decided to try it to improve my current implementation of a "processing" page that I use to display a waiting message and to check every 5 seconds if a response is available. If it is, the user is redirected to a "processing done" page.
My previous implementation used the refresh tag provided by HTML in the "processing" page:
<meta HTTP-EQUIV="Refresh" CONTENT="5; URL=<%=request.getContextPath()%>/main/CheckForResponse.do"/>
Every 5 seconds a struts action is executed and the action itself will forward to the "processing done" page when a response is available.
This solution works, however I don't like the refresh page effect, so I was trying to use AJAX instead. Now I put in the "processing" page the following script:
function checkForResponse()
var xmlHttp;
try
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
catch (e)
// Internet Explorer
try
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
catch (e)
try
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
catch (e)
alert("Your browser does not support AJAX!");
return false;
xmlHttp.open("GET","<%=request.getContextPath()%>/main/CheckForResponse.do",true);
xmlHttp.send(null);
}and I have the following html body tag.
<body onLoad="setInterval('checkForResponse()',5000);">
The function executes correctly and the struts action is also executed. However the problem is that for some reason the action doesn't forward to the "processing done" page. It does actually, if I debug, but nothing happens, the "waiting" page keeps being displayed.
Does anyone have an idea about what I could be doing wrong? any suggestion?
Thanks a lot!!Did you define the call back function correctly? like===
xmlhttp.onreadystatechange = handleHttpEvent;
function handleHttpEvent(){
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
// GO TO PROCESSING END PAGE
} else {
window.alert("ERROR");
}Also, you might want to check the progress bar application
in bpcatalog -> http://bpcatalog.dev.java.net -
Populating dependent dropdown without using AJAX
In my struts application, I have jsp where I have two dropdowns (<html:select>) - Course and Subject.
The values are being retrieved from database.
Now depending on the selection of my Course, I have to get corresponding Subjects from database.
If I call same Action class from jsp, when jsp loads again, it refreshes my dropdowns and the value selected previously for Course reset.
I dont want to use AJAX.
Please give some idea, how can I acheive it.
Thanks in advance.Gagz wrote:
but when jsp loads, it clears the value of first dropdown.Ah, that's your whole problem! Populating the 2nd dropdown has completely nothing to do with it. You would still get the same problem if you didn't populate any 2nd dropdown. Try to elaborate problems the smart way the next time.
Not sure how to do it in Struts (you're here at a JSP forum, not at a Struts forum), but basically you should set the selected value based on the submitted value/property. something like <html:select value="${beanname.propertyname}"> or <html:select property="propertyname">. In plain JSP/HTML terms you just need to set the <option> to "selected" based on the submitted value as request parameter. -
Error processing a page when using AJAX
hi apex forum.
I need your help with a problem that presents me with an application in apex 4.2.
I have developed a html screen, in which I have created a table that contains a detailed items and on which the user can enter some values. these data that user enters, I calculate a total at the end of the page. To view the current total of the entries , the user presses a button that uses AJAX (to avoid having to refresh the whole page) to calculate totals and at the same time, i call an AJAX process to add each record to an apex_collection , until here everything perfect.
The problem is that when I want to save the information to pass it from apex_collection to the database (by pressing a button and make the official insert), I must first have to refresh the page, if not do it this way, Apex generate an Error Message.
it's important to say that error does not apper, if before pressing the button, i first refresh the page. Any suggestions??
I think I should use some internally command to synchronize or update the page.... any suggestions are welcome.,
thanks in advance,Soooo...
What is the error you are seeing?
Is the multi-row process still there? What exactly happens on submit (computations, validations, processes)?
Have you tried to run with debug enabled and were you able to see where the error originates? -
Help required for using ajax in netweaver
Hi..
Can i Use Ajax for my netweaver applications?? If yes, then how?? Any pointers regarding that will be adequately rewarded points..
ThanksFor pure JavaScript enabled AJAX application, no problem. You just write the application as usual and send XMLHttpRequest with parameters to server, then update the web page with your JavaScript code;
I can show you some sample code here:
<script type="text/javascript">
function createXMLHttpRequest() {
var xmlHttp;
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
return xmlHttp;
function onclick_changeModelHouse(id) {
var xmlHttp = createXMLHttpRequest();
xmlHttp.onreadystatechange = function(){
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
// here you get your page component with id or any you like,
// then update it with data returned from the request you sent;
// Here I update one image url path;
var img = document.getElementById("houseModel");
// suppose you return the image file name;
img.innerHTML="<img src='images/" + xmlHttp.responseText + "'>";
xmlHttp.open("GET", "http://myserver:8080/myApp//AjaxImageService?model="+id, true);
xmlHttp.send(null);
</Script>
For some button in your page you add javascript code like
onClick="onclick_changeModelHouse(id)"
somthing.
You need develop servlet to response your request, and usually you need pass back your data in XML format, here I just use plain text for easy understanding. -
Using AJAX to load city, state, metro area based on zip code
I'm new to getting APEX to work with AJAX properly. I've been reading some tutorials and trying to apply what they do to my situation, but I'm running into a problem. I have a text field item for zip code. What I want to happen is that when someone enters in a zip code, I want to use AJAX to populate 3 different select lists (1 each for state, city, and metro area) and to populate a checkbox (of neighborhoods based on the zip code as well). I'm looking at the examples in:
http://www.oraclealchemist.com/wp-content/uploads/2006/11/s281946.pdf
and
http://apex.oracle.com/pls/otn/f?p=11933:63
But they all use examples where the value of a text field item is used to populate 1 select list. I can't figure out how to apply that methodology to populate 3 select lists and 1 checkbox item. I've got all my SELECT statements written to populate these fields based on the value of the zip code text field item, but don't know how to convert what I already have to use AJAX.
Here are my SELECT statements:
P2805_STATE lov:
===========================================================================================
SELECT INITCAP(GEO_DATA_STATE.STATEFULLNAME) d,GEO_DATA_STATE.STATE v
FROM GEO_DATA_STATE, GEO_DATA_ZIP
WHERE isPrimary = 'P' and
trim(upper(GEO_DATA_ZIP.STATE)) = trim(upper(GEO_DATA_STATE.STATE)) and
GEO_DATA_ZIP.ZIPCODE = :P2805_ZIPCODE
ORDER BY STATEFULLNAME
P2805_CITY lov:
===========================================================================================
SELECT UNIQUE (INITCAP(GEO_DATA_CITY.CITY)) d,GEO_DATA_CITY.CITY v
FROM GEO_DATA_STATE, GEO_DATA_ZIP, GEO_DATA_CITY
WHERE
trim(upper(GEO_DATA_ZIP.STATE)) = trim(upper(GEO_DATA_STATE.STATE)) and
trim(upper(GEO_DATA_ZIP.CITY)) = trim(upper(GEO_DATA_CITY.CITY)) and
GEO_DATA_ZIP.ZIPCODE = :P2805_ZIPCODE
ORDER BY GEO_DATA_CITY.CITY
P2805_METRO_AREA lov:
===========================================================================================
SELECT UNIQUE (INITCAP(GEO_DATA_METRO.METRO_AREA)) d,GEO_DATA_METRO.CODE v
FROM GEO_DATA_STATE, GEO_DATA_ZIP, GEO_DATA_METRO
WHERE
trim(upper(GEO_DATA_ZIP.STATE)) = trim(upper(GEO_DATA_STATE.STATE)) and
trim(upper(GEO_DATA_ZIP.METROCODE)) = trim(upper(GEO_DATA_METRO.CODE)) and
GEO_DATA_ZIP.ZIPCODE = :P2805_ZIPCODE
ORDER BY 1
P2805_NEIGHBORHOOD lov:
===========================================================================================
SELECT UNIQUE (INITCAP(GEO_DATA_HOOD.HOOD)) d,GEO_DATA_HOOD.HOOD v
FROM GEO_DATA_STATE, GEO_DATA_ZIP, GEO_DATA_METRO, GEO_DATA_HOOD
WHERE
trim(upper(GEO_DATA_ZIP.STATE)) = trim(upper(GEO_DATA_STATE.STATE)) and
trim(upper(GEO_DATA_ZIP.METROCODE)) = trim(upper(GEO_DATA_METRO.CODE)) and
GEO_DATA_HOOD.METRO_CODE = GEO_DATA_METRO.CODE and
GEO_DATA_ZIP.ZIPCODE = :P2805_ZIPCODE
ORDER BY 1Do all these statements need to go in 1 on-demand process? Where do I go from here?Andy, cool. This is starting to make more sense. THANKS A BUNCH! OK. I've gone ahead and modified the on demand process to suit my needs, so I have:
begin
owa_util.mime_header('text/xml', FALSE );
htp.p('Cache-Control: no-cache');
htp.p('Pragma: no-cache');
owa_util.http_header_close;
-- Building States list
htp.prn('<SELECT>');
FOR i in (
SELECT INITCAP(GEO_DATA_STATE.STATEFULLNAME) d, GEO_DATA_STATE.STATE v
FROM GEO_DATA_STATE, GEO_DATA_ZIP
WHERE isPrimary = 'P' and
trim(upper(GEO_DATA_ZIP.STATE)) = trim(upper(GEO_DATA_STATE.STATE)) and
GEO_DATA_ZIP.ZIPCODE = :P2805_ZIPCODE
ORDER BY STATEFULLNAME
LOOP
htp.prn('<OPTION VALUE=''' || i.v || '''>' || i.d || '</OPTION>');
END LOOP;
htp.prn('</SELECT>');
-- Building Cities list
htp.prn('<SELECT>');
FOR i in (
SELECT UNIQUE (INITCAP(GEO_DATA_CITY.CITY)) d, GEO_DATA_CITY.CITY v
FROM GEO_DATA_STATE, GEO_DATA_ZIP, GEO_DATA_CITY
WHERE
trim(upper(GEO_DATA_ZIP.STATE)) = trim(upper(GEO_DATA_STATE.STATE)) and
trim(upper(GEO_DATA_ZIP.CITY)) = trim(upper(GEO_DATA_CITY.CITY)) and
GEO_DATA_ZIP.ZIPCODE = :P2805_ZIPCODE
ORDER BY GEO_DATA_CITY.CITY
LOOP
htp.prn('<OPTION VALUE=''' || i.v || '''>' || i.d || '</OPTION>');
END LOOP;
htp.prn('</SELECT>');
-- Building Metro Area list
htp.prn('<SELECT>');
FOR i in (
SELECT UNIQUE (INITCAP(GEO_DATA_METRO.METRO_AREA)) d, GEO_DATA_METRO.CODE v
FROM GEO_DATA_STATE, GEO_DATA_ZIP, GEO_DATA_METRO
WHERE
trim(upper(GEO_DATA_ZIP.STATE)) = trim(upper(GEO_DATA_STATE.STATE)) and
trim(upper(GEO_DATA_ZIP.METROCODE)) = trim(upper(GEO_DATA_METRO.CODE)) and
GEO_DATA_ZIP.ZIPCODE = :P2805_ZIPCODE
ORDER BY 1
LOOP
htp.prn('<OPTION VALUE=''' || i.v || '''>' || i.d || '</OPTION>');
END LOOP;
htp.prn('</SELECT>');
-- Building Neighborhood list
htp.prn('<SELECT>');
FOR i in (
SELECT UNIQUE (INITCAP(GEO_DATA_HOOD.HOOD)) d, GEO_DATA_HOOD.HOOD v
FROM GEO_DATA_STATE, GEO_DATA_ZIP, GEO_DATA_METRO, GEO_DATA_HOOD
WHERE
trim(upper(GEO_DATA_ZIP.STATE)) = trim(upper(GEO_DATA_STATE.STATE)) and
trim(upper(GEO_DATA_ZIP.METROCODE)) = trim(upper(GEO_DATA_METRO.CODE)) and
GEO_DATA_HOOD.METRO_CODE = GEO_DATA_METRO.CODE and
GEO_DATA_ZIP.ZIPCODE = :P2805_ZIPCODE
ORDER BY 1
LOOP
htp.prn('<OPTION VALUE=''' || i.v || '''>' || i.d || '</OPTION>');
END LOOP;
htp.prn('</SELECT>');
end;It doesn't look like I would have to modify the appendToSelect function at all, correct? Is the checkbox that I need to populate handled the same way as these select lists? And it seems like I only need to make the 2 changes that you mentioned to get_AJAX_SELECT_XML function, right? So my javascript function should be like:
<script language="JavaScript1.1" type="text/javascript">
function get_AJAX_SELECT_XML(pThis,pSelect1,pSelect2,pSelect3,pSelect4){
if (document.getElementById('P2805_ZIPCODE').value.length == 5)
var l_Return = null;
var l_Select1 = $x(pSelect1);
var l_Select2 = $x(pSelect2);
var l_Select3 = $x(pSelect3);
var l_Select4 = $x(pSelect4);
var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=otn_Select_XML',0);
get.add('TEMPORARY_ITEM',pThis.value);
gReturn = get.get('XML');
var sels = gReturn.getElementsByTagName("select");
if(gReturn && l_Select1){
var l_Count = sels[0].getElementsByTagName("option").length;
l_Select1.length = 0;
for(var i=0;i<l_Count;i++){
var l_Opt_Xml = sels[0].getElementsByTagName("option");
appendToSelect(l_Select1, l_Opt_Xml.getAttribute('value'), l_Opt_Xml.firstChild.nodeValue)
if(gReturn && l_Select2){
var l_Count = sels[1].getElementsByTagName("option").length;
l_Select2.length = 0;
for(var i=0;i<l_Count;i++){
var l_Opt_Xml = sels[1].getElementsByTagName("option")[i];
appendToSelect(l_Select2, l_Opt_Xml.getAttribute('value'), l_Opt_Xml.firstChild.nodeValue)
if(gReturn && l_Select3){
var l_Count = sels[2].getElementsByTagName("option").length;
l_Select3.length = 0;
for(var i=0;i<l_Count;i++){
var l_Opt_Xml = sels[2].getElementsByTagName("option")[i];
appendToSelect(l_Select3, l_Opt_Xml.getAttribute('value'), l_Opt_Xml.firstChild.nodeValue)
if(gReturn && l_Select4){
var l_Count = sels[3].getElementsByTagName("option").length;
l_Select4.length = 0;
for(var i=0;i<l_Count;i++){
var l_Opt_Xml = sels[3].getElementsByTagName("option")[i];
appendToSelect(l_Select4, l_Opt_Xml.getAttribute('value'), l_Opt_Xml.firstChild.nodeValue)
get = null;
</script>
And then since all 4 items (3 select lists and 1 checkbox item) are populated based on the value inputted in the text field item, I would only need to add the following to the html form element attribute of my text field item, right?
onKeyUp="javascript:get_AJAX_SELECT_XML(this,'P2805_STATE','P2805_CITY','P2805_METRO_AREA','P2805_NEIGHBORHOOD');"Denes, thanks for the example. It seems like what I need to do is somewhere inbetween what you have and what's in the example on http://apex.oracle.com/pls/otn/f?p=11933:37. I have 3 select lists and 1 checkbox item that should all be populate depending on the value entered for the text item. Do I still need to split everything up then into a function and an on demand process for each select list and checkbox? -
Calling an On Demand Process in PL/SQL Region without using AJAX
Hi!
I am trying to find a way to call an On demand Process in a PL/SQL Reports Region. The reason is that i need Reportings for about 20 Pages that look like the same but have different parameters. I already have some Processes that return SQL Statements and it works fine. But these Reportings are more complex and it's not possible to return it wirh a SQL Statement.
I have seen some solutions in this forum that used AJAX to call such a process. The problem is, that I'm not allowed to use AJAX because activeX is diabled. I tried it and it works but i need another way to solve this process call.
Thanks in advance
PhilippAt the moment I cannot say if your link can help. Right now the call of the On demand Process looks like this:
Inside annonymous PL/SQL Region:
<script type="text/javascript">
get = new htmldb_Get(null,'||:APP_ID||'.,'APPLICATION_PROCESS=F_REPORT_NAME',0);
gReturn = get.get();
document.write(gReturn);
</script> -
# of parameters you can pass using AJAX
I have a weird problem with an AJAX form combined with a CFC. Just to rule out any possibilities, is there a limit on the number of input fields you can pass to a CFC using AJAX? I only ask because it appears when the entire form is filled out the page throws an error that the CFC can't be found.
Also, I'm noticing that 2 of the parameters are out of order (in red). Would that make a difference? I'm also not sure why they are out of order when getting passed because they are not that way on the form. Am I missing something here?
CFC
<cffunction name="LyricOpera" access="remote" returntype="array" output="false">
<cfargument name="CurrentApplicationStep" type="string" default="" />
<cfargument name="ScreenSelection" type="string" default="" />
<cfargument name="Role1" type="string" default="" />
<cfargument name="Opera1" type="string" default="" />
<cfargument name="Company1" type="string" default="" />
<cfargument name="Year1" type="string" default="" />
<cfargument name="Role2" type="string" default="" />
<cfargument name="Opera2" type="string" default="" />
<cfargument name="Company2" type="string" default="" />
<cfargument name="Year2" type="string" default="" />
<cfargument name="Role3" type="string" default="" />
<cfargument name="Opera3" type="string" default="" />
<cfargument name="Company3" type="string" default="" />
<cfargument name="Year3" type="string" default="" />
<cfargument name="Aria1" type="string" default="" />
<cfargument name="Aria1Opera" type="string" default="" />
<cfargument name="Aria1Language" type="string" default="" />
<cfargument name="Aria2" type="string" default="" />
<cfargument name="Aria2Opera" type="string" default="" />
<cfargument name="Aria2Language" type="string" default="" />
<cfargument name="Aria3" type="string" default="" />
<cfargument name="Aria3Opera" type="string" default="" />
<cfargument name="Aria3Language" type="string" default="" />
<cfargument name="Variable1Name" type="string" default="" />
<cfargument name="Variable1Institution" type="string" default="" />
<cfargument name="Variable1Address1" type="string" default="" />
<cfargument name="Variable1City" type="string" default="" />
<cfargument name="Variable1State" type="string" default="" />
<cfargument name="Variable1Province" type="string" default="" />
<cfargument name="Variable1Zipcode" type="string" default="" />
<cfargument name="Variable1PostalCode" type="string" default="" />
<cfargument name="Variable1Phone" type="string" default="" />
<cfargument name="Variable1IntlPhone" type="string" default="" />
<cfargument name="Variable1Country" type="string" default="" />
<cfargument name="Variable1Email" type="string" default="" />
<cfargument name="Variable2Name" type="string" default="" />
<cfargument name="Variable2Institution" type="string" default="" />
<cfargument name="Variable2Address1" type="string" default="" />
<cfargument name="Variable2City" type="string" default="" />
<cfargument name="Variable2State" type="string" default="" />
<cfargument name="Variable2Province" type="string" default="" />
<cfargument name="Variable2Zipcode" type="string" default="" />
<cfargument name="Variable2PostalCode" type="string" default="" />
<cfargument name="Variable2Phone" type="string" default="" />
<cfargument name="Variable2IntlPhone" type="string" default="" />
<cfargument name="Variable2Country" type="string" default="" />
<cfargument name="Variable2Email" type="string" default="" />
From Firebug
argumentCollection{
"CurrentApplicationStep":"Lyric-Opera",
"ScreenSelection":"Submit",
"Role1":"Abigail",
"Opera1":"The Crucible",
"Company1":"Kingwood Summer Opera",
"Year1":"2010",
"Role2":"Title role",
"Opera2":"Suor Angelica",
"Company2":"Kingwood Summer Opera",
"Year2":"2008",
"Role3":"Lauretta",
"Opera3":"Gianni Schicchi",
"Company3":"Sam Houston State University",
"Year3":"2007",
"Aria1":"Tacea la notte placida",
"Aria1Opera":"Il Trovatore",
"Aria1Language":"Italian",
"Aria2":"Song to the Moon",
"Aria2Opera":"Rusalka",
"Aria2Language":"Czech",
"Aria3":"Embroidery Aria",
"Aria3Opera":"Peter Grimes",
"Aria3Language":"English",
"Variable1Name":"Todd R Miller",
"Variable1Institution":"Lonestar College Kingwood",
"Variable1Address1":"20000 Kingwood Dr",
"Variable1City":"Kingwood",
"Variable1State":"TX",
"Variable1Province":"",
"Variable1Zipcode":"77339",
"Variable1Phone":"281-312-1485",
"Variable1IntlPhone":"",
"Variable1Country":"USA",
"Variable1Email":"[email protected]",
"Variable2Name":"Anne Heath-Welch",
"Variable2Institution":"Todd Miller",
"Variable2Address1":"309 East 13th Street",
"Variable2City":"Houston",
"Variable2State":"TX",
"Variable2Province":"",
"Variable2Zipcode":"77008",
"Variable2Phone":"832-335-9108",
"Variable2IntlPhone":"",
"Variable2Country":"USA",
"Variable2Email":"[email protected]",
"Variable1Postalcode":"",
"Variable2Postalcode":"",
"Submit":"Continue"}
methodLyricOpera
returnFormat
jsonThe fix is to set "setHTTPMethod("POST");" for the AJAX proxy. By default, the proxy function "setHTTPMethod("method");" is set to "GET" and 47 input fields with corresponding data is over the limit. The proxy function, "setHTTPMethod("method");", must be set to "POST" to avoid this error.
-
When we will be able to use AJAX components inside a portlet?
Hi
Thank you for reading my post
when we will be able to use AJAX components inside a portlet?
thanksI noticed the failure of the portlet to load its needed JavaScript files. Are there additional problems with the Ajax components running inside a portlet? Using the weblets project seemed like one approach to dealing with the resource loading problem.
...Kevin
Maybe you are looking for
-
Using a Global as a value change in an Event Structure
I have many events I want to react to based on Global buttons. How do I get the Event Structure to recognize a global button value change? This screen shot is one of my many attempts. So far my events only change with a real button on the FP. Than
-
Spinning wheel when setting up new time machine
Hi, Am sure there is something obvious i'm missing, but having set up a new time capsule (my first) I am having problems getting it to work with time machine. I have it working fine over airport and so I think it is working fine- I am getting a much
-
How to avoid save same employee name under same company name
hi, i am doing flex4 web application with mxml tags, i am having one text box and one datagrid and one save button. text box having one company name, data grid having employee names. when i click save button which is placed in outside the datagrid it
-
Rejection of subcontract material to vendor without return of material.
Dear friends, There are some subcontracted (semi finished) parts kept with us which were received from Subcontractor after their process. As usual at the time of GR, the raw material sent to them were consumed at our end and relavent labour charges w
-
I made a video on my Iphone 4S uploaded it to my Imac via direct connection. When I try to share the video Email it says you can not share videos in IPhoto. I posted it to FaceBook and it is fine. Any help with other ways to transfer would be much ap