In a dynamic page how to share variable between PL/SQL and javascript
For example, my dynamic page contains such PL/SQL codes:
<ORACLE>
DECLARE
info varchar(100);
rowid urowid;
procedure doDelete(
row_id in urowid
) IS
begin
Delete From xxx
WHERE rowid = row_id;
end doDelete;
BEGIN
Select name, rowid INTO info, rowid
From xxx Where xxx;
HTP.PRN(' <INPUT TYPE="button" VALUE="show value" onClick="alert(info);">');
HTP.PRN(' <INPUT TYPE="button" VALUE="delete" onClick="doDelete(_row_id);">');
END;
</ORACLE>
The variable 'info' and '_row_id' are correct, however the two HTP. sentence do not work. What's the problem?
What I want to do is to show all the records in TABLE A in a page. And at the end of each line (record), there' re a 'delete' and a 'update' button to let user operate on this record. Is this possible? I know form can do delete an update, but it can not show all the records in a page like what report does. Besides dynamic page, is there any other better choice? Report can do it?
One more question. In a report, I employed link on one field to a second report. It works well. But I want to open the second report in a new window when the link is click. Is this possible?
I was almost driven crazy by these :( I so appreciate if anyone can help.
The code written by you is insufficient for the funtionality you are trying to achieve. Below is a method to achieve the same.
Note: Used standard scott.emp table for the example which is located in my db provider schema.
Do the below modifications as per your local configuration
xxxxx -> Replace it with your Portal schema
yyyyy -> Replace it with your db provider schema
<<module_id_of_form>> -> Replace with the module id of form created in step 1 & 2.
First and foremost... oracle does not allows variables starting with '_'. So if you want to use it you have to place it in double quotes ("")
rowid -> illegal
"_row_id" -> legal.
However, I will advice you not to use variable names starting with "_".
Now lets get started...
1. Create a form on the table you are using in the dynamic page. Just have the update button. Remove the other buttons.
2. Get the module id of this form. Instruction for getting the module id:
a) Right-click on the form's run link and copy the shortcut
b) Get the value of p_moduleid parameter. This is your module id.
3. Create a procedure "save_action_details" in your db provider schema. This procedure will accomplish the delete operation on the record.
CREATE OR REPLACE Procedure save_action_details(
p_rowid IN VARCHAR2,
p_action IN VARCHAR2,
p_dyn_ref_path IN VARCHAR2,
p_dyn_page_url IN VARCHAR2)
is
l_sto_session xxxxx.wwsto_api_session;
begin
l_sto_session := xxxxx.wwsto_api_session.load_session(
p_domain => 'DynStore',
p_sub_domain => 'DynStore_' || p_dyn_ref_path
l_sto_session.set_attribute(
p_name => 'rowid',
p_value => p_rowid
l_sto_session.set_attribute(
p_name => 'action',
p_value => p_action
l_sto_session.save_session;
htp.init;
owa_util.redirect_url(p_dyn_page_url);
end save_action_details;
Explaination: The above procedure creates a session and keeps the rowid and action in the session. This information is used by the below dynamic form to perform the necessary action. In our exampl, the action is always going to be delete so you may go ahead and hard code it, else leave it as it is.
4. Grant execute privilege on the procedure "save_action_details" to public.
sql> grant execute on save_action_details to public;
5. Create your Dynamic page.
a) In HTML code section have the below code. This code shows some columns from the table and "update" and "delete" buttons to perform the respective action.
<ORACLE>select empno,ename,rowid,
'<input type="button" value="Update" onClick="doAction(this.form,''UPD'',''xxx'','''
|| xxxxx.wwv_standard_util.url_encode(rowid) || '''); tWin();">
<input type="button" value="delete" onclick="doAction(this.form,''DEL'',''' || rowid || ''',''xxx'');">' Action
from yyyyy.emp</ORACLE>
b) In additional pl/sql code section of dynamic page, have the below pl/sql block "in after displaying the header" section.
declare
l_sto_session xxxxx.wwsto_api_session;
l_del_rowid varchar2(20);
l_action varchar2(10);
begin
htp.comment('User code starts here ...');
htp.p('<script>');
htp.p('var winHandle;');
htp.p('
function doAction(formObj, action, rowid, erowid)
if (action == "UPD")
var formURL = "' || xxxxx.wwctx_api.get_proc_path('wwa_app_module.link?p_arg_names=_moduleid&p_arg_values=<<module_id_of_form>>&p_arg_names=_rowid&p_arg_values=') || '" + erowid;
winHandle = window.open(formURL, "winDynUpd", "width=750,height=500,resizable=yes");
else
formObj.p_rowid.value = rowid;
formObj.p_action.value = action;
formObj.submit();
function tWin() {
if (winHandle.closed) {
document.location = document.location;
else {
setTimeout("tWin()", 500);
htp.p('</script>');
htp.p('<form name="dynRowProcess" method="POST" action="'
|| xxxxx.wwctx_api.get_proc_path('save_action_details','yyyyy')
|| '">');
htp.p('<input type="hidden" name="p_rowid">');
htp.p('<input type="hidden" name="p_action">');
htp.p('<input type="hidden" name="p_dyn_ref_path" value="' || p_reference_path || '">');
htp.p('<input type="hidden" name="p_dyn_page_url" value="' || p_page_url || '">');
l_sto_session := xxxxx.wwsto_api_session.load_session(
p_domain => 'DynStore',
p_sub_domain => 'DynStore_' || p_reference_path
l_del_rowid := l_sto_session.get_attribute_as_varchar2('rowid');
l_action := l_sto_session.get_attribute_as_varchar2('action');
if l_action = 'DEL' then
delete from yyyyy.emp
where rowid = l_del_rowid;
end if;
end;
Explaination: The session information (rowid and action) stored by "save_action_details" procedure is retrieved by the dynamic page and is used to delete the record.
6. Once you are through with the above steps, test it by placing the above "dynamic page" portlet on a page.
a) When you click on delete button the record gets deleted and the automatically refreshed page will not show the deleted record.
b) On clicking update button, a form will appear. do the necessary modifications in data and click update. the data in the form gets updated. Once you close the form the dynamic page gets refreshed automatically and it will show you the updated information.
Similar Messages
-
How to share music between my ipad and iPhone
How to share music between iPad and iPhone
Sync both devices to the same iTunes Library on your computer. Or just re-download iTunes Store purchased music from the Purchased tab in iTunes using the same AppleID.
-
How to share calendars between lumia 920 and 820?
Hi
I´m having problems sharing calnedars between my 920 and my wifes 820.
They both use @hotmail calendars as a default.
I first tried to send her an invite to a meeting I created and noticed that it uses @gmail account picked up from facebook as a default so I added her @hotmail account to her contact info.
The invite still doesn´t arrive.
Is it supposed to arrive as an invitation to the phone or just as an email?
Next I tried to share our calendars at microsoft live but nothing happens even it says its sending the share invite.
Am I doing someting wrong or what?Hmm.. I tried to send an email to my @hotmail account to test it and it didn´t arrive so I checked the settings and it seems that my hotmail account is named @gmail.com. Probably cause I´ve used it to create the live account. I just thought that the hotmail account would automatically be named @hotmail. Now I can´t do pretty much anything with it since it doesn´t even let me access to gmail account when I try to link them.
Do I have to close the whole account to get this working or what? I´ve used the gmail address to create a microsoft account a long time ago and the address can´t be changed anymore.
I don´t even need a hotmail address but I understood that it is needed to get the calendar working in the phone? -
How to share variable between jsp and JSF?
hi:
I have code :
<h:dataTable binding="#{Tables.dataTable}" value="#{Tables.query}" var="currentRow">
<h:column>
<h:outputText value="#{currentRow['factorycode']}"/>
</h:column>
<%
//here I want get upon variable currentRow and process some field.
// but how java code I can get the currentRow,
//currentRow is a ResultSet object
%>
</h:dataTable>
thanksEL cannot pick up scripting variables. It picks up attributes from scope only.
Similarly it doesnt set any scripting variables too.
<%
int g_nAge=12;
pageContext.setAttribute ("g_nAge", new Integer(g_nAge));
%>
${g_nAge}cheers,
ram. -
HI, I want to write a program with two classes, and there is a variable that should be shared between these two classes. I don't know how to realize the sharing. Thanks
Here you go:class A {
// whatever type T is ...
private T sharedVariable;
// get/set it
public void setSharedVariable(T that) { sharedVariable= that; }
public T getSharedVariable() { return sharedVariable; }
// etc. etc.
class B {
private A a;
// pass the stuff to be shared ...
public B(A a) { this.a= a; }
// get/set it
public void setSharedVariable(T that); { a.setSharedVariable(that); }
public T getSharedVariable() { return a.getSharedVariable(); }
// etc. etc.
}kind regards,
Jos -
How to share photos between macbook air and iphone5s
What is the easiest way to transfer photos from my iphone 5s to my macbook air, wirelessly. I have wifi in the house and not really sure how to use the icloud. Thoughts? Thank you so much.
Hi there Braeth,
There are a couple of ways of accomplishing this. You can either sync them directly to your computer via iTunes, or use iCloud to sync your photos via PhotoStream. I have linked some resources below for how to get everything set up.
iTunes: Syncing photos
http://support.apple.com/kb/HT4236
iCloud: My Photo Stream FAQ
http://support.apple.com/kb/HT4486
iCloud: Set up Photo Stream
http://support.apple.com/kb/ph2605
-Griff W. -
Using HttpServletRequest object to share variables between static methods.
Does anyone know of the overhead/performance implications of using the HttpServletRequest object to share variables between a static method and the calling code?
First, let me explain why I am doing it.
I have some pagination code that I would like to share across multiple servlets. So I pulled the pagination code out, and created a static method that these servlets could all use for their pagination.
public class Pagination {
public static void setPagination (HttpServletRequest request, Config conf, int totalRows) {
int page = 0;
if (request.getParameter("page") != null) {
page = new Integer(request.getParameter("page")).intValue();
int articlesPerPage = conf.getArticlesPerPage();
int pageBoundary = conf.getPageBoundary();
int numOfPages = totalRows / articlesPerPage;
// Checks if the page variable is empty (not set)
if (page == 0 || (page > numOfPages && (totalRows % articlesPerPage) == 0 && page < numOfPages + 1)) {
page = 1; // If it is empty, we're on page 1
// Ex: (2 * 25) - 25 = 25 <- data starts at 25
int startRow = page * articlesPerPage - (articlesPerPage);
int endRow = startRow + (articlesPerPage);
// Set array of page numbers.
int minDisplayPage = page - pageBoundary;
if (minDisplayPage < 1) {
minDisplayPage = 1;
int maxDisplayPage = page + pageBoundary;
if (maxDisplayPage > numOfPages) {
maxDisplayPage = numOfPages;
int arraySize = (maxDisplayPage - minDisplayPage) + 1;
// Check if there is a remainder page (partially filled page).
if ((totalRows % articlesPerPage) != 0) arraySize++;
// Set array to correct size.
int[] pages = new int[arraySize];
// Fill the array.
for (int i = 1; i <= pages.length; i++) {
pages[i - 1] = i;
// Set pageNext and pagePrev variables.
if (page != 1) {
int pagePrev = page - 1;
request.setAttribute("pagePrev", pagePrev);
if ((totalRows - (articlesPerPage * page)) > 0) {
int pageNext = page + 1;
request.setAttribute("pageNext", pageNext);
// These will be used by calling code for SQL query.
request.setAttribute("startRow", startRow);
request.setAttribute("endRow", endRow);
// These will be used in JSP page.
request.setAttribute("totalRows", totalRows);
request.setAttribute("numOfPages", numOfPages);
request.setAttribute("page", page);
request.setAttribute("pages", pages);
}I need two parameters from this method (startrow and endrow) so I can perform my SQL queries. Since this is a multithreaded app, I do not want to use class variables that I will later retrieve through methods.
So my solution was to just set the two parameters in the request and grab them later with the calling code like this:
// Set pagination
Pagination.setPagination(request, conf, tl.getTotalRows());
// Grab variables set into request by static method
int startRow = new Integer(request.getAttribute("startRow").toString());
int endRow = new Integer(request.getAttribute("endRow").toString());
// Use startRow and endRow for SQL query below...Does anyone see any problem with this from a resource/performance standpoint? Any idea on what the overhead is in using the HttpServletRequest object like this to pass variables around?
Thanks for any thoughts.You could either
- create instance vars in both controllers and set them accordingly to point to the same object (from the App Delegate) OR
- create an instance variable on the App Delegate and access it from within the view controllers
Hope this helps! -
Share variables between JSP and Classes
Hello !
Is there any way to share the same variables between JSP�s and Classes?
For example...
I have 20 variables in a JSP page (with values, like constants...) and I want to view their contents inside the classes...
Is there any way? Maybe a import or something like this...
Thanks,
Igor.If you search the forums you will find many answers to your questions. You can also try the servlet and JSP short courses listed below;
Here is lthe link that will take you to the Java.sun.com Tutorial pages.
http://developer.java.sun.com/developer/onlineTraining/
Here is a tutorial on Servlets
http://developer.java.sun.com/developer/onlineTraining/Servlets/Fundamentals/contents.html
Here is the tutorial on the JSP
http://developer.java.sun.com/developer/onlineTraining/JSPIntro/contents.html -
I tried to configure 2 windows users accounts using a single library per the instructions in HT1203. My iTunes library is on an external drive. I cannot get this to work. Any suggestions?
To give other users read-only access to your iTunes library, use the Sharing features of iTunes. Sharing works over the local network as well as on the same computer. See the built-in help for details.
If you want to give full read/write access to more than one user, see the support article linked below.
iTunes: How to share music between different accounts on a single computer
There is a way to share the library without moving it to a secondary volume. If you really need to do that, ask for instructions. -
I have 2 profiles on one computer. How to share music between the 2 separate profiles in iTunes?
iTunes: How to share music between different accounts on a single computer
This might help. info provided by 'b noir'
iMoz -
How to share music between different accounts on a single computer
I am trying to share music on my Mac between two different iTunes accounts. Can this be done?
iTunes: How to share music between different accounts on a single computer - http://support.apple.com/kb/HT1203 - relocating iTunes' media folder to a shared area but leaving separate library files - extra tip at https://discussions.apple.com/message/17331189
-
i have tried this 6+ times to "How to share music between different accounts on a single computer" on my wifes mac and can not get it to work!! On my PC no problem but on the MAC it will not work, follow the instructions to the T but no go????
It is almost as if the program does not exist on my computer. If I search for it, the only thing that comes up is the installer. I cannot find it anywhere despite the fact I have installed it numerous times, uninstalled it and conducted a fresh install, and the Adobe website checks says that it is installed.
-
How to define variables in toad sql script editor - newbie
I have just pull out the script of a Function and want to run it on toad SQL editor.
I am little bit confused how to define the VARIABLEs here in toad SQL editor to run my script.
SELECT
NVL(SUM(debit), 0) - NVL(SUM(credit), 0)
INTO l_accountBalance
FROM
GLP_VoucherMaster vm
INNER JOIN GLP_VoucherDetail vd ON vm.GLP_VoucherMaster_ID = vd.GLP_VoucherMaster_ID
INNER JOIN GLP_ChartOFAccounts coa ON vd.GLP_ChartOfAccounts_ID = coa.GLP_ChartOfAccounts_ID
WHERE
vm.isActive = 'Y' AND vd.isActive = 'Y'
-- *** how to define variables in toad sql script editor ***
AND vm.voucherDate < p_cDate
AND coa.AccountCode LIKE p_accountCode || '%';
Thanks
w\Just prefix with a colon (:)
SELECT NVL (SUM (Debit), 0) - NVL (SUM (Credit), 0)
INTO L_accountbalance
FROM Glp_vouchermaster Vm
INNER JOIN
Glp_voucherdetail Vd
ON Vm.Glp_vouchermaster_id = Vd.Glp_vouchermaster_id
INNER JOIN
Glp_chartofaccounts Coa
ON Vd.Glp_chartofaccounts_id = Coa.Glp_chartofaccounts_id
WHERE Vm.Isactive = 'Y'
AND Vd.Isactive = 'Y'
AND Vm.Voucherdate < :P_cdate
AND Coa.Accountcode LIKE :P_accountcode || '%';
/:p -
How can I share photos between my iphone and ipad?
I want to automatically share photos between my iPhone and iPad. I use iCloud and I setup Photo Stream but my photos are not moving from one device to the other. My goal is to have all my photos on both devices- automatically. How can I accomplish this?
Thank you!Photos will Not go between iPad & iPhone..they have to go thro' iCloud as a provider or sync via your computer individually...you need Wireless on both or a direct USB connection..
On each iPad and iPhone you can initialize via the Summary/Photos when they are connected via iTunes.. -
How can I share data between WinXP Pro and Mac OS 10.8.3 via wifi
How can I share data between WinXP Pro and Mac OS 10.8.3 via home wifi.
MartyP wrote:
Or is there a problem with both OS's writing stuff to the
~/Home/Library folder that may be incompatible?
Yes, big time. Mail, for sure, has a different file/folder structure, and would not be happy.
Plus, a number of apps (Apple and 3rd-party) are "Sandboxed." That's a security feature, to prevent malware or bad coding from affecting things it shouldn't. Some of their files, including the preferences files, aren't even stored in the same places!
Or to other places I'm not aware of?
Probably. If you have two versions of the same app, they may or may not expect the same data setup.
To have one User folder for both OS's would save a lot of drive space
Not if you use some or all of woodmeister50's suggestions.
But I'm also not sure how I'd use Time machine with such a set up.
Just as you do now. By default, Time Machine backs-up everything (except things like system work files, most caches and logs, trash) for all users and all internal drives & partitions. By default, it excludes external drives.
You can change those defaults, of course, via TM Preferences > Options.
See Time Machine - Frequently Asked Question #32 for details and considerations of multiple drives.
Presently I backup with . . . clones to other HD's
Good. Yes, clones are different. You need multiple "tasks" to back up multiple drives/partitions. But once set up, that shouldn't be a big deal.
Maybe you are looking for
-
Third party contact form widgets no longer working with upgrade - PHP errors
PHP seems to be even more screwed up with the latest update/upgrade to Muse. The previous upgrade started producing the following error message when I uploaded my site via FTP: "1 Warning - Connection to PHP file failed. Unable to check if this web
-
Using Motion 5 templates with other programs
Can motion 5 transitions, titles, lower thirds, etc. be used in a program other than Final Cut Pro in any useful way? Adobe Premiere Elements?
-
WiFi Grayed, Bluetooth looping
I have my iPhone WiFi grayed almot all the time, and Bluetooth looping for a long times, sometimes it take a day to go back to off or on state. I thought that the problem began with updating to iOS 7.0.6, but I wasn't using WiFi & Bluetooth before t
-
Hello, I've been having some issues with some MSO image sequences in my article. I have a few autoplay MSO image sequences that works perfectly in the desktop viewer, but won't seem to play on the iPad. I have Adobe Content Viewer v32.4.2. The weird
-
As I can capture or recognize a column selected in a ALV ?