You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by ma...@metm.org on 2004/04/30 06:14:03 UTC

OO menus

I am a bit stuck on a coding issue, so I am thinking outloud, hoping
that the answer will come to me or that I will set off somebody else's
thought process.  

I want to set up a menu system, where all one has to do is modify a file
in the current directory to define the menus for that place in the
directory tree:

_menu.epl: 
@menu = [ item1 , item2 , item3 , item4 ]

item3/_menu.epl:
@menu = [ subitem1, subitem2, subitem3 ]

an embperl html creating widget would produce this :

<ul>
 <li>item1</li>
 <li>item2</li>
 <li>item3
  <ul>
   <li>subitem1</li>
   <li>subitem2</li>
   <li>subitem3</li>
  </ul>
 </li>
 <li>item4</li>

from a data structure that looks like this:

@menu = [ item1 , 
          item2 , 
          [ subitem1 , subitem2 , subitem3 ] , 
		  item3 ,
          item4 ]

I am looking at the end of IntroEmbperlObject.pod with the inslut
example and I imagine this must be possible.  I have been getting stuck
between creating the data structures and calling the superclasses.  I
feel like I want to tinker with Execute cause I don't feel like I
understand the differences between:

  [- Execute('../_menu.epl') -]
  [- Execute({object => '../_menu.epl'}) -]
  [- Execute({isa => '../_menu.epl'}) -]
  [- Execute({inputfile => '../_menu.epl'}) -]

Are there others?  Should I put my data into sub routines like is
shown at times in the docs and the inslut example? 

I want to have the html generating code as a widget called in from the
top-level _base.epl say from _widgets.epl.   I would call with the
subroutine &menu with @menu data structure parameter.  The subroutine
would know how to walk through the structure to print it out.

I am speaking in vauge terms because I feel that I can write each little
piece but I don't quite see how to fit the whole into the embperl framework.

Thanks for any thoughts,

-- 
Marco

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: OO menus

Posted by Gerald Richter <ri...@ecos.de>.
Hi,

>
> Thanks for the responce.
>
> On Wed, May 05, 2004 at 05:49:01AM +0200, Gerald Richter wrote:
>>
>>>   [- Execute({object => '../_menu.epl'}) -]
>>
>> this will return you an object, e.g. you can do
>>
>> [-
>> $obj = Execute({object => '../_menu.epl'}) ;
>> $obj -> display_menu(\@menu) ;
>> -]
> In this example, what contructor is called?
> Can I write my own?
>

Everything that is inside [! !] is executed during the 'object => xxx'
initialization. There you can place your construction code or call your
construtor.

Gerald

---------------------------------------------------------------------------
Gerald Richter            ecos electronic communication services gmbh
IT-Securitylösungen * Webapplikationen mit Apache/Perl/mod_perl/Embperl

Post:       Tulpenstrasse 5          D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de          Voice:   +49 6133 939-122
WWW:        http://www.ecos.de/      Fax:     +49 6133 939-333
---------------------------------------------------------------------------
Besuchen Sie uns auf der KOMCOM 2004 in Mannheim
25. bis 27. Mai 2004  Stand K11a   www.komcom.de

ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info
---------------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: OO menus

Posted by Marco Scoffier <ma...@metm.org>.
Hi Gerald,

Thanks for the responce.  

On Wed, May 05, 2004 at 05:49:01AM +0200, Gerald Richter wrote:
> 
> >   [- Execute({object => '../_menu.epl'}) -]
> 
> this will return you an object, e.g. you can do
> 
> [-
> $obj = Execute({object => '../_menu.epl'}) ;
> $obj -> display_menu(\@menu) ;
> -]
In this example, what contructor is called?  
Can I write my own?

Thanks,

-- 
Marco

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: OO menus

Posted by Gerald Richter <ri...@ecos.de>.
Hi,

>
>   [- Execute('../_menu.epl') -]

this simply excutes the code/html in menu.epl

>   [- Execute({object => '../_menu.epl'}) -]

this will return you an object, e.g. you can do

[-
$obj = Execute({object => '../_menu.epl'}) ;
$obj -> display_menu(\@menu) ;
-]

if you have defined display_menu as a sub inside of menu.epl

>   [- Execute({isa => '../_menu.epl'}) -]

if you ut this in your base.epl, base.epl (and therefore the Embperl request
object) will inheret all methods, so anywhere you can say

[-
$epreq -> display_menu(\@menu) ;
-]

>   [- Execute({inputfile => '../_menu.epl'}) -]

this is the same as the first example.
>
> Are there others?  Should I put my data into sub routines like is
> shown at times in the docs and the inslut example?
>
> I want to have the html generating code as a widget called in from the
> top-level _base.epl say from _widgets.epl.   I would call with the
> subroutine &menu with @menu data structure parameter.  The subroutine
> would know how to walk through the structure to print it out.


So you should use the isa solution as shown above.

Gerald

>
> I am speaking in vauge terms because I feel that I can write each
> little piece but I don't quite see how to fit the whole into the
> embperl framework.
>
> Thanks for any thoughts,

---------------------------------------------------------------------------
Gerald Richter            ecos electronic communication services gmbh
IT-Securitylösungen * Webapplikationen mit Apache/Perl/mod_perl/Embperl

Post:       Tulpenstrasse 5          D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de          Voice:   +49 6133 939-122
WWW:        http://www.ecos.de/      Fax:     +49 6133 939-333
---------------------------------------------------------------------------
Besuchen Sie uns auf der KOMCOM 2004 in Mannheim
25. bis 27. Mai 2004  Stand K11a   www.komcom.de

ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info
---------------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org