Sunday, June 8, 2008

Undocumented Oracle Application Express Text Messages

Hi,

A lot of developers create some JavaScript function, for translating messages, or make their own notifications, object names, error handling etc., instead of using regular APEX messages. That’s why I’d like to post some undocumented Oracle Application Express Text Messages.

 

Name

Message Text

Place

INVALID_CREDENTIALS

Invalid Login CredentialsLogin Notification

WWV_FLOW_ITEM_HELP.NO_HELP_EXISTS

No help exists for this item.

Popup window for optional Label with help
LAYOUT.T_ALT_HELP

Help

Popup window for optional Label with help
CALENDAR_TYPECalendarCalendar Icon Hint
WWV_FLOW_UTILITIES.SHUTTLE_RESETResetShuttle Reset Hint
WWV_FLOW_UTILITIES.SHUTTLE_MOVE_ALLMove AllShuttle Reset Hint
WWV_FLOW_UTILITIES.SHUTTLE_MOVEMoveShuttle Reset Hint
WWV_FLOW_UTILITIES.SHUTTLE_REMOVERemoveShuttle Reset Hint
WWV_FLOW_UTILITIES.SHUTTLE_REMOVE_ALLRemove AllShuttle Reset Hint
WWV_FLOW_UTILITIES.SHUTTLE_TOPTopShuttle Reset Hint
WWV_FLOW_UTILITIES.SHUTTLE_UPUpShuttle Reset Hint
WWV_FLOW_UTILITIES.SHUTTLE_DOWNDownShuttle Reset Hint
WWV_FLOW_UTILITIES.SHUTTLE_BOTTOMBottomShuttle Reset Hint
FLASH_CHART.LOADING_DATA

Loading data...

Flash Chart Load Window
FLASH_CHART.WAITING

Loading data. Please wait.

Flash Chart Load Window

For more information look APEX View:

flows_030100.wwv_flow_messages$

Monday, February 18, 2008

Breaking the 32 character limit using OWA_TEXT

In this post discussed how to display text, from database into HTML Region, that has more than 32000 characters length.

There were a lot of ways. I think that the decision below is the most simple and clear.
For this purpose I use owa_text.multi_line data type.

This data type is a PL/SQL record that holds large amounts of text. The rows field, of type OWA_TEXT.VC_ARR DATA TYPE, contains the text data in the record.

TYPE multi_line IS RECORD (
rows vc_arr,
num_rows INTEGER,
partial_row BOOLEAN);

The function below, convert clob into owa_text.multi_line data type:


create or replace function clob_to_multi_line(v_clob clob) return owa_text.multi_line is
res owa_text.multi_line;
r_cnt integer;
rem integer;
b_pos integer;
b_siz integer;

begin
r_cnt := trunc(dbms_lob.getlength(v_clob) / 32767);

rem := mod(dbms_lob.getlength(v_clob), 32767);
b_pos :=
1;
for idx in
1..r_cnt loop
b_siz :=
32767;
dbms_lob.read(v_clob, b_siz, b_pos, res.rows(idx));
b_pos := b_pos + b_siz;
end loop;
res.num_rows := r_cnt;
if (rem >
0) then
dbms_lob.read(v_clob, rem, b_pos, res.rows(r_cnt +
1));
res.num_rows := res.num_rows +
1;
end if;
res.partial_row := false;
return res;

end clob_to_multi_line;

An example source of PL/SQL Dynamic Content Region:

declare
c clob;

begin
select
clob_column into c from table_of_clobs
where id=1594;
OWA_TEXT.PRINT_MULTI(clob_to_multi_line(c));
end;


That’s it.

Tuesday, January 22, 2008

Zapatec AJAX tree in APEX

In this post, I would like to demonstrate the way of using Zapatec AJAX tree in Apex.
From http://www.zapatec.com/ I downloaded the DHTML tree files.

After this, I applied some of them into my application. I decided to store them in my database, for maintainability.

There is the list of files that I used:
  • Java Script files
    • .. \zptree\src\tree.js
    • .. \utils\zapatec.js
  • CSS file
    • .. \zptree\themes\kde1.css
    • .. \zptree\themes\default.css
    • .. \zptree\themes\empty.css
    • .. \website\css\zpcal.css
    • .. \website\css\template.css
  • Images
    • Tree icons
      • .. \zptree\themes\kde1\folder_open.png
      • .. \zptree\themes\kde1\folder.png
      • .. \zptree\themes\kde1\document.png
    • Tree structure
      • .. \zptree\themes\img\fetching.gif
      • .. \zptree\themes\img\lines-b.gif
      • .. \zptree\themes\img\lines-c.gif
      • .. \zptree\themes\img\lines-s.gif
      • .. \zptree\themes\img\lines-t.gif
      • .. \zptree\themes\img\lines-v.gif
      • .. \zptree\themes\img\minus.gif
      • .. \zptree\themes\img\plus.gif
      • .. \zptree\themes\img\zpempty.gif

I imported it using Shred Documents -> Static Files -> Create
Next step, was adding css and javascript files to HTML Header of my page:
After that I changed all paths, that is used in css and javascripts to APEX ‘paths’, for example:
Original kde1.css

div.tree-item td.customIcon {
background: url("kde1/document.png") no-repeat 0 50%;
}

div.tree-item-expanded td.customIcon {
background: url("kde1/folder_open.png") no-repeat 0 50%;
}

div.tree-item-collapsed td.customIcon {
background: url("kde1/folder.png") no-repeat 0 50%;
}

APEX compatible:

div.tree-item td.customIcon {
background: url("wwv_flow_file_mgr.get_file?p_security_group_id=948527760686885&p_flow_id=100&p_fname=document.png") no-repeat 0 50%;
}

div.tree-item-expanded td.customIcon {
background: url("wwv_flow_file_mgr.get_file?p_security_group_id=948527760686885&p_flow_id=100&p_fname=folder_open.png") no-repeat 0 50%;
}

div.tree-item-collapsed td.customIcon {
background: url("wwv_flow_file_mgr.get_file?p_security_group_id=948527760686885&p_flow_id=100&p_fname=folder.png") no-repeat 0 50%;
}

After that I was ready to create a dynamical content for my tree. There is the needed structure for tree content:

<ul id="tree_defaults">
<li>Group 1
<ul>
<li>Sub Group 1
<ul>
<li>Document 1</li>
<
li>Document 2</li>
</ul>
</li>
<
li>Sub Group 2
<ul>
<
li>Document 3</li>
</ul>
<
/li>
</ul>
<
/li>
<
/ul>

<script type="text/javascript">
var tree_defaults = new
Zapatec.Tree({
tree: "tree_defaults",
defaultIcons: "customIcon",
saveState: true,
saveId: "saveState",
expandOnLabelClick: true,
highlightSelectedNode: true
});

</script>

In my case, I have to create content from two tables. One is the table of ‘groups’, another is the table of ‘documents’.


There is the source code of tree generating procedure:

function enum_documnet_tree (v_session integer) return varchar2
is
res varchar2(32000);

procedure add_str(v_str varchar2) is
begin
res := res || v_str || chr(10);
end;


procedure add_group(v_nid integer) is
v_name varchar2(256);
begin
select cname into v_name from group_table where nid = v_nid;
add_str('
<li>'||v_name);
add_str('<ul>');
for rec in (select nid, cname from group_table
where nparent_group = v_nid
order by 2) loop
add_group(rec.nid);
end loop;
for o_rec in (select o.cname, o.nid from documents o where ngroup = v_nid) loop

add_str('<li><a href="f?p=100:19:'||v_session||'::NO::P19_DOCUMENT_ID:'||o_rec.nid||'">'||o_rec.cname||'</a></li>');
end loop;
add_str('
</ul>');
add_str('
</li>');
end;
begin
res := '
<ul id="tree_defaults">';

for m_rec in (select nid from group_table where nparent _group is null) loop
add_group(m_rec.nid);
end loop;
for o_rec in (select o.cname, o.nid from documents o where ngroup is null) loop
add_str('
<li><a href="f?p=100:19:'||v_session||'::NO::P19_DOCUMENT_ID:'||o_rec.nid||'">'||o_rec.cname||'</a></li>');
end loop;
add_str('
</ul>');
add_str('
<script type="text/javascript">
var tree_defaults = new Zapatec.Tree({
tree: "tree_defaults",
defaultIcons: "customIcon",
saveState: true,
saveId: "saveState",
expandOnLabelClick: true,
highlightSelectedNode: true
});

<
/script>');
return res;
end;


Finaly I created a hidden item :P19_TREE. HTML region with source:
htp.p(:P19_TREE);

And process PL/SQL anonymous block (On Load – Before Header):
:P19_TREE:= enum_documnet_tree(:SESSION);

That’s it!

P.S. If you want to use this AJAX component, you have to read a Zapatec tree license agreement on http://www.zapatec.com/website/main/products/prod3/license.jsp

Google