Images and text on PSP page [message #256402] |
Sat, 04 August 2007 06:09 |
jelo
Messages: 3 Registered: August 2007
|
Junior Member |
|
|
I’ve got psp page like below:
<%@ page language="PL/SQL" %>
<%@ plsql procedure="srodek" %>
<html>
<head>
<title>IMG_7271</title>
<meta http-equiv="content-type" content="text/html; iso-8859-2">
<script type="text/javascript">
<!--
function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}
function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
}
}
}
var preloadFlag = false;
function preloadImages() {
if (document.images) {
previousArrowover = newImage("pcg_test.get?name='previousArrowover.gif'");
nextArrowover = newImage("pcg_test.get?name='nextArrowover.gif'");
preloadFlag = true;
}
}
// -->
</script>
</head>
<body onload="preloadImages();">
<img src="display_easy_image?p_id=22" alt="IMG_7271">
<a href="go_to_prev_image" onmouseover="changeImages('previousArrow', "pcg_test.get?name='previousArrowover.gif'"); return true;" onmouseout="changeImages('previousArrow', 'pcg_test.get?name=previousArrow.gif'); return true;"><img class="prew"name="previousArrow" src="pcg_test.get?name=previousArrow.gif"></a>
<a href="go_to_next_iamge" onmouseover="changeImages('nextArrow', 'pcg_test.get?name=nextArrowover.gif'); return true;" onmouseout="changeImages('nextArrow', 'pcg_test.get?name=nextArrow.gif'); return true;"><img class="next" name="nextArrow" src="pcg_test.get?name='nextArrow.gif'"></a>
<br>
<p>
owa_util.cellsprint('test'); <%-- here I want to display text from database --%>
</p>
</body>
</html>
package test like below
CREATE OR REPLACE PACKAGE pcg_test IS
actual_image VARCHAR2(30);
PROCEDURE load_p (filename VARCHAR2);
PROCEDURE get_p (filename VARCHAR2);
end;
/
show error;
CREATE OR REPLACE PACKAGE BODY pcg_test IS
PROCEDURE load_p (filename VARCHAR2) IS
f_lob BFILE;
b_lob BLOB;
image_name VARCHAR2(30);
mime_type VARCHAR2(30);
dot_pos NUMBER;
BEGIN
dot_pos := INSTR(filename,'.');
image_name := filename; --SUBSTR(filename,1,dot_pos-1);
mime_type := 'image/'||SUBSTR( filename,dot_pos+1,length(filename) );
INSERT INTO images(image_name,mime_type,content) values(image_name,mime_type,empty_blob() )
RETURN content INTO b_lob;
f_lob := BFILENAME('ZDJECIA',filename);
dbms_lob.fileopen(f_lob,dbms_lob.file_readonly);
dbms_lob.loadfromfile(b_lob,f_lob,dbms_lob.getlength(f_lob) );
dbms_lob.fileclose(f_lob);
COMMIT;
END load_p;
PROCEDURE get_p (filename VARCHAR2) IS
vblob BLOB;
mime_type VARCHAR2(30);
BEGIN
select content,mime_type
into vblob,mime_type
from images
where image_name=filename;
owa_util.mime_header(mime_type, false);
owa_util.http_header_close;
wpg_docload.download_file(vblob);
exception when others then
htp.p(sqlcode || sqlerrm);
END get_p;
BEGIN
actual_image:='1.jpg';
END pcg_test;
function display_easy_image is from Burleson's book:
create or replace procedure display_easy_image( p_id number ) as
s_mime_type varchar2(48);
n_length number;
s_filename varchar2(400);
lob_image blob;
begin
select mime_type, dbms_lob.getlength( blob_content ), filename,
blob_content
into s_mime_type, n_length, s_filename, lob_image
from easy_image
where image_id = p_id;
owa_util.mime_header( nvl( s_mime_type, 'application/octet' ), FALSE );
-- Set the size so the browser knows how much it will be downloading.
htp.p( 'Content-length: ' || n_length );
-- The filename will be used by the browser if the users does a "Save as"
htp.p( 'Content-Disposition: filename="' || s_filename || '"' );
owa_util.http_header_close;
-- Download the BLOB
wpg_docload.download_file( lob_image );
end display_easy_image;
/
and I've got 2 problems
1. how can I display together image and text (both from database)? a can't even display staic text owa_util.cellsprint('test')
2. how can I do something like that: when you load page on the first time you will see image 1.jpg, and after you click "next arrow" (prev arrow) you will see this same page with next (previous) image from a table (with siutable field next_image_id and prev_image_id) in database
can anyone help me with that? Thanaks in advance.
|
|
|
Re: Images and text on PSP page [message #256812 is a reply to message #256402] |
Mon, 06 August 2007 14:13 |
andrew again
Messages: 2577 Registered: March 2000
|
Senior Member |
|
|
Try using htp.p rather than cellsprint - most of those fancy functions are just wrappers to htp.p. If you know what you want the html to look like, then htp.p is easier.
htp.p('<HTML><BODY><HEAD><TITLE>Image Test Page - with text</TITLE></HEAD>');
htp.p('Below is an image<br>');
htp.p('<img src="display_easy_image?p_id=22" alt="IMG_7271" border="0"><br>');
htp.p('Above is an image<br></BODY></HTML>');
The fact that you can dispay your link means that you can display text too. Try adding text to your prev/next html:
...src="pcg_test.get?name='nextArrow.gif'"> HERE IS MY TEST </a>...
|
|
|
|
Re: Images and text on PSP page [message #256814 is a reply to message #256813] |
Mon, 06 August 2007 14:58 |
andrew again
Messages: 2577 Registered: March 2000
|
Senior Member |
|
|
It's could be a characterset mismatch issue (assuming yor code it't corrupting the image data. Because your "display_easy_image?p_id=22" works correclty, you must have the characterset correclty set in the DAD to match your database characterset.
Do both approaches use the same Oracle characterset settings?
(check your PSP Oracle NLS characterset settings)
[Updated on: Mon, 06 August 2007 15:02] Report message to a moderator
|
|
|
Re: Images and text on PSP page [message #256823 is a reply to message #256814] |
Mon, 06 August 2007 16:13 |
jelo
Messages: 3 Registered: August 2007
|
Junior Member |
|
|
I've tried this both methods in the same PSP file, I mean once I 'v used (as a part of PSP page)
<img src="display_easy_image?p_id=22" alt="">
and then I've only changed the line above in this way
<img src="<% display_easy_image(22); %>" alt="">
|
|
|