You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Kaare Rasmussen <ka...@webline.dk> on 2000/04/21 12:44:57 UTC

Javascript w/ EmbperlObject

Hi

I thought I could place this in my EmbperlObject template:
<BODY  [- Execute ('*#js_start') -]>

and this in the original file:

[$ sub js_start $] onLoad="nr.focus()" [$ endsub $]

But the result is this:

<HTML>
<HEAD>
<title> title
</title>
</HEAD>
 onLoad="nr.focus()" 
<BODY>

How will I produce an individual onLoad if I want to use EmbperlObjects ?

-- 
Kaare Rasmussen            --Linux, spil,--        Tlf:        3816 2582
Kaki Data                tshirts, merchandize      Fax:        3816 2582
Howitzvej 75               �ben 14.00-18.00        Email: kar@webline.dk
2000 Frederiksberg        L�rdag 11.00-17.00       Web:      www.suse.dk

RE: More questions

Posted by Gerald Richter <ri...@ecos.de>.
Hi
>
> 1. DBIxRecordset: How do I put the PrevNextForm in a table ? I
> want to alwas
> have the same buttons the same place in the form, like this
>
> First   Previous   Next   Last
>
> If displaying the first rows,
> it would look like
>
>                     Next   Last
>
> Hope it is understandable.
>

Yes, I understand, but the current version don't displays First and
Previous, if you are already at the start of the recordset. If you need
this, you must patch DBIx::Recordset PrevNextForm method.

> 2. Could someone please tell me how I make a persistent database
> connection
> with mod_perl and Embperl ? A step by step intro including
> - where do I make the DBI->connect. In startup.pl ?

Never make a connect in the startup.pl, unless you also make a disconnect!
(because db handles becomes invalid when APache forks it childs)

> - How do I reference the database handle? What name does it have ?
>

In your startup.pl inlcude a

use Apache::DBI ;

afterwards you can just access your database as normal. Apache::DBI takes
care for you.


> According to the mod_perl guide, this is preferable to put in startup.pl
>
> use mymodule();
>
> to save time by including all the routines on startup. But if I
> do so, I can
> not access any routines in mymodule. They are simple not known.
> Why ?
>

Because your routines will live in the main package. Include a

package mymodule ;

at the top of your module and access the functions via

mymodule::foo () ;

Gerald



> --
> Kaare Rasmussen            --Linux, spil,--        Tlf:        3816 2582
> Kaki Data                tshirts, merchandize      Fax:        3816 2582
> Howitzvej 75               Åben 14.00-18.00        Email: kar@webline.dk
> 2000 Frederiksberg        Lørdag 11.00-17.00       Web:      www.suse.dk
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>


More questions

Posted by Kaare Rasmussen <ka...@webline.dk>.
Hi

1. DBIxRecordset: How do I put the PrevNextForm in a table ? I want to alwas
have the same buttons the same place in the form, like this

First   Previous   Next   Last

If displaying the first rows, 
it would look like

                    Next   Last

Hope it is understandable.

2. Could someone please tell me how I make a persistent database connection
with mod_perl and Embperl ? A step by step intro including
- where do I make the DBI->connect. In startup.pl ?
- How do I reference the database handle? What name does it have ?

According to the mod_perl guide, this is preferable to put in startup.pl

use mymodule();

to save time by including all the routines on startup. But if I do so, I can
not access any routines in mymodule. They are simple not known.
Why ?

-- 
Kaare Rasmussen            --Linux, spil,--        Tlf:        3816 2582
Kaki Data                tshirts, merchandize      Fax:        3816 2582
Howitzvej 75               �ben 14.00-18.00        Email: kar@webline.dk
2000 Frederiksberg        L�rdag 11.00-17.00       Web:      www.suse.dk

RE: Javascript w/ EmbperlObject

Posted by Gerald Richter <ri...@ecos.de>.
> The problem is that I want it to go inside the <BODY>. It seems
> that EmbPerl
> moves it outside the <BODY>. onLoad can only be used within
> <BODY>, that's the
> problem.
>

Aah, now I see where the problem is. Execute will not work inside a html tag
that Embperl interprets. Currently only solution is to return the output of
the sub in a scalar and then include it in the body tag:

[- Execute ({inputfile => '*', 'sub' => 'js_start', output => \$out}) -]
<BODY [+ $out +]>

this should work.

> Btw. Is it possible to have a conditional execution? I want to
> execute this
> subroutine if it exists in the original file, but I don't want an
> error if it
> doesn't.
>

At the moment not

Gerald



> --
> Kaare Rasmussen            --Linux, spil,--        Tlf:        3816 2582
> Kaki Data                tshirts, merchandize      Fax:        3816 2582
> Howitzvej 75               Åben 14.00-18.00        Email: kar@webline.dk
> 2000 Frederiksberg        Lørdag 11.00-17.00       Web:      www.suse.dk
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>


RE: Javascript w/ EmbperlObject

Posted by Kaare Rasmussen <ka...@webline.dk>.
> The current version of Embperl requires a
> [- Execute ({ inputfile => '*', import => 0}) -]

Sorry for not being too specific. I have that, and I do get the included item.
The problem is that I want it to go inside the <BODY>. It seems that EmbPerl
moves it outside the <BODY>. onLoad can only be used within <BODY>, that's the
problem.

Btw. Is it possible to have a conditional execution? I want to execute this
subroutine if it exists in the original file, but I don't want an error if it
doesn't.

-- 
Kaare Rasmussen            --Linux, spil,--        Tlf:        3816 2582
Kaki Data                tshirts, merchandize      Fax:        3816 2582
Howitzvej 75               �ben 14.00-18.00        Email: kar@webline.dk
2000 Frederiksberg        L�rdag 11.00-17.00       Web:      www.suse.dk

RE: Javascript w/ EmbperlObject

Posted by Gerald Richter <ri...@ecos.de>.
Hi
>
> I thought I could place this in my EmbperlObject template:
> <BODY  [- Execute ('*#js_start') -]>
>

The current version of Embperl requires a

[- Execute ({ inputfile => '*', import => 0}) -]

before the first call to a subroutine in that file, to define the
subroutines in this file. The final release of 1.3 will make this
automaticly for you

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925151
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------