Using Tree Elements as parameters to a CFC function using AJAX
I would like to use a <CFTREEITEM> tag element ("value") as a parameter to a CFC function. I regret that I am fairly new to AJAX and I do not have te exertise to accomplish this. Does anyone have a method? Page 671 of the Coldfusion 8 Developers Guide indicates that it is not posiible to do this "directly", but I am hoping to find a way through possibly less direct means.
Hi kanishka wickrama
Here is an example of passing parameters from SAP to a Stored Procedure:
In the stored procedure you need your variable with the word output as follows:
@FromDate varchar(12) OUTPUT,
@ToDate varchar(12) OUTPUT
Then in your query in SAP pass them as follows (in this example the dates are pulled from OPCH, but you can also use OFPR as it contains all the start and end dates for each financial period)::
DECLARE @FromDate DATETIME
DECLARE @ToDate DATETIME
SELECT @FromDate = T0.DocDate FROM dbo.OPCH T0 WHERE T0.DocDate = '[%0]'
SELECT @ToDate = T1.DocDate FROM dbo.OPCH T1 WHERE T1.DocDate = '[%1]'
EXEC MY_STORED_PROCEDURE @FromDate, @ToDate
Hope this helps
Kind regards
Peter Juby
Similar Messages
-
Tree element: How to make nodes editable
Is it possible to make the nodes of a Tree element (a design time element visible in the view editor) editable? Or is there a tree component that can be used via "component use" with which to accomplish that?
I don't want to use a table with embedded TreeByKeyTableColumn or similar!Hi Klaus,
It's not possible for a tree ui element. As you pointed out you could achieve it using a TreeBy* master column of a table. The ByNesting variant uses a similar context structure as a tree. In addition, using a table will enable scrolling - which is not possible for the Tree ui element.
Best regards,
Thomas -
# 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.
-
Hi,
i implemented a tree structure in a table with MasterColumn UI element . I added also to MasterColumn two Menu UI Elements. It schould be possible for user, after clicking one of the tree element to choose function -add to filter-, and this currently used element name must be copied and transferred to another view. Unfotunataly i can't find any solution for these problems:
nodeTable()->root element,
1)wdContext.nodeTable().getTitle() , it gives only currently selected element, or the first element if nothing was selected, i can't get the Element who has called this menu action.
2) if i even select some line in table, i can get only the root element name, not child element name
Could you please help?
Thank you very much.
Kind Regards,
DariaHi Armin,
Thank you very very much!!!!!
i added a parameter("filterParam") as you sad in Filter action and mapped in wdDoModifyView() this way:
IWDMenuActionItem menu =(IWDMenuActionItem)view.getElement("MenuActionItem");
menu.mappingOfOnAction().addSourceMapping("nodeElement","filterParam");
Now it's working!!!
I only need now to differ nodes (wich level it is) to copy it to the right view Inputfield. I hope it's possible just by adding a new value attribute such as typeOfnode to Table(datasource) Node ...
One question.
Is "nodeElement" parameter defined in meta model of Mastercolumn UI?
Thank you once more for help!
Kind regards,
Daria -
Hello!
I'm trying to create a kind of a navigation tree for my application.
It should represent some elements of an XML structure and some other nodes for other options.
The binding with the context is not a problem, I can create the tree up to all the levels I want to.
The problem now is, that I don't know, how to get the "current tree element", when there is any action.
For example:
public void onActionSelect(...) {
String test = wdContext.currentTreeNodeElement().getText();
wdThis.wdGetContext().currentContextElement().setSelectedElement(test);
With this method I can get the text of the "first level nodes". If I want to get the "second level node", I can do
String test = wdContext.currentTreeNodeElement().currentChildElement.getText();
..and for the next levels so on.
Isn't there any general method to get the information of the selected element without knowing before, whether it is a nodeElement or a nodeElement.currentChildElement or a nodeElement.currentChildElement.currentChildElement, ...?
Greetings,
RamóHi,
if you following that pdf ,
i think your not implemented the below code in DomodifyView method
if (firstTime) {
IWDTreeNodeType treeNode = (IWDTreeNodeType) view.getElement("TheNode");
/* The following line is necessary to create parameter mapping from parameter "path" to parameter "selectedElement".
Parameter "path" is of type string and contains the string representation of the tree element (its corresponding context element to be exact)
that raised the onAction event. Parameter "selectedElement" is of type IWDNodeElement (or extends it) and is defined as parameter in the event handler
that handles the onAction. The parameter mapping defined here translates the String "path" into the corresponding context element that then can
be accessed within the event handler
treeNode.mappingOfOnAction().addSourceMapping("path", "selectedElement");
/* The following line is necessary to create parameter mapping from parameter "path" to parameter "element".
Parameter "path" is of type string and contains the string representation of the tree element (its corresponding context element to be exact)
that raised the onLoadChildren event. Parameter "element" is of type IWDNodeElement (or extends it) and is defined as parameter in the event handler
that handles the onLoadChildren. The parameter mapping defined here translates the String "path" into the corresponding context element that then can
be accessed within the event handler
treeNode.mappingOfOnLoadChildren().addSourceMapping("path", "element");
please cross check once.
Thanks,
Ramesh -
Is it possible to create a tree with drag-and-drop functionality using ajax
I saw these samples;
Scott Spendolini's AJAX Select List Demo
http://htmldb.oracle.com/pls/otn/f?p=33867:1:10730556242433798443
Building an Ajax Memory Tree by Scott Spendolini
http://www.oracle.com/technology/pub/articles/spendolini-tree.html
Carl Backstrom ApEx-AJAX & DHTML examples;
http://htmldb.oracle.com/pls/otn/f?p=11933:5:8901671725714285254
Do you think is it possible to create a tree with drag-and-drop functionality using ajax and apex like this sample; http://www.scbr.com/docs/products/dhtmlxTree/
Thank you,
Kind regards.
TonguçHello,
Sure you can build it, I just don't think anyone has, you could also use their solution as well in an APEX page it's just a matter of integration.
Carl -
How to give url to an tree element?
I have created a 2 views
The first view contains a Tree Control like:
MainMenu 1
- submenu 1
- submenu 2
MainMenu 2
- submenu 1
- submenu 2
MainMenu 3
- submenu 1
- submenu 2 and a tranparent container in the right side of tree.
The second view contain some contents.
I want to give action for the tree element like if I click the submenu , it should display the second view in the transparent container of the first view.
Can anyone pls suggest me?
Thanks.Hi Abdul,
I guess what you need is a Link To Action table column. You can achieve same by following the below mentioned steps:
1) click on table and try to bind it to the context node
2) change the property "cell editor of table column" to "link to action" of the column/attribute from where you would like to trigger the action.
3) bind the "visible" property of VC to a context attribute of type boolean
4) set this attribute to abap_true in event OnAction__()
this will display your view at that location.
Hope this helps.
Regards,
Anoop -
Problem by activating Monitoring Tree Element in NW Administrator
Hi All,
I try to activate the monitor tree element in http://<host>:<j2ee port>/nwa but I find not active the entry server and the related entry "applications". The step necessary for my configuration is to select the tab Configuration of the Details pane, select Data Collection from the Show drop-down menu, and activate all monitors of the subtree by selecting the Enable All Children.
The button [Enable All Children] is in a gray colour as all path starting from the "Server" entry.
For my configuration I'm following the information in "How to Monitor Exchange Infrastructure.pdf".
Any suggestion will be well appreciated.
Many thanks in advance for your support.
Regards,
Edited by: GiovanniB on Jul 1, 2009 4:19 PMmay be below tags would help you
Re: IT0019 Date of Monitoring TAsk
How to create a Customizing Monitoring Tree Element(MTE) for CCMS alerts.
regards
nag -
Any function like 'SEARCH', 'SEARCH NEXT' available in tree element?
As we know, the tree control in EnjoySAP Controls provides the functions 'Search' and 'Search Next'. Are these functions available in a tree UI element in WebDynpro?
Hi
According to my information i dont think functions like 'Search' and 'Search Next' are available for a tree UI element in WebDynpro.
If you want to check any value follow the below instructions:
1. In the test script editor, open the command interface.
2. Expand the tree in the left side of the structure editor to display the relevant element.
3. From the context menu, choose Insert Check. The element is copied to the GETS_AND CHECKS node.
4. Under the GETS_AND CHECKS node, double-click the element to display it for editing in the right-hand pane.
5. Parameterize the CheckAction field and ExpectedValue field as required. Optionally, parameterize the Value field to perform a GET as well.
For further clarifications please go through the link:
http://help.sap.com/saphelp_nw2004s/helpdata/en/84/ef2a41b108f523e10000000a155106/frameset.htm
Rergards
Elizabeth -
How to use Ajax Get Multiple Values in Tabular form?
Hi All-
I am trying to use AJAX to get multiple values in tabular form by using Denes Kubicek's example in the following link -
http://apex.oracle.com/pls/otn/f?p=31517:239:9172467565606::NO:::
Basically, I want to use the drop down list to populate rest of the values on the form.
I have created the example(Ajax Get Multiple Values, application 54522) on Oracle site -
http://apex.oracle.com/pls/apex/f?p=4550:1:0:::::
Workspace: iConnect
login: demo
password: demo
I was able to duplicate his example on page 1 (home page).
However, I want to use system generate tabular form to finish this example, and was not able to populate the data correctly.
Page 2 (method 2) is the one that I am having trouble to populate the column values. When I checked application item values in Session, and the values seems to be populated correctly.
This is what I have done on this page:
1. Create an Application Process On Demand - Set_Multi_Items_Tabular2:
DECLARE
v_subject my_book_store.subject%TYPE;
v_price my_book_store.price%TYPE;
v_author my_book_store.author%TYPE;
v_qty NUMBER;
CURSOR cur_c
IS
SELECT subject, price, author, 1 qty
FROM my_book_store
WHERE book_id = :temporary_application_item2;
BEGIN
FOR c IN cur_c
LOOP
v_subject := c.subject;
v_price := c.price;
v_author := c.author;
v_qty := c.qty;
END LOOP;
OWA_UTIL.mime_header ('text/xml', FALSE);
HTP.p ('Cache-Control: no-cache');
HTP.p ('Pragma: no-cache');
OWA_UTIL.http_header_close;
HTP.prn ('<body>');
HTP.prn ('<desc>this xml genericly sets multiple items</desc>');
HTP.prn ('<item id="f04_' || :t_rownum || '">' || v_subject || '</item>');
HTP.prn ('<item id="f05_' || :t_rownum || '">' || v_price || '</item>');
HTP.prn ('<item id="f06_' || :t_rownum || '">' || v_author || '</item>');
HTP.prn ('<item id="f07_' || :t_rownum || '">' || v_qty || '</item>');
HTP.prn ('</body>');
END;
2. Create two application items - TEMPORARY_APPLICATION_ITEM2, T_ROWNUM2
3. Put the following in the Page Header:
<script language="JavaScript" type="text/javascript">
function f_set_multi_items_tabular2(pValue, pRow){
var get = new htmldb_Get(null,html_GetElement('pFlowId').value,
'APPLICATION_PROCESS=Set_Multi_Items_Tabular2',0);
if(pValue){
get.add('TEMPORARY_APPLICATION_ITEM2',pValue)
get.add('T_ROWNUM2',pRow)
}else{
get.add('TEMPORARY_APPLICATION_ITEM2','null')
gReturn = get.get('XML');
if(gReturn){
var l_Count = gReturn.getElementsByTagName("item").length;
for(var i = 0;i<l_Count;i++){
var l_Opt_Xml = gReturn.getElementsByTagName("item")[i];
var l_ID = l_Opt_Xml.getAttribute('id');
var l_El = html_GetElement(l_ID);
if(l_Opt_Xml.firstChild){
var l_Value = l_Opt_Xml.firstChild.nodeValue;
}else{
var l_Value = '';
if(l_El){
if(l_El.tagName == 'INPUT'){
l_El.value = l_Value;
}else if(l_El.tagName == 'SPAN' && l_El.className == 'grabber'){
l_El.parentNode.innerHTML = l_Value;
l_El.parentNode.id = l_ID;
}else{
l_El.innerHTML = l_Value;
get = null;
</script>
Add the follwing to the end of the above JavaScript:
<script language="JavaScript" type="text/javascript">
function setLOV(filter, list2)
var s = filter.id;
var item = s.substring(3,8);
var field2 = list2 + item;
f_set_multi_items_tabular2(filter, field2);
4. Tabular form query:
select
"BOOK_ID",
"BOOK",
"SUBJECT",
"PRICE",
"AUTHOR",
"QTY",
"BOOK_ID" BOOK_ID_DISPLAY
from "#OWNER#"."MY_BOOK_STORE"
5. In Book_ID_DISPLAY column attribute:
Add the following code to element attributes: onchange="javascript:f_set_multi_items_tabular2(this.value,'#ROWNUM#');"
Changed to -> onchange="javascript:setLOV(this,'f03');"
Now, T_ROWNUM2 returns value as f03_0001. But, TEMPORARY_APPLICATION_ITEM2 returns as [object HTMLSelectElement]...
Please help me to see how I can populate the data with this tabular form format. Thanks a lot in advanced!!!
Ling
Updated code in Red..Ling
Lets start with looking at what the javascript code is doing.
function f_set_multi_items_tabular(pValue, pRow){
/*This will initiate the url for the demand process to run*/
var get = new htmldb_Get(null,html_GetElement('pFlowId').value,
'APPLICATION_PROCESS=Set_Multi_Items_Tabular',0);
if(pValue){
/*If there is an value than submit item name with value*/
get.add('TEMPORARY_APPLICATION_ITEM',pValue)
get.add('T_ROWNUM',pRow)
}else{
/*Else set the item TEMPORARY_APPLICATION_ITEM to null*/
get.add('TEMPORARY_APPLICATION_ITEM','null')
/*Submit the url and te returned document is of type XML*/
gReturn = get.get('XML');
if(gReturn){
/*There is something returned*/
var l_Count = gReturn.getElementsByTagName("item").length;
/*For all elements of the tag item*/
for(var i = 0;i<l_Count;i++){
/*Get the item out of the XML*/
var l_Opt_Xml = gReturn.getElementsByTagName("item")[i];
/*Get the id of the item*/
var l_ID = l_Opt_Xml.getAttribute('id');
/*Get the element in the original page with the same id as
**the item we have in the XML produced by the ondemand process
var l_El = html_GetElement(l_ID);
/*Now get the value of the item form the XML*/
if(l_Opt_Xml.firstChild){
var l_Value = l_Opt_Xml.firstChild.nodeValue;
}else{
/*There is no value*/
var l_Value = '';
if(l_El){
/*There is an element with the same id as the item we are processing*/
if(l_El.tagName == 'INPUT'){
/*The element is an input item just set the value*/
l_El.value = l_Value;
}else if(l_El.tagName == 'SPAN' && l_El.className == 'grabber'){
/*If it is a span elment and has the class grabber
**Then set the innerHTML of the parent to the value
**and the id of the parent to the id
l_El.parentNode.innerHTML = l_Value;
l_El.parentNode.id = l_ID;
}else{
/*Else set the value as innerHTML*/
l_El.innerHTML = l_Value;
get = null;
Now where it went wrong in your initial post
The XML that was returned by your XML process would be something like
<body>
<desc>this xml genericly sets multiple items</desc>
<item id="f02_1">CSS Mastery</item>
<item id="f03_1">22</item>
<item id="f04_1">Andy Budd</item>
<item id="f05_1">1</item>
</body>
When you don't use apex_item to create your tabular form a item in the table will look like
<input id="f02_0001" type="text" value="CSS Mastery" maxlength="2000" size="16" name="f05" autocomplete="off">
Notice the id's f02_1 and f02_0001 don't match.
So to make it work the XML would have to look like
<body>
<desc>this xml genericly sets multiple items</desc>
<item id="f02_0001">CSS Mastery</item>
<item id="f03_0001">22</item>
<item id="f04_0001">Andy Budd</item>
<item id="f05_0001">1</item>
</body>
To do that simply use lpad in the ondemand process like
HTP.prn ('<item id="f02_' || lpad(:t_rownum,4,'0') || '">' || v_subject || '</item>');
HTP.prn ('<item id="f03_' || lpad(:t_rownum,4,'0') || '">' || v_price || '</item>');
HTP.prn ('<item id="f04_' || lpad(:t_rownum,4,'0') || '">' || v_author || '</item>');
HTP.prn ('<item id="f05_' || lpad(:t_rownum,4,'0') || '">' || v_qty || '</item>');
Keep in mind that the above is based on your original post and #ROWNUM# not being lpadded with zero's.
Nicolette -
How can i upload file using ajax post request and jsp
Hi
this is my code files
addPhoto.jsp
<html>
<head>
<title>Add Photo</title>
<script>
var optionNo = 0;
var i=1;
var val=0;
var file = 0;
var exten = new Array(".jpg",".jpeg",".gif");
function addValues()
for(var i=0;i<5;i++)
optionNo += 1;
oNewOption = new Option();
oNewOption.text = optionNo;
oNewOption.value = optionNo;
addSelect.add(oNewOption);
function addBoxes()
var str = "";
var j=0;
val = document.getElementById('addSelect').value;
for(j=1; j<= val; j++)
str = str + '<font size=3>file:' + j + '</font>';
str = str + '<input type="file" id=filepath'+ j +' name=file'+ j + ' onchange="uploadFile(hidden'+ j + '.value)"><div id="result'+ j +'"></div>
str = str + '<input type="hidden" name="hidden' + j + '" value=' + j +'>';
document.getElementById('addPhoto').innerHTML = str;
function uploadFile(value)
var str = "filepath" + value;
file = value;
var param = document.getElementById(str).value;
var parameter = "filepath=" + param;
alert(parameter.length);
if(checkValidity(param))
var url = "uploadFile.jsp";
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
req.open("POST", url, true);
req.setRequestHeader("Content-type", "multipart/form-data");
//req.setRequestHeader("Content-length", parameter.length);
req.setRequestHeader("Connection", "close");
req.onreadystatechange = callback;
req.send(null);
else
document.getElementById("result" + file).innerHTML = "upload .jpeg,.jpg,.gif Files Only";
function callback() {
if (req.readyState == 4) {
updatepage(req.responseText);
function updatepage(str){
document.getElementById("result" + file).innerHTML = str;
function checkValidity(str)
var i=0;
var j=0;
var str1 = str.substring(str.lastIndexOf("."),str.length);
alert(str1);
for(i=0;i<exten.length;i++)
if(str1.search(exten) != -1)
j++;
break;
if(j>0)
return true;
else
return false;
</script>
</head>
<body onload="addValues()">
<h5>Add Photo(s)</h5>
<select id="addSelect" name="addSelect" onchange="addBoxes()">
<option id="select" selected>Select</option>
</select>
<div id="addPhoto"></div>
</body>
</html>
uploadFile.jsp
<%@page import="java.io.*"%>
<%
/*try
String contentType = request.getContentType();
System.out.println(request.getMethod());
System.out.println("Content type is :: " +contentType);
if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0))
DataInputStream in = new DataInputStream(request.getInputStream());
DataInputStream in1 = in;
int formDataLength = request.getContentLength();
System.out.println(formDataLength);
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while (totalBytesRead < formDataLength)
byteRead = in1.read(dataBytes, totalBytesRead, formDataLength);
totalBytesRead += byteRead;
out.println("<br>totalBytesRead : " + totalBytesRead + " : formDataLength = " + formDataLength);
} catch(Exception e) {
e.printStackTrace();
try
String filePath = request.getParameter("filepath");
System.out.println(filePath);
File f= new File(filePath);
String path = f.getName();
String contentType = request.getContentType();
System.out.println(contentType);
//InputStream in = new FileInputStream(filePath);
DataInputStream in = new DataInputStream(request.getInputStream());
int formDataLength = request.getContentLength();
System.out.println(formDataLength);
byte[] buf = new byte[1024];
OutputStream out1 = new FileOutputStream("c:/docs/" + path);
int len;
while ((len = in.read(buf)) > 0) {
out1.write(buf, 0, len);
in.close();
out1.close();
out.write("File Uploaded SucssesFully");
catch(Exception e)
e.printStackTrace();
out.write("error while Writing File");
%>
the above code in request.getContentType() i am getting 0. I am not passing the content length. for the same application with out using Ajax i am
getting the size of file... it is very very urgent for me.. pls help me out on this...
Any one having the code on this pls mail me the code...
my mail id ... [email protected]
Regards
Ashok KumarSure, you can upload a file, using a form input element of type file. You pick this up with a servlet, though you need a special request wrapper to sort out the multi-part request you get back that way (there's a suitable package on jakarta.apache.org/commons)
The servlet decrypts the file and can pass the results to a JSP for display.
Don't try to do the complicated stuff in a JSP, it all gets incredibly messy, and that's not what JSPs are for. -
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? -
Hi All,
Thanks for any help in advance.
I am trying to submit an item into the session by using AJAX iin version 4.1
I have a application process which is an on demand: run this application process when requested by a page process.
begin
:P4_FISCAL_YEAR2 := :AJAX_4_FISCAL_YEAR2;
end;then in the item :P4_FISCAL_YEAR2 have the html form element attributes set to:
(also the page item is set to None(Default) on page action when value changed.
onchange="selectChanged6(this)"and a page process
<script type="text/javascript">
function selectChanged6(filter)
var get = new htmldb_Get(null,$v('pFlowId'), 'APPLICATION_PROCESS=SET_4_FISCAL_YEAR2',0);
get.add('AJAX_4_FISCAL_YEAR2', filter.value);
var ret = get.get();
</script>The item doesnt seem to be submitting into the session and I cant figure out why, ThanksMarie,
I think I have acomplished what you are looking for but if your goal is quick response time then this can fluctuate since there is 1 ajax call made to set your item value and another ajax call for every chart you want to refresh.
This solution assumes the following:
1. all reports are in the same language and in english.
2. all reports are flash charts.
here is a demo: http://apex.oracle.com/pls/apex/f?p=43401:23:0
Go into your chart template and add the class refreshable_chart
<div class="rounded-corner-region refreshable_chart" id="#REGION_STATIC_ID#" #REGION_ATTRIBUTES#>
...Create the following dynamic action on your chart page:
Name: refresh_chart
Event: Change
Selection Type: Item(s)
Item(s): P4_FISCAL_YEAR2
True actions:
Sequence: 10
Action: execute pl/sql code
Code:
NULL;
{code}
Page Items to Submit: P4_FISCAL_YEAR2
Sequence: 20
Action: Execute JavaScript code
Affected Elements:
-- Type: jQuery Selector
-- jQuery Selector: .refreshable_chart
Code:
{code:javascript}
this.affectedElements.each(function(){
apex_RefreshFlashChart(&APP_PAGE_ID., this.id.substr(1), 'en');
{code}
Good Luck,
Tyson Jouglet
Edited by: Tyson Jouglet on Dec 14, 2011 10:33 AM -
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>
Maybe you are looking for
-
Not getting anywhere near the speeds I should be...
For a very long time, most likely since we've had the service, I have gotten very poor speeds. Where we should be getting 512Kbps-1Mbps according to our HSI plan, the maximum speed I have ever gotten is and was 91Kbps. According to my router page(192
-
Batch convert appleworks to pdf in same folder
I need a script that will work in 10.5.8 on a powerPC machine (iBook G4) that will allow me to scan the entire drive for Appleworks documents, open them in AppleWorks, print to PDF, apply the same name and save in the same folder. A bonus would be to
-
Win2K Server and Reports Server 3
Does the following Combination will work? OS - Win2K Server Reports Server - ver 3.0 Reports - ver 3.0 Database - Oracle v8.1.6 We are trying to upgrade our servers to Win2K from NT which unfortunately is running Oracle 8.0.6 with Reports Server 3.0
-
Execute javascript from plsql in a dynamic action.
Is it possible to execute javascript with htp.p from a plsql block in a dynamic action (on change). I have tried it but I get a JSON error. The reason I want to to this is: I have to check something with plsql and depending on the result I want to do
-
After a successful iOS 5 upgrade to my iPhone 3GS, I began going through the setup wizard the phone takes you through upon initial use. However, I'm unable to make it past the part where you are supposed to "Sign In with an Apple ID". The steps to