Oracle APEX 5 Dynamic Action upon page load event does not work. What am i doing wrong? - sql

The program basically aims at retrieving some fields of a record and processing and displaying that on a textbox of static content region in apex 5
My database: LCD_MONItOR table
Interface :
PLSQL code that is supposed to execute on page load event.
Declare
lcd_id LCD_Monitor.LCD__NO%TYPE;
tag LCD_Monitor.ASSET_TAG%TYPE;
pp LCD_Monitor.PURCHASE_PRICE%TYPE;
sal LCD_Monitor.SALVAGE%TYPE;
ls LCD_Monitor.LIFE_SPAN%TYPE;
accm LCD_Monitor.ACCUMULATED_DEP%TYPE;
netbook Number;
currDep Number;
Begin
select LCD__NO, ASSET_TAG, PURCHASE_PRICE,SALVAGE, LIFE_SPAN,
ACCUMULATED_DEP into lcd_id, tag, pp, sal, ls, accm from LCD_MONITOR
where LCD__No='40';
:LCD_NO:=lcd_id;
:CURR_DEP:= (pp-sal)*(1/ls);
:TOT_DEP:= (pp-sal)*(1/ls)+accm;
:NBV:=pp-(pp-sal)*(1/ls)+accm;
End;
PS: I have returned the values to the textboxes in 'Affected Elements' Section in the properties.
But when the page is loaded, no values appear in the textboxes. Any help would be appreciated.

I'm not sure if I understood correctly what exactly are you doing. If you need just fill items with data, create a before header process (in Page Designer mode, it is in Pre-rendering -> Before Header. Write your code there, it should be enough.
If you want to do it in Dynamic Action (I wouldn't recommend this way), you need to create a Dynamic Action with Event - Page Load, which will contain a True Action with properties: Action - Execute PL/SQL Code, PL/SQL Code - your code and Items to Return - LCD_NO,CURR_DEP,TOT_DEP,NBV
But make sure your items really have such names, because by default APEX creates items with names like P10_LCD_NO, where 10 (for example) is a number of the page.

Instead of directly assigning a calculated value to the textfields items, I assigned them to a variable first then assigned variables to the items i.e
Before
:CURR_DEP:= (pp-sal)*(1/ls);
:TOT_DEP:= (pp-sal)*(1/ls)+accm;
:NBV:=pp-(pp-sal)*(1/ls)+accm;
Corrected
currDep:= (pp-sal)*(1/ls);
:CURR_DEP:= currDep;
tot:= (pp-sal)*(1/ls)+accm;
:TOT_DEP:=tot;
netbook:=pp-((pp-sal)*(1/ls)+accm);
:NBV:=netbook;

Related

Apex, Dynamic action, Confirm action, not picking up correct text - what am I missing?

I'm obviously missing something and hoping someone might be able to help.
I've an Interactive Grid, and a button.
When the button is pressed the dynamic action on the button has 2 steps.
Action 1 - Execute Javascript to take a value from one of the IG cells and put it into a page item.
Action 2 - Confirm Action - Are you sure you wish to delete &P10_JOB_ID.
I've made the page item, &P10_JOB_ID, visible and I can see the value has correctly been changed to the value from the IG.
I write P10_JOB_ID into a database table - I get the correct value
But the confirm message isn't picking up the correct value from P10_JOB_ID.
Namely it uses the value in P10_JOB_ID when the page starts, but then as I move around the IG pressing the button and changing the value of P10_JOB_ID, the text in the confirm message never changes.
Can anyone suggest what I might have missed, I'm baffled.
Thanks a lot
Substitutions like &P10_JOB_ID. are made when the page is rendered, not dynamically, so reflect the value at time of page load.
You will need to use Javascript to perform the conform action, something like:
apex.page.confirm ('Are you sure you wish to delete ' + $v('P10_JOB_ID') + '?', 'DELETE');
$v is an APEX Javascript function that returns the current value of a page item.
I used 'DELETE' as an example of a request value; you may want to do something different here.
Ok - having the setting of value and confirm as 2 separate actions is what causes the problem.
As per fac586
That is the expected behaviour. Static text substitutions are performed once during page show processing. They are not evaluated dynamically in the browser at runtime as values change.
Drop the second action and extend the first to display the confirm dialog using the apex.message.confirm JS API method, accessing the item value using the $v shorthand method.

Storing dynamic text in Selenium

I'm new to Selenium and had the following question about storing dynamic text...
In our web application, when a function is performed (i.e. transfer), a confirmation message is displayed (i.e. "function is completed. The reference number is #12345". The ref number is then displayed in a list with other ref numbers on another page. As part of my test, after the ref. number is generated, I would like to select from the list the ref number that was just generated.
Example
1 create item.
2 confirmation message displays
3 save ref number
4 navigate to other page which contains list of ref #s
5 select item from list that was just created (select using ref #)
Question: How do I save the ref number from the confirmation message so that I have Selenium select that number from the list of ref #'s?
Thanks,
D
Find out the identifier (CSS/XPath/etc.) of the UI element that displays the reference number, and then use the relatively getText() command. In Java,
String text = selenium.getText("your_identifier");

How to create Struts Drop down List?

I m new to struts.
I Want to add drop down in web page.That drop down should contain four values. The default and first value will be (Select).
I want to persist the selected value, when that form is opened again and while submitting, if user doesn't select any value from drop down (meaning the default value is present) I want to give an alert to the user and then not to allow a submit until till the user selects an option from the dropdown.
There is one action.java, form.java, javascript file and jsp file. In action.java, I m suppose to use ArrayList to hold different drop down values. How this can be done. please help me.
<s:select list="#{'':'Select', 'key1':'Value 1', 'key2':'Value 2'}" key="selectedValue"></s:select>
or you have a list object(id, value)
<s:select key="selectedValue" list="yourlists" headerKey="" headerValue="Select" listKey="id" listValue="value"/>
Firstly, you need to show your code here. If you are interested in tutorials then I'd suggest - VaanNila, a great place to learn struts framework. (Here is a link of select tag.)

dojox.grid.DataGrid: how to access data from a click event?

I'm using Dojo 1.5 (including dojox). I have a dojox.grid.DataGrid where each row represents a user. When I click a row, I want to redirect to a URL like /users/USER_ID. The user ID is one of the fields in the grid, so all I need to do in my onRowClick callback is to grab the user ID for the row that was clicked.
The click event contains a rowIndex property, and, indeed, I found a (rather old) post elsewhere that suggested I should be able to do:
var row = dijit.byId('grid').model.getRow(e.rowIndex);
/* (Then grab the 0th field of the row, which is the user ID.) */
(Sorry, I've since lost the URL.)
But my grid object has no model attribute. What's up with that? Has the API changed? (My grid certainly is populated with data, which I can see, click, sort by column, et cetera).
So I'm stuck for now. Note, BTW, that it won't work to use rowIndex to directly access the grid's underlying dojo.data.ItemFileReadStore. That's because the grid is sortable, so there's no guarantee that the grid's rows will be in the same order as the store's.
Any hints would be deeply appreciated. I hope that the question is clear, and sufficiently general that any answers can help others in my predicament. Many thanks.
I have a similar scenario and I grab the value like this:
onRowClick: function(e) {
open_link(my_grid._getItemAttr(e.rowIndex, 'object_path'));
}
In this case my_grid is a reference to the datagrid and object_path is the column where I store the path to the object. open_link is of course a custom function of mine that as it implies, requests a server path.
So just change the specifics to suite your case and you should be fine.

Question about oracle xe search query

this is my second time using ORACLE xe and Apex. Here is what I'm trying to do .. I'm trying to execute the following query SELECT * FROM EMPLOYEES WHERE JOB_TITLE = 'CLERK'
but not from sql command prompt but from gui/apex and here is how- I have created page one with one textfield and one submit button.
Now of course I'd type in the text field value CLERK and I'd like onclick on submit button that I be taken to page2 let say, and on that page2 to receive argument for the query. The query will be located at page2 of course.
I believe that this is fairly simple for someone who knows oracle, I know of course how I'd do this with PHP/Mysql its simple as it can be all I need is this :
#1 Get value from input
#2 Pass it to the next page using javascript or whatever
#3 Execute query on the next page using the value passed in where
Thank you, explanation tips hints link .. anything is welcome
You can refer to any item in an Apex application from any other page. For example, on page 1 you have an item P1_JOB_TITLE, then on page 2 you write a query like:
SELECT * FROM EMPLOYEES WHERE JOB_TITLE = :P1_JOB_TITLE;
(warning: make sure that page 1 doesn't have a "reset" process which would clear the value of the item when the page is submitted)
Note, however, that the item doesn't have to be on a different page if you don't want it to - you could have it on the same page as the report.