«

»

Print this Post

Is my FactBox visible?

Is my FactBox visible?
1 vote, 5.00 avg. rating (98% score)

In one of my previous posts on “how to link a faxbox in code“, I explain .. uhm .. how you can link a faxbox in code.. (you might have guessed that). Now, one of the things you have to keep in mind (as a programmer) when doing so, is the fact that the code on your “OnAfterGetCurrRecord” of your page is always executed. So if you’re putting code there to update your factbox, it’s also going to (try to) execute it, even when it’s not visible. You don’t want that.

So how do I fix this?

Well, it would be nice to be able to use something like this, isn’t it?

IF NOT CurrPage.MyFactBox.PAGE.VISIBLE THEN …;

Let’s save you the trouble .. you can’t! At least not out-of-the-box..

So why just not creating that property ourselves on our own factbox?

Is that possible?

Well, with PRS, we try to let people think in an (and I should be careful which words I use .. but I’m still gonna .. blame me for it..) “Object Oriented” way. So if the Factbox is my object, I want to add the “Visibility”-property on it!

This is how I did it (or at least tried to do it).

First of all, I declared a global boolean on the factbox, which I call “PageIsVisible“.

Now, you want to be able to call this boolean from outside, so you create a global function on your factbox “IsVisible“, like:

IsVisible() : Boolean

EXIT(PageIsVisible);

Last thing, to “set” your boolean, I rely on the fact that, when you set your factbox visible, the code runs through the “OnOpenPage” trigger. I think it’s quite safe to rely on.. , So, all you do is:

OnOpenPage()

PageIsVisible := TRUE;

It’s as simple as that!

Now you can use this function in your form where you use your page where you wanted to show the factbox, like this:

UpdateFactbox()

IF NOT CurrPage.VMFMessageFactbox.PAGE.IsVisible THEN EXIT;

With the new debugger, you can easily see if it works .. as you see below, where I set a breakpoint in the IsVisible-function on my factbox. As you can see, the boolean is false, which was correct.. as my factbox was indeed not visible at that time..


There were a few people who reminded me to write this blog .. so hope this answers the question .. and help them with their situation.

If not .. or you’ve got remarkt .. I’m always happy to get comments!


Permanent link to this article: http://www.waldo.be/2013/02/11/is-my-factbox-visible/

4 comments

3 pings

Skip to comment form

  1. Magno

    Wouldn’t it be good practice to set PageVisible to false onQueryClosePage?
    Just in case they close the factbox in between, you will have the correct state as well.

  2. waldo

    Good point! Of course :-)

  3. Sebi64

    Thank you for your post.
    I was close from the solution, i just missed the use of the OnOpenPage.

    1. waldo

      Glad i was able to assist you … :-)

  1. Is my FactBox visible? | Pardaan.com

    [...] Bron : Waldo’s Blog Lees meer… [...]

Leave a Reply