Home » Developer & Programmer » Forms » How to make null text and image items invisible in run time?? (Oracle Forms 10g.)
How to make null text and image items invisible in run time?? [message #621173] Mon, 11 August 2014 02:52 Go to next message
utsav0311
Messages: 12
Registered: July 2014
Location: Bangalore,India
Junior Member
Hello all,

I have a non-tabular(Number of Records Displayed = 1)datablock,B_test which has four Text Items say Item1,item2,Item3 and Item4 and four Image Items say Image1,Image2,Image3 and Image4 . I have a table Employees having Emp_id as one of its column and lets say that the table has only 3 rows and the values for Emp_id is 1,2,and 3.
Now there is one push button which when pressed should get the values of all the emp_id present in the table Employees and Image of those employee (which is available on the hard disk not in the database) into the Item1,Item2,Item3 & Item4 and Image1,Image2,Image3 and Image4,respectively. Obviously,Item4 and Image4 will be null.

I have managed to achieve the first part of it (i.e getting values to the block B_test) and now I want all the null items(Item4 and Image4) to be invisible in my canvas.

Here's this is how I am trying to do it:

Declare
next varchar2(40);-- to hold the values of the system cursor of next item in the B_Test block
lastitem varchar2(40);--to hold the values of the system cursor of last item in the B_Test block
Begin
Go_Block('B_test');
next := :SYSTEM.CURSOR_ITEM;
Go_Item(Get_Block_Property('B_test',LAST_ITEM));
lastitem := :SYSTEM.CURSOR_ITEM;
For i in 1..last_item
Loop
Go_Item(next);
val:= :System.Cursor_value;
If val is null then
message(next||' is null');
set_item_property(:System.Cursor_Item,Visible,PROPERTY_FALSE);-- This gives me the obvious error that Forms cant set invisible property to the current item
Elsif val is not null then
message(next||' is not null');
End if;
NEXT_ITEM;
next := :SYSTEM.CURSOR_ITEM;
EXIT WHEN :SYSTEM.CURSOR_ITEM = lastitem;
END LOOP;

End;


So could you all please help me to get rid of this error.
Re: How to make null text and image items invisible in run time?? [message #621175 is a reply to message #621173] Mon, 11 August 2014 03:00 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
Please read and follow How to use [code] tags and make your code easier to read?

Obviously you have to move the cursor somewhere else first.
Personally I'd skip the loop entirely and just code an IF statement for each item that can be null. I imagine at least some of them are not null, so you can skip checking those and leave the cursor in one of them while making the other invisible.
Re: How to make null text and image items invisible in run time?? [message #621177 is a reply to message #621175] Mon, 11 August 2014 04:26 Go to previous messageGo to next message
utsav0311
Messages: 12
Registered: July 2014
Location: Bangalore,India
Junior Member
Thanks for your concern !!
Actually I have written in that format only but when I posted,somehow it turned into unformatted code.

Anyways,coming to what you have suggested,I have a few basic doubts:
1.If not a LOOP then how can I check till the last item.
2.Quote:
leave the cursor in one of them while making the other invisible.
How can I achieve this? I mean I won't be knowing the item name of the null items.
3.Is there any built-in or anything sort of that which can set invisible property for the next item till the last item of the block.

I will be highly obliged if you help me with the coding of the idea which you have suggested.

Re: How to make null text and image items invisible in run time?? [message #621180 is a reply to message #621177] Mon, 11 August 2014 05:17 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
utsav0311 wrote on Mon, 11 August 2014 10:26
Thanks for your concern !!
Actually I have written in that format only but when I posted,somehow it turned into unformatted code.

Then you haven't read the link in the above post, since that shows how to avoid it being unformatted.

utsav0311 wrote on Mon, 11 August 2014 10:26

Anyways,coming to what you have suggested,I have a few basic doubts:
1.If not a LOOP then how can I check till the last item.

Datablocks do not contain random numbers of items, you know exactly what's there so just check each item. Lsat item is irrelevant unless you using a loop.
utsav0311 wrote on Mon, 11 August 2014 10:26

2.Quote:
leave the cursor in one of them while making the other invisible.
How can I achieve this? I mean I won't be knowing the item name of the null items.

Are you saying there isn't a single not null column there?
utsav0311 wrote on Mon, 11 August 2014 10:26

3.Is there any built-in or anything sort of that which can set invisible property for the next item till the last item of the block.

No. though of course you can use get_item_property to work out what the next_item is.

utsav0311 wrote on Mon, 11 August 2014 10:26

I will be highly obliged if you help me with the coding of the idea which you have suggested.

8 (if necessary) IF statements, each checking one of the items and if it's null setting the item property.
I'm suggesting the most basic code to get the job done, nothing clever.
Re: How to make null text and image items invisible in run time?? [message #621185 is a reply to message #621180] Mon, 11 August 2014 07:01 Go to previous messageGo to next message
utsav0311
Messages: 12
Registered: July 2014
Location: Bangalore,India
Junior Member
Quote:
Then you haven't read the link in the above post, since that shows how to avoid it being unformatted.

Laughing
This was my second post in the Forum and believe me I have gone through it and probably from the next time it won't happen. Smile

Quote:
Are you saying there isn't a single not null column there?

There are lot of not null items.I am totally a newbie in Oracle Forms,so I am not able to implement your suggestion in codes.Please elaborate it.

Quote:
each checking one of the items and if it's null setting the item property.

That's what I am trying to do in the above code.While checking the item for null values, my system cursor will be at that item and I won't be able to make it invisible(Error: Frm 41016).So, I need to go to the next item and then 'somehow' set the immediate previous item invisible.And I am totally clueless about this 'somehow'.

Please help me to find this 'somehow'. Razz

Thanks!!
Re: How to make null text and image items invisible in run time?? [message #621186 is a reply to message #621185] Mon, 11 August 2014 07:46 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
I think you think I mean something more complicated than what I said, when I actually meant exactly what I said. Assuming item1 is not null:
IF :block.item2 IS NULL THEN
  set_item_property('blovk.item2', Visible, PROPERTY_FALSE);
END IF;

IF :block.item3 IS NULL THEN
  set_item_property('blovk.item3', Visible, PROPERTY_FALSE);
END IF;

........


You've got 8 items. You could have written that in 1 minute and then it would be done.
Re: How to make null text and image items invisible in run time?? [message #621253 is a reply to message #621186] Tue, 12 August 2014 03:25 Go to previous messageGo to next message
utsav0311
Messages: 12
Registered: July 2014
Location: Bangalore,India
Junior Member
I guess I have failed to explain my requirement.

My block contains much more than 8 items and so does my Employee table.Up here I have written just for a illustration purpose.If it would have been for just 8 items,it would have been literally a cakewalk.
And obviously I am not in position to use 100's of if condition and that's exactly why I was trying to use LOOP condition at first place.

I will try to explain my requirement once again.
I have a datablock with lots of text and image items in it and I have fetched some data in these items in the runtime from a table. However few of these items of datablock contain null values(because total count of items in the datablock is more than total count of records in the table),which needs to be invisible during runtime.

I have thought of two ways in achieving this:
1.We need to refer the null item name dynamically(during runtime) and set them invisible. But the basic issue is how to refer any item of the block dynamically.?
2.Since the data is inserted in sequential manner so all the null items will in together after the last non-null item.So if somehow we are able to set all the items (till last item)invisible after one particular item(last non-null item),then also it will serve my purpose.

Please help me with either option OR suggest me something more effective and easily achievable.

Thanks!! Smile
Re: How to make null text and image items invisible in run time?? [message #621260 is a reply to message #621253] Tue, 12 August 2014 03:52 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
Some things can be worth simplifying when presenting a problem, the number of items in the block you need to make invisble isn't one of them.

Instead of going to each item in turn you can use get_item_property to get the nextitem property and use that to check each item in turn while keeping the cursor in the first item.
Re: How to make null text and image items invisible in run time?? [message #621264 is a reply to message #621260] Tue, 12 August 2014 04:07 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I'm curious: what kind of information do you store into such a table? Is it normalized (3rd normal form)?

Could you post a screenshot of a current form? Doesn't matter that certain empty items are still visible. Blur it if necessary.
Re: How to make null text and image items invisible in run time?? [message #621283 is a reply to message #621260] Tue, 12 August 2014 06:52 Go to previous messageGo to next message
utsav0311
Messages: 12
Registered: July 2014
Location: Bangalore,India
Junior Member
I got a solution for the same.Thanks a lot for all your replies and concern. Smile

The code is :
-- next is a variable which holds the address of first non-null item
For i in 1..LAST_ITEM
 LOOP
  Go_Item(next);
  NEXT_ITEM;	
  Set_Item_Property(next,DISPLAYED,PROPERTY_OFF);			 
  next := :SYSTEM.CURSOR_ITEM;
  EXIT WHEN :SYSTEM.CURSOR_VALUE is NOT NULL;
 END LOOP;
Re: How to make null text and image items invisible in run time?? [message #621284 is a reply to message #621264] Tue, 12 August 2014 06:55 Go to previous messageGo to next message
utsav0311
Messages: 12
Registered: July 2014
Location: Bangalore,India
Junior Member
Its just a simple table consisting of some details of the employees and I am not sure about its normalization.
Re: How to make null text and image items invisible in run time?? [message #621379 is a reply to message #621284] Wed, 13 August 2014 00:06 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
That just doesn't match.
You, previously

My block contains much more than 8 items and so does my Employee table (...) obviously I am not in position to use 100's of if condition

vs.
You, in your last message

Its just a simple table consisting of some details of the employees

Re: How to make null text and image items invisible in run time?? [message #621445 is a reply to message #621379] Wed, 13 August 2014 06:57 Go to previous messageGo to next message
utsav0311
Messages: 12
Registered: July 2014
Location: Bangalore,India
Junior Member
Sorry!! But I am not able to make out what's not matching in my Quote:
Previous message
and Quote:
Last message
Confused
Re: How to make null text and image items invisible in run time?? [message #621446 is a reply to message #621445] Wed, 13 August 2014 07:00 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
A "simple table" doesn't need "100's of IF conditions".
Re: How to make null text and image items invisible in run time?? [message #621556 is a reply to message #621446] Thu, 14 August 2014 04:55 Go to previous message
utsav0311
Messages: 12
Registered: July 2014
Location: Bangalore,India
Junior Member
Well!! the table is 'Simple' only,however my Block is a bit complicated.

In my block I have say 50 items(25 image and 25 text items,every image item is placed on the top of a text item).Now,when one particular button is pressed,each image item is supposed to have the picture and and the text item(right below it) should hold the name & employee id of that employee. When these pictures are clicked,a new canvas should show the details of that employee.This was the first part of my requirement which I have mentioned in the very first message of mine.

Just in case,if the Employee table holds only 30 records then my 20 items (10 image and 10 text items) will be null,which I had to make them invisible.This was the second part of my requirement for which I have started the thread.

The 'Number of Records Displayed = 1' for the block so the count of 'if' conditions(to make items invisible during run time) which I have mentioned in the previous messages will be depended upon the number of records of the table rather than its number of columns.


I hope I have not complicated things rather than simplifying it. Smile
Previous Topic: Regarding Oracle forms and reports
Next Topic: Oracle Forms & Reports 10g Upgrade to 11g
Goto Forum:
  


Current Time: Fri Mar 29 10:14:14 CDT 2024