Browsing "Older Posts"

APEX "Display as Text" items with border and background-color

Von Tobias Arnhold → 10.26.2008
I don't know if you have noticed it yet. But the behavior of "Text Field (Disabled, save state)" items show up different from Firefox to IE or Opera. In Firefox (what I think looks much more standard like) the background color of the item value is gray and in all other browsers its white.

I couldn't find any solution for this item type. But I found another way to let a value look gray in all browsers using the
"Display as Text" item.

How to:
Create item as: "Display as Text (saves state)"
Edit item > Element > Element Table Cell Attributes
style="border: 1px solid rgb(204, 204, 204); width: 80px; background-color: rgb(225, 225, 225); padding: 2px;"
To see in an example app: http://apex.oracle.com/pls/otn/f?p=28737:6

Here are the different browser views (more or less adjust to FF3):

Internet Explorer 7:
Opera 9.51:
Internet Explorer 6 (with MultipleIE):
Firefox 3:

It's crazy how different such small details can be...
APEX-AT-WORK no image

APEX Interactive Reports with dynamic filters

Von Tobias Arnhold → 10.20.2008
A couple of days ago I worked with dynamic filters in Interactive Reports (In my case: filters which get created at the page start). I used them in pop up pages to show up just a couple of rows depending on the clicked value.

I created an example: http://apex.oracle.com/pls/otn/f?p=28737:4

I must say I couldn't fix that problem myself but with the terrific APEX community I found a solution.
Look at the whole entry: Set Interactive Report in popup with start search value and submit
Thanks again to Andy who made this useful tip possible.

How to do it?
In your pop up site where your Interactive report is go
Home>Application Builder>Application 28737>Page 5>Edit Page> HTML Header
and add this javascript.


<script language="JavaScript" type="text/javascript">

function set_ir_search_val() {
init_gReport();
var v_stop_js = document.getElementById('P5_STOP_JS');
if (v_stop_js.value != 1) {
var v_page = 'P4_SELECT';
var v_from = opener.document.getElementById(v_page);
var v_to = document.getElementById('apexir_SEARCH');
v_to.value = v_from.value;
v_stop_js.value = 1;
gReport.search('SEARCH');
}
}
addLoadEvent(set_ir_search_val);

</script>


Now go Home>Application Builder>Application 28737>Page 5>Edit Region> Region Footer
and add this script:


<script language="JavaScript" type="text/javascript">
set_ir_search_val();
</script>


Finally you need to create a hidden item, in my case: P5_STOP_JS.

I think when you use Interactive Reports a lot then this tip can be really useful for you.

Oracle SQL Developer Data Modeling database re-engineering with APEX features

Von Tobias Arnhold → 10.13.2008
I tried a bit around with the new Oracle SQL Developer Data Modeling. First I tried to get it to run on my USB stick without the included JRE.
After it started I used some APEX features to re-engineer a database model.

How to (tested on Windows XP):
1. Download the software and extract/install it
OSDM:
Download from: Oracle_Download_Page
If you use the usb stick copy it to: %YOUR_USB_DRIVE%\PortableApps\ORACLE\oracle_data_modeller

PStart (if you want to use your OSDM from an USB stick in a comfortable way)
Download from pegtop.net

2. Get the new OSDM to run

Either you start it from your standard installation, for example
C:\ORACLE\ADMINISTRATION\oracle_data_modeller\bin\osdm.exe

Or you create an own batch if you want to use it from an USB stick
REM Start osdm with nojre installed
REM (standalone from USB stick)


REM 1. set variables
REM 1.1 Path Variable
REM set PATH=\PortableApps\ORACLE\INSTANT_CLIENT;%PATH%

REM 1.2 ORACLE_HOME variable
REM set ORACLE_HOME=\PortableApps\ORACLE\INSTANT_CLIENT

REM 1.3 JAVA variable
set PATH=\PortableApps\RUNTIME\JRE\bin;%PATH%
set JAVA_HOME=\PortableApps\RUNTIME\JRE\bin

REM 1.4 TNS_ADMIN variable
REM set TNS_ADMIN=\PortableApps\ORACLE\INSTANT_CLIENT

REM 1.5 NLS_LANG Variable
REM set NLS_LANG=German_Germany.WE8MSWIN1252

REM 2. Connect app path
cd \PortableApps\ORACLE\oracle_data_modeller\bin

REM 3 Import java files into path variable
set cwdcp=..\conf
set cwdcp=%cwdcp%;..\lib\osdm.images.jar
set cwdcp=%cwdcp%;..\lib\osdm.exports.jar
REM this string you need to add
REM if you create it from the Linux script

set cwdcp=%cwdcp%;..\lib\osdm.imports.jar
set cwdcp=%cwdcp%;..\lib\osdm.sets.jar
set cwdcp=%cwdcp%;..\lib\osdm.model.jar
set cwdcp=%cwdcp%;..\lib\osdm.gui.jar
set cwdcp=%cwdcp%;..\lib\osdm.utils.jar
set cwdcp=%cwdcp%;..\lib\log4j.jar
set cwdcp=%cwdcp%;..\lib\lf\jlfgr.jar
set cwdcp=%cwdcp%;..\lib\poi\poi.jar
set cwdcp=%cwdcp%;..\lib\jimi\JimiProClasses.jar
set cwdcp=%cwdcp%;..\lib\jdbc\oracle\ojdbc5.jar
set cwdcp=%cwdcp%;..\lib\oracleaw\awxml.jar
set cwdcp=%cwdcp%;..\lib\oracleaw\olap_api.jar
set cwdcp=%cwdcp%;..\lib\oracleaw\xmlparserv2.jar
set cwdcp=%cwdcp%;..\lib\ohj\help4.jar
set cwdcp=%cwdcp%;..\lib\ohj\ohj-jewt.jar
set cwdcp=%cwdcp%;..\lib\ohj\oracle_ice.jar

REM 4. start application
java -Xmx1024M -Xms258M -classpath %cwdcp% oracle.dbtools.crest.swingui.ApplicationView

3. Create DDL with APEX

Go Home > Utilities > Generate DDL
Select your schema
Under "Object Type" click on "Check all" and Output to "Save As Script File"
Now click "Generate DDL" and give it a name like NEW_DDL_SCRIPT

Download your generated script: Home > SQL Workshop > SQL Scripts > Script Editor
Click on your script and download it as "NEW_DDL_SCRIPT.sql".

4. Integrate DDL
Start the OSDM (via batch or the osdm.exe)
File > Import > DDL File


Select your APEX generated DDL file
Select your database version, for example: Oracle Database 10g
Import runs and log-file will be generated

Oracle SQL Developer Data Modeling Version: 1.5.1 Build: 518

Data Modeling Import Log
Date and Time: 2008-10-13 15:50:26
Design Name: test
RDBMS: Oracle Database 10g

All Statements: 75
Imported Statements: 75
Failed Statements: 0
Not Recognized Statements: 0

The generated model looked really well and I can only hope that this tool will be free at the end of the development.

APEX radio group with dynamic help text

Von Tobias Arnhold → 10.12.2008
I came across a problem with help text information for the values of a radio group (LOV). I wanted to pop up help information when you move over the output items of the radio group.

To include this ability you have to a enhance your LOV query.

Go Edit Page Item > List of Values > List of values definition:

select
('<span style="cursor:help" title="' || product_description || '">'
|| PRODUCT_NAME || '</span>') as show_value,
PRODUCT_ID return_value
from DEMO_PRODUCT_INFO
order by 1

It will look like:See it in action: http://apex.oracle.com/pls/otn/f?p=28737:3

There are a couple of other resources about this topic available:
Completely different example how to show up some help (Just click on a red text title):
APEX-AT-WORK no image

Advanced APEX trees

Von Tobias Arnhold → 9.26.2008
Last couple of weeks/days when i went through the Oracle APEX forum there was quite a lot of questions about the APEX trees.
I really worked a lot with them and want to describe how to use them.

1. This how to will base on the following table ddl:
CREATE TABLE  "LOG_SYSTEMS"
( "S_ID" NUMBER NOT NULL ENABLE,
"S_NAME" VARCHAR2(100) NOT NULL ENABLE,
"S_DESCRIPTION_SHORT" VARCHAR2(100),
"S_PARENT" NUMBER NOT NULL ENABLE,
"S_RESPONSIBLE_DEPARTMENT" VARCHAR2(5),
"S_CONTACT_PERSON" VARCHAR2(100),
"S_TYPE" VARCHAR2(20)
CONSTRAINT "PK_S_ID" PRIMARY KEY ("S_ID") ENABLE
)
2. How does the standard SQL selection of a APEX tree look like

select "S_ID" id, -- Primary key
"S_PARENT" pid, -- Parent key
"S_NAME" name, -- Displayed value (node description)
'f?p=&APP_ID.:1:&SESSION.::NO::P1_SYSTEM:'||"S_ID" link, -- linked page
null a1,
null a2
from "#OWNER#"."LOG_SYSTEMS"

3. How to improve the displayed value (node)
You can concat several columns:
-- name with description
"S_NAME" || ' (' || "S_DESCRIPTION" || ')' AS name,

-- name with html (big)
'<b>' || "S_NAME" || '</b>' AS name,

-- name with icon in front of it
'<img src="#WORKSPACE_IMAGES#tree_group.png" border="0" style="vertical-align:middle" alt="Group">&nbsp ' || "S_NAME" AS name,

-- Using of the case command to see different node values
CASE
WHEN "S_TYPE" = 'GROUP' THEN '<b>' || "S_NAME" || '</b>'
WHEN "S_TYPE" = 'SYSTEM' THEN "S_NAME" || ' (' || "S_DESCRIPTION" || ')' END AS name,

4. How to use the link column
-- Standard link column would link to page 1 and overwrite the
-- value of :P1_SYSTEM
'f?p=&APP_ID.:1:&SESSION.::NO::P1_SYSTEM:'||"S_ID" link,

-- Using several values to overwrite in page
'f?p=&APP_ID.:1:&SESSION.::NO::P1_SYSTEM,P1_S_NAME,P1_FROM_TREE:'|| "S_ID"||','||"S_NAME"||',YES' AS link,

-- Link to a specified page via node value
'f?p=&APP_ID.:' ||"S_ID" || ':&SESSION.::NO::' AS link,

-- Link to a specified page via node value and javascript
'javascript:change_page(' || "S_ID" || ')'

Go Edit Page > HTML Header
<script language="JavaScript" type="text/javascript">
function change_page(v_page) {
var v_url = 'f?p=&APP_ID.:' + v_page + ':&SESSION.::::';
window.location.href = v_url;
}
</script>

-- If you use your tree as a pop up tree and want to give back a node
-- value to the parent page with submit and close the pop up
-- page automatically afterward
-- Info: I used it as a self made pop up tree item
'javascript:close_page(' || "S_ID" || ',''' || "S_NAME" || ''')' AS link,

-- I also used a hidden item in the pop up page to fill with the parent
-- page id &P101_WHEREFROM.
Go Edit Page > HTML Header
<script language="JavaScript" type="text/javascript">
function close_page(v_id,v_value) {
var v_page = 'P' + '&P100_WHEREFROM.' + '_S_ID';
var v_page_display = 'P' + '&P101_WHEREFROM.' + '_S_NAME';
var l_field_id = opener.document.getElementById(v_page);
l_field_id.value = v_id;
if(l_field_id.getAttribute('onchange') || l_field_id.onchange) {l_field_id.onchange()}
var l_field_value = opener.document.getElementById(v_page_display);
l_field_value.value = v_value;
if(l_field_value.getAttribute('onchange') || l_field_value.onchange) {l_field_value.onchange()}
close();
window.opener.doSubmit('POPUP_RELOAD');
}
</script>

I used these examples in my application TIA: http://apex.oracle.com/pls/otn/f?p=25500:1
Login: guest Password: apexuser
Download it from: http://www.oracle-apex-award.de/TIA-Technische-Infrastruktur.70.0.html
The application is in German but the developments (used variables, hints) are made in English.

Hope you can use it in your application and of course you are welcome http://www.blogger.com/img/blank.gifto give me some feedback.

Update 12.09.2011:
The example application doesn't work anymore. I currently work on a new version which includes the new APEX tree as well:
http://apex-at-work.blogspot.com/2011/09/logbuch.html
I will try to extend the view of the standard APEX tree as well as I did with the old one. Of course I will write about it. :)

Update 26.09.2011:
I just saw a nice example application about APEX trees:
http://apex.oracle.com/pls/apex/f?p=36648:27
APEX-AT-WORK no image

APEX_MAIL with UTL_TCP under XE database

Von Tobias Arnhold → 9.24.2008
If you want to use the features of the UTL_TCP package you need to publish it to your APEX application user. (I tested it under APEX 3.1.2)

How to:

-- sqlplus
GRANT EXECUTE ON "SYS"."UTL_TCP" TO "APEX_USER"

-- sqlplus
create or replace synonym UTL_TCP for SYS.UTL_TCP;

-- an APEX process procedur
-- apex_mail procedure call
apex_mail.send(
p_to => 'user@company.com',
p_from => 'info@company.com',
p_body => 'New message cerated from ' || :p1_user || '.' || utl_tcp.crlf ||
'Description: ' || utl_tcp.crlf || :p1_description,
p_subj => 'New message! ' utl_tcp.crlf);

-- push the e-mail queue for immediate delivery
wwv_flow_mail.push_queue(
P_SMTP_HOSTNAME => 'ip',
P_SMTP_PORTNO => 'port');

Update (08.09.2009):
There was a interesting question about the APEX_MAIL function and pushing the email queue in the Oracle forum which you may be interested on: apex mail - mail queue

APEX DoSubmit button with js before pl/sql processes

Von Tobias Arnhold → 9.17.2008
Sometimes you need to use javascript after click on a button before the APEX validations and processes starts.
(For example you have a report with editable fields and maybe a save button on every row. In these special cases you could need something like that.)

Go on edit Button > URL Redirect > change/add
Target is: URL
URL Target: javascript:BUTTON_ACTION();

Edit Page > HTML Header > add the new javascript

<script language="JavaScript" type="text/javascript">
function RR_ACTION_UPDATE()
{
// P1_ACTION field into JS variable

var l_field_id = document.getElementById("P1_ACTION");

// Now you a
re able to put in every type of code
// example: set value for field l_field_id.value =
// 'UPDATE';

// calculate: l_field_id.value = 5 + 5;


// doSubmit
action
doSubmit('DOSUBMIT');

}

</script>