Browsing "Older Posts"

APEX-AT-WORK no image

Outlook calendar in APEX

Von Tobias Arnhold → 4.17.2009
Hi,
if you want to integrate your outlook calendar or some other oultook features into an APEX site use the following code in a HTML region.

<DIV STYLE="width:800px;height:400px">
<OBJECT classid=CLSID:0006F063-0000-0000-C000-000000000046
id=ViewCtlFolder
width="100%"
height="100%"
Codebase="http://activex.microsoft.com/activex/controls/office/outlctlx.CAB#ver=9,0,0,3203">
<param name="Namespace" value="MAPI">
<param name="Folder" value="Calendar">
<param name="Restriction" value="">
<param name="DeferUpdate" value="0">
</OBJECT>
</DIV>

Example page: http://apex.oracle.com/pls/otn/f?p=28737:8
More information to that topic:
http://blogs.tech-recipes.com/shamanstears/2008/04/15/outlook-creating-your-own-outlook-today-page/
http://www.outlookcode.com

That feature is just appropriable with the Internet Explorer.

Spacing APEX items

Von Tobias Arnhold → 3.13.2009
Did you ever experienced the problem when you have a couple of items in the same line/row in a HTML region and you have a select list (in the next row) which becomes so Hugh that the upper items places more and more to the right. It just looks ugly and the select list value
normally changes dynamically.
What to do?
First we need to bring a logical barrier in between the line breaks.
Using a "Stop and Start HTML Table" object in between text items and select list.
It will look like that:
Result: Just the text label is incorrect anymore.Now we have two choices:1. Using &nbsp object until it fits.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Text1:&nbsp;
Problem: The more text different there are, the more &nbsp you will need.

2. Creating a SPACER item
Create a new display only item called :P1_SPACER in front of the first text item.Now add the following text under "Element Table Cell Attributes" > style="width:200px"Edit the pixel value so that it fits into your page.

The region items will be listed like that:
In case you still have some problem with different browser presentations look at my last post.

Update 17.03.2009:
Just tested a really good hint from Patrick.
Using the ColSpan option in the select list item saves all other steps above. Set the value for ColSpan (in my case) to 3 and the same result appears. Good that I never stop learning...

Own browser check condition in APEX

Von Tobias Arnhold → 3.12.2009
The easiest way to check the browser type for conditional displaying
is to use one of the following conditions:
  • Client Browser: Mozilla, Netscape 6.x/7x or higher
  • Client Browser: Microsoft Internet Explorer 5.5,6.0 or higher
  • Client Browser: Other browsers (or older version)
That way is definitely the easiest one. But in case you have several display conditions you need to check or you want to use that check at another point (for example inside an pl/sql script) then you get some trouble.
I asked in the APEX forum for help and thanks to Andy he gave me a really good hint how to find a solution for that issue.
Forum link: http://forums.oracle.com/forums/message.jspa?messageID=3322457

In my case I wanted to use a condition inside the SQL statement of an updateable report. Because FF and IE displayed the report columns differently.

First I followed the hint from Andy and analyzed the OWA_UTIL output with the function PRINT_CGI_ENV().

BEGIN
OWA_UTIL.PRINT_CGI_ENV();
END;

The result for parameter HTTP_USER_AGENT (with FF) looks like that:

HTTP_USER_AGENT = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7 (.NET CLR 3.5.30729)

Next step was to get that output text into a variable. Function OWA_UTIL.GET_CGI_ENV('HTTP_USER_AGENT') provides the information.
I created a variable called :P1_BROWSER_TYPE and an initialization process to save the information in my variable.

IF :P1_BROWSER_TYPE NULL THEN
IF OWA_UTIL.GET_CGI_ENV('HTTP_USER_AGENT') LIKE '%MSIE 7.0%' THEN
:P1_BROWSER_TYPE := 'IE7';
ELSIF OWA_UTIL.GET_CGI_ENV('HTTP_USER_AGENT') LIKE '%MSIE 6.0%' THEN
:P1_BROWSER_TYPE := 'IE6';
ELSIF OWA_UTIL.GET_CGI_ENV('HTTP_USER_AGENT') LIKE '%Firefox/3%' THEN
:P1_BROWSER_TYPE := 'FF3';
ELSIF OWA_UTIL.GET_CGI_ENV('HTTP_USER_AGENT') LIKE '%Firefox/2%' THEN
:P1_BROWSER_TYPE := 'FF2';
ELSIF OWA_UTIL.GET_CGI_ENV('HTTP_USER_AGENT') LIKE '%Firefox/1%' THEN
:P1_BROWSER_TYPE := 'FF1';
ELSE
:P1_BROWSER_TYPE := 'UNKNOWN';
END IF;
END IF;

Now I created my updateable report with a CASE WHEN CHECK inside the SQL statement:

SELECT CASE :P1_BROWSER_TYPE WHEN 'FF3' THEN '<b><div style="width: 289px">Sum:</div></b>'
WHEN 'FF2' THEN '<b><div style="width: 289px">Sum:</div></b>'
WHEN 'FF1' THEN '<b><div style="width: 289px">Sum:</div></b>'
WHEN 'IE7' THEN '<b><div style="width: 247px">Sum:</div></b>'
WHEN 'IE6' THEN '<b><div style="width: 247px">Sum:</div></b>'
ELSE '<b><div style="width: 247px">Sum:</div></b>' END as "Sum",
...
Example app: http://apex.oracle.com/pls/otn/f?p=28737:7
Documentation link for the OWA_UTIL package: http://download-west.oracle.com/docs/cd/B12037_01/appdev.101/b10802/w_util.htm#997271
APEX-AT-WORK no image

Terrific Oracle forum exemplified by "wi (dd.mm.yyyy-dd.mm.yyyy)"

Von Tobias Arnhold → 2.20.2009
Did you ever had any problems with Oracle based issues like Database, APEX, Forms, SQL and so on? Of course you had.
Normally the Oracle Metalink is the first address for everybody who has a contract with Oracle. But in some cases the Oracle forum help is unbeatable.
What I mean is. Whenever you have a problem with SQL commands or APEX issues the fastest way to find a solution is to ask in the Oracle forums.

I want to bring up a special example I had. I needed some week and date values via a sql command for a month like that:
wi (dd.mm.yyyy-dd.mm.yyyy)
05 (01.02.2009-01.09.2009)
06 (02.02.2009-08.09.2009)
07 (09.02.2009-15.09.2009)
08 (16.02.2009-22.09.2009)
09 (23.02.2009-28.09.2009)

I couldn't fix it myself so I wrote a forum entry:
http://forums.oracle.com/forums/message.jspa?messageID=2842808
I got more then a tip I got a solution for the problem.

A couple of weeks later I just found out that the last week in February was missing. So I wrote a new post which was answered just a couple of hours later.
http://forums.oracle.com/forums/message.jspa?messageID=3279392

I think this type of help is sometimes more valuable then any GOLD support you can get. :D

By the way here is the solution for the problem: ;D

-- select all weeks for a year
select to_char(dt+(7*rn),'WW') ||' ('||
to_char(dt+(decode(rn,0,0,(7*rn)+1-offset))) ||'-'||
case when dt+(7*(rn+1))-offset > last_day(dt) then
last_day(dt) ||')'
else
dt+(7*(rn+1))-offset ||')'
end as show_value,
to_char(dt+(7*rn),'WW') as return_value
from (select to_date(mes||'2009','MMYYYY') as dt, to_number(to_char(to_date(mes||'2009','MMYYYY'),'D')) as offset
from dual, (select to_char(rownum, '00') mes from dual connect by rownum <= 12))
,(select rownum-1 rn from dual connect by rownum <= 6)
where trunc(to_date(dt+(decode(rn,0,0,(7*rn)+1-offset))), 'MM') = dt
order by dt, return_value asc
-- select all week for a month
select to_char(dt+(7*rn),'IW') ||' ('||
to_char(dt+(decode(rn,0,0,(7*rn)+1-offset))) ||'-'||
case when dt+(7*(rn+1))-offset > last_day(dt) then
last_day(dt) ||')'
else
dt+(7*(rn+1))-offset ||')'
end as show_value,
to_char(dt+(7*rn),'IW') as return_value
from (select to_date(02||2009,'MMYYYY') as dt from dual)
,(select to_number(to_char(to_date(02||2009,'MMYYYY'),'D')) as offset from dual)
,(select rownum-1 rn from dual connect by rownum <= 5)
where trunc(to_date(dt+(decode(rn,0,0,(7*rn)+1-offset))), 'MM') = dt
-- the way I use it in APEX
select to_char(dt+(7*rn),'IW') ||' ('||
to_char(dt+(decode(rn,0,0,(7*rn)+1-offset))) ||'-'||
case when dt+(7*(rn+1))-offset > last_day(dt) then
last_day(dt) ||')'
else
dt+(7*(rn+1))-offset ||')'
end as show_value,
to_char(dt+(7*rn),'IW') as return_value
from (select to_date(:P1_MONTH||:P1_YEAR,'MMYYYY') as dt from dual)
,(select to_number(to_char(to_date(:P1_MONTH||:P1_YEAR,'MMYYYY'),'D')) as offset from dual)
,(select rownum-1 rn from dual connect by rownum <= 5)
where trunc(to_date(dt+(decode(rn,0,0,(7*rn)+1-offset))), 'MM') = dt

Special thanks to BluShadow and Miguel Chillitupa!
APEX-AT-WORK no image

Set up column width in an APEX report (for Firefox)

Von Tobias Arnhold → 2.13.2009
Most of you would say: "Why is that so special? Just go to
Report Attributes>Column Attributes>Column Formatting>CSS Style and add for example: width:100px"

Like the help says:
"Use this attribute to apply a style to a column value. For example, setting this attribute to 'color:#FF0000;' will result in the following html being generated:
<span style="color:#FF0000">Sample Data</span>
This will change the text color of the column to red."

You all are right but there is a problem with Firefox which is ignoring this setting.
Why? Take a look here:
http://www.velocityreviews.com/forums/t163666-firefox-ignores-the-style-width-attribute-in-the-span-tag.html

How to fix that now? I use the div tag in my sql statement for the report:

SELECT '<b><div style="width: 150px; text-align: left">Employee no.: ' || "EMP"."EMPNO" ||
'</div></b>' as "EMPNO",
'<div style="border: 1px solid rgb(204, 204, 204); padding: 2px; width: 150px; background-color: rgb(225, 225, 225); text-align: center">' ||
"EMP"."ENAME" || '</div>' as "ENAME",
'<div style="border: 1px solid rgb(204, 204, 204); padding: 2px; width: 100px; background-color: rgb(225, 225, 225); text-align: center">' ||
"EMP"."HIREDATE" || '</div>' as "HIREDATE",
'<div style="border: 1px solid rgb(204, 204, 204); padding: 2px; width: 100px; background-color: rgb(225, 225, 225); text-align: center">' ||
"EMP"."SAL" || '</div>' as "SAL",
'<div style="border: 1px solid rgb(204, 204, 204); padding: 2px; width: 100px; background-color: rgb(225, 225, 225); text-align: center">' ||
"EMP"."COMM" || '</div>' as "COMM"
FROM "EMP"
-- </div> - div tag is needed to create the css style attributes
-- "width: 150px;" - for column width
-- "text-align: left" - for text alignment
-- "background-color: rgb(225, 225, 225)" - for column background color
-- "border: 1px solid rgb(204, 204, 204)" - for border color
-- "padding: 2px" - for empty place between text and border


Example application in action: http://apex.oracle.com/pls/otn/f?p=25472:30

Forum entry to it: http://forums.oracle.com/forums/thread.jspa?forumID=137&threadID=854151

Honestly I think there is another way to fix this issue which I don't know yet but I would really appreciate to get to know about it. :D

To all: Enjoy the weekend, have fun and DON'T think about the world economic crisis. :)
APEX-AT-WORK no image

Focus problem with IE6 and APEX_ITEM.SELECT_LIST_FROM_LOV

Von Tobias Arnhold → 2.12.2009
If you are using the SELECT_LIST_FROM_LOV item in your apex reports you may have noticed that you can get some trouble with the Internet Explorer 6.

For example your report includes 100 rows which are all displayed on one page and you must scroll up and down to reach all items. In case you have the focus on one of your select list items and set it from value x to y and immediately after that you want to scroll down. The cursor stays in the item and scrolls inside instead of outside the page.

This behavior just appears with IE6 all newer browser works after a standard behavior. After you selected an item value and you start scrolling, the page scrolls after your mouse movement.

How to fix this issue with IE6? You need to edit your SQL select statement for your report:

-- select statement with IE6 problems
select
b_id as "Book number",
'<b>'||b_name||'</b>' ||
' (' || b_description || ') ' as "Book name"
apex_item.SELECT_LIST_FROM_LOV(
1, -- p_idx
b_category_id, -- p_value
'LOV_BOOK_CATEGORIES', -- p_lov
'', -- p_attributes
'YES', -- p_show_null
'', -- p_null_value
'no book category selected', -- p_null_text
'', -- p_item_id
'' -- p_item_label)
as "Book category"
from books;

-- fixed select statement with attribute for wrong focus behavior
select
b_id as "Book number",
'<b>'||b_name||'</b>' ||
' (' || b_description || ') ' as "Book name"
apex_item.SELECT_LIST_FROM_LOV(
1, -- p_idx
b_category_id, -- p_value
'LOV_BOOK_CATEGORIES', -- p_lov
'onChange="body.focus()"', -- p_attributes
'YES', -- p_show_null
'', -- p_null_value
'no book category selected', -- p_null_text
'', -- p_item_id
'' -- p_item_label)
as "Book category"
from books;

You need to use onChange="body.focus()" in the attribute section.

Of course you can also use this functionality in a normal select list item.
Go Edit Page Item>Element>HTML Form Element Attributes
and add: onChange="body.focus()"
APEX-AT-WORK no image

Administration and development tools I work with

Von Tobias Arnhold → 2.09.2009
Hi all!
I wrote a lot about APEX the last couple of month. Now I want to write about the tools/applications I use to get these apps running and having always the full grip over it.

What main points should an application including to be usable in my eyes?
  • It should work for what I bought it "no more, no less"
  • It should be fast (During start up and use)
  • It should be always accessible better portable (like on an usb stick)
  • It should be intuitive and easy to use
  • It shouldn't cost to much (I mean thousands of €uros) or better be freeware or open source
Database administration tools:
Monitoring
  • LAB128 (Commercial) - One of the jewels: it fits to all main points I wrote before
Log file analysis
  • OraSentry (Charityware) - Small tool which shows you if your alertlog/database is in trouble
SQL and PL/SQL development tools:
  • PL/SQL Developer (Commercial) - In my eyes the best development tool for pl/sql programming
  • TORA (GPL) - This one (a tool with a long history) needs to be named too.
Database modeling tools:
  • DBSchema (Commercial) - A really good mix between price and performance
  • Schemester (Freeware) - I liked this one a lot unfortunately its not longer under development
Data mapping:
  • FlowHeater (Commercial) - A really good data mapping tool for an unbeatable price. It is still under development and unfortunately (until now) only in German available
HTML, CSS and JS development:
  • Notepad++ (GPL) - A must have for fast and easy programming
Website debugging tools:
  • Firefox - Of course a must have for all APEX developers
With these add ons:
  • Colorzilla
  • Firebug
  • Greasemonkey
  • IE Tab
  • Resizeable Textarea
  • Web Developer
Have fun trying them out and maybe some of you know other really good tools. Real jewels for the apex development community.

And of course I just write about them because I like them (and paid for them) and not because they paid for me. :D