Home » Developer & Programmer » Application Express, ORDS & MOD_PLSQL » When Button Pressed in Apex (APEX 4)
When Button Pressed in Apex [message #517083] Fri, 22 July 2011 06:51 Go to next message
magnetic
Messages: 324
Registered: January 2003
Senior Member
Hi there,

I was trying to built a forms-when-button-pressed in apex but it seems a little complicated then i had expected.

I'll be appreciated if one could help me with the next situation:

I have 2 regions:
Reion 1: html type containing some items and buttons (controblock)
Region2: report type containing 1 databasetable to query

Two items on region 1 wich are initiated with numeric values by a before header proces.
First item contains the value of year and the other the weeknumber (for example year=2011 and weeknumber=29).
I have also created two buttons in region 1 named "previous" and "next" to change the values of these item.

When button "previous" pressed, i want to call a database procedure wich gives me back the year and weeknumber of the previouse week and requerys the table in region 2
[year= 2011 and weeknumber = 28]

The same for the button "next" wich will show the data for the next week [year= 2011 and weeknumber = 30]

Thanks for your help!


Re: When Button Pressed in Apex [message #517098 is a reply to message #517083] Fri, 22 July 2011 08:27 Go to previous messageGo to next message
c_stenersen
Messages: 255
Registered: August 2007
Senior Member
What is your difficulty? And what have you tried so far? Updating the two values can easily be done with an after submit process, you branch back to the same page, and when the page is reloaded the report will show the query with the new values.

What do you mean by week number? The oracle one (week one starting Jan 1st, so not always on a Monday, and ending Jan 7th. WW in the to_char format) or the ISO week number (The one you often see in calendars, starting with a Monday, and where week 1 is the week containing Jan 4th. IW in the to_char format)?
http://en.wikipedia.org/wiki/Week_number#Week_numbering
Re: When Button Pressed in Apex [message #517125 is a reply to message #517098] Fri, 22 July 2011 14:27 Go to previous messageGo to next message
magnetic
Messages: 324
Registered: January 2003
Senior Member
Thanks for your reply,

The difficulty is that i tried some ways to get what i want
- dynamic action triggerd by the button
- computation
- process

During all these tryouts i didnt see the values returned bij the databaseprocedure in my 2 items.

So your solution is to make an after regions proces and link this to the button? or should the button submit first then the proces will run automatically?
The link between submit,proces and branche back is not clear yet.

What should be the button properties to submit and also the properties of the 2 items?
I think my properties are not correct because the itemvalues dont change according to me, or they might cange for a short time and the previous values are shown back after reloading the page.

This shouldnt be that difficult.
Documentation and examples on internet are too poor to solve this by my self.
Re: When Button Pressed in Apex [message #517159 is a reply to message #517125] Sat, 23 July 2011 07:37 Go to previous messageGo to next message
c_stenersen
Messages: 255
Registered: August 2007
Senior Member
The properties of the items can be whatever you like, but make sure that any "source value or expression" you might have set has as a condition to only use it when the value is null.

For the buttons set "Action" to be submit page, not redirect.

Make an after submit process, and under conditions you choose "when button pressed" and your button. In this process you set the values of your items.

You then create a branch, "on submit, after processing", and as the target page you give in the number of the page you are currently editing. So say that the page with your items and report are on is page 2, then you choose 2 as the target. It might be wise as well to tell it to reset the pagination since your query will change and the result set will change. (If you had pagination of 15 rows, and you were watching rows 16 to 30 of your report, then pressed the button, and the new result set contains less than 15 rows it would not display properly) Here as well you put as a condition the button. (But don't list your page in the "clear cache" option when branching. This will clear the values of your items again.)

For both of these you can use a single condition if you want the same process/branch to be run for both your next and your previous button (rather than creating two processes and two branches). Then you for the condition remove the "when button pressed" choice, and choose "request is contained within expression 1" as the condition type. Then in expression 1 you write PREVIOUS,NEXT

Unless you have any other processes or computations on your pages operating on these items, the items should then stay the way you set them in your process. When you enter the page again the report will show the results of the query using the new values.

Good luck Smile
Re: When Button Pressed in Apex [message #517299 is a reply to message #517159] Mon, 25 July 2011 05:08 Go to previous message
magnetic
Messages: 324
Registered: January 2003
Senior Member
Yes, it works Smile
Thanks for your time and explanation
Previous Topic: Oracle APEX experiences
Next Topic: Pushing event to client applications
Goto Forum:
  


Current Time: Thu Mar 28 05:20:38 CDT 2024