CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Referencing objects in include pages, second try

Print topic Send  topic

Author Message
jwh

Posts: 13
Posted: 08/26/2004, 4:05 PM

Hi all,

this is my second try (first one was 08/04) to ask the following question, but this time in a new topic (so hopefully this will raise the attention of some more people, and hopefully of some who can help me, maybe You Peter R.?)

so here we go again:

Hi there,

At first, I'm new to CCS, PHP and to this forum, but I quickly figured out:

The people here and at YES, as well as CCS are all GREAT !!!

I have run into trouble with the same Error Message but for a different reason (and after reading and trying for hours I decided to ask here, sorry for the long post, maybe it's also long because of my "German" nature ;-))

My Goal: implement "template-like" Pages with some functionality includable
almost everywhere for example in other included pages and also multiple times within the same page.

So when I include a given "special function include" page twice on the same "main" page, it gets a different name (and its own instance of the include pages class) which is fine.

So I can access the objects of these included instances from the main page by theire different names, works fine.

But because of the different names of these instances I figured out a way to get the include pages current instance "path" by calling the function debug_backtrace() and building the "path" to the wanted instance by searching for the entry with the requested classname. The whole thing is implemented in the "BeforeShow -Event of the Include Page.

As long as the Include Page is included within the main page, averything works ok, but if it is included by another level of included page, I can't figure out how to address it correctly.

So my Test Scenario:

The Main Page "m" which has one HTML-String, one inclusion of the "special include page" "i" with the "instance"-name "i", one inclusion of the same page "i" but this time with the special name "i1"
and one inclusion of another include page "s".

The Page "s" has nothing but an inclusion of the "special page" "i".

The "Special Page "i" has just a HTML String and a TextBox-Object "TextBox1"

If I don't code any Event-Code the visual Result is a Page with

first the String from the main page, followed 3 times by the string and an empty TextBox from the page "i" (two times from the inclusion within the main page, and one time from the inclusion via the intermediate page "s".

In the "BeforeShow" -Event of the main page I can access the TextBox1 by their names "$i-TextBox1-SetValue("Hello")", "$i1->TextBox1-SetValue("Hello1")" and "$s->i->TextBox1-SetValue("Hello2")".

Within the "BeforeShow"-Event of the "i"-Page itself, I can access these Pages with their "hardcoded" names as well, but normaly I don't know these names.

So here is my Event-code (the problem part is marked by !!!!!!!!:

-------------------------------------------------------------------------------------------

echo "<pre>";
$stack = debug_backtrace();
//print_r($stack);
$highest = array_pop($stack);
//echo "highest: ";
//print_r($highest);
$caller = $highest["args"][0];
global $$caller;
while ($highest['class'] != 'clsi') {
if ($callchain) {
$callchain = $callchain . '->';
}
$highest = array_pop($stack);
//echo "highest: ";
//print_r($highest);
$callchain = $callchain . $highest["args"][0];
}

printf("My Caller originally came from object instance: %s<br>", $caller);
printf("My Callchain is: %s<br>", $callchain);
if ($callchain) {
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//this one does NOT work
$$caller->$callchain->TextBox1->SetValue('Hello my friends');
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
} else {
// this on works
$$caller->TextBox1->SetValue('How is life?');
}

// the hard coded way works fine
//$i->TextBox1->SetValue('Hello');
//$i1->TextBox1->SetValue('Hello');
//$s->i->TextBox1->SetValue('Hello');

echo "</pre>";

---------------------------------------------------------------------------------------------

Any help is very welcome, If you think that's the wrong place to ask
this whole long question so please advise me to the right place,
If something (or even the whole thing) is unclear, please let me know.

thanks in advande and enjoy your day

cu jwh


Jan W. Hentsch (jwh@csmed.de)
CSMed GmbH, Darmstadt
Germany
View profile  Send private message
DonB
Posted: 08/28/2004, 6:23 AM

What is the "Error Message" and what DOES happen when it "does NOT work"?

And how will what you have written simplify or minimize the task of writing
event code?


--
DonB

http://www.gotodon.com/ccbth


"jwh" <jwh@forum.codecharge> wrote in message
news:5412e6cbd2f794@news.codecharge.com...
> Hi all,
>
> this is my second try (first one was 08/04) to ask the following question,
but
> this time in a new topic (so hopefully this will raise the attention of
some
> more people, and hopefully of some who can help me, maybe You Peter R.?)
>
> so here we go again:
>
> Hi there,
>
> At first, I'm new to CCS, PHP and to this forum, but I quickly figured
out:
>
> The people here and at YES, as well as CCS are all GREAT !!!
>
> I have run into trouble with the same Error Message but for a different
reason
> (and after reading and trying for hours I decided to ask here, sorry for
the
> long post, maybe it's also long because of my "German" nature ;-))
>
> My Goal: implement "template-like" Pages with some functionality
includable
> almost everywhere for example in other included pages and also multiple
times
> within the same page.
>
> So when I include a given "special function include" page twice on the
same
> "main" page, it gets a different name (and its own instance of the include
> pages class) which is fine.
>
> So I can access the objects of these included instances from the main page
by
> theire different names, works fine.
>
> But because of the different names of these instances I figured out a way
to
> get the include pages current instance "path" by calling the function
> debug_backtrace() and building the "path" to the wanted instance by
searching
> for the entry with the requested classname. The whole thing is implemented
in
> the "BeforeShow -Event of the Include Page.
>
> As long as the Include Page is included within the main page, averything
works
> ok, but if it is included by another level of included page, I can't
figure out
> how to address it correctly.
>
> So my Test Scenario:
>
> The Main Page "m" which has one HTML-String, one inclusion of the "special
> include page" "i" with the "instance"-name "i", one inclusion of the same
page
> "i" but this time with the special name "i1"
> and one inclusion of another include page "s".
>
> The Page "s" has nothing but an inclusion of the "special page" "i".
>
> The "Special Page "i" has just a HTML String and a TextBox-Object
"TextBox1"
>
> If I don't code any Event-Code the visual Result is a Page with
>
> first the String from the main page, followed 3 times by the string and an
> empty TextBox from the page "i" (two times from the inclusion within the
main
> page, and one time from the inclusion via the intermediate page "s".
>
> In the "BeforeShow" -Event of the main page I can access the TextBox1 by
their
> names "$i-TextBox1-SetValue("Hello")", "$i1->TextBox1-SetValue("Hello1")"
and
> "$s->i->TextBox1-SetValue("Hello2")".
>
> Within the "BeforeShow"-Event of the "i"-Page itself, I can access these
Pages
> with their "hardcoded" names as well, but normaly I don't know these
names.
>
> So here is my Event-code (the problem part is marked by !!!!!!!!:
>
> --------------------------------------------------------------------------
-----------------
>
> echo "<pre>";
> $stack = debug_backtrace();
> //print_r($stack);
> $highest = array_pop($stack);
> //echo "highest: ";
> //print_r($highest);
> $caller = $highest["args"][0];
> global $$caller;
> while ($highest['class'] != 'clsi') {
> if ($callchain) {
> $callchain = $callchain . '->';
> }
> $highest = array_pop($stack);
> //echo "highest: ";
> //print_r($highest);
> $callchain = $callchain . $highest["args"][0];
> }
>
> printf("My Caller originally came from object instance: %s<br>", $caller);
> printf("My Callchain is: %s<br>", $callchain);
> if ($callchain) {
>
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> //this one does NOT work
> $$caller->$callchain->TextBox1->SetValue('Hello my friends');
>
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> } else {
> // this on works
> $$caller->TextBox1->SetValue('How is life?');
> }
>
> // the hard coded way works fine
> //$i->TextBox1->SetValue('Hello');
> //$i1->TextBox1->SetValue('Hello');
> //$s->i->TextBox1->SetValue('Hello');
>
> echo "</pre>";
>
> --------------------------------------------------------------------------
-------------------
>
> Any help is very welcome, If you think that's the wrong place to ask
> this whole long question so please advise me to the right place,
> If something (or even the whole thing) is unclear, please let me know.
>
> thanks in advande and enjoy your day
>
> cu jwh
>
>
> Jan W. Hentsch (jwh@csmed.de)
> CSMed GmbH, Darmstadt
> Germany
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

jwh

Posts: 13
Posted: 09/03/2004, 3:26 AM

Hello DonB (and others)

sorry for the late reply, I was away for a while.

Yes, you're right, I should tell what the error message is, I forgott to copy this from the other trail.
So the error is:

Fatal error: Call to a member function on a non-object in ...

The goal of all those tries is to reuse include pages several times, also include them multiple times within the same "main" page.
When I say reuse include pages I mean reuse things implemented as include pages (maybe a collection of objects acting together to solve some generic task).
The "main"-page hereby needs to feed some information to the include page (maybe into a hidden object of the include page) and the include page needs to get access to that information. Therefor it needs to know its own "name" whithin the "object"- hirarchy.

Hopefully it's clear what I want and what my problem is.

thanks in advance

Jan W. Hentsch
jwh@csmed.de
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.