Re: How to generate pre-filled forms? (fwd)

2002-04-28 Thread F . Xavier Noria

On 29 Apr 2002 09:16:42 +1000
simran <[EMAIL PROTECTED]> wrote:

: Have a look at the HTML::FillInForm module as well... 

Yeah, thank you, I'll give it a try. I guess this is a natural candidate
for an output chain, the HTML generated by two or three Apache modules
will need that post-process, so I plan to use HTML::FillInForm with
Apache::Filter, it will be the first application of my recent study of
the Cookbook I couldn't have produced before I read it, magnific!

-- fxn




Re: How to generate pre-filled forms? (fwd)

2002-04-28 Thread simran

Have a look at the HTML::FillInForm module as well... 
it works wonders for me... 


On Sat, 2002-04-27 at 04:43, darren chamberlain wrote:
> * Ken Clark <[EMAIL PROTECTED]> [2002-04-26 14:33]:
> > I'll throw my technique into the ring, too.  I use Template Toolkit
> > most of the time, and I pass the original Apache request object back
> > to the template as a parameter.  Then I call the "param" method to
> > fill in the "value" of form elements, like so:
> 
> [-- snip --]
> 
> > Nothing gets placed there the first time through as calling
> > "$apr->param" returns nothing.  This seems to work great for me.  I've
> > not used HTML::Template in a while, but possibly you can do this, too?
> 
> The constructor for HTML::Template takes an optional argument names
> "associate", which should point to an object (or reference to a list of
> objects) that can("param").  Paramters in the template that are not
> explicitly filled in using the param method of the HTML::Template object
> are looked for by iterating through this list and calling
> param($template_variable_name), and takes the first non-false value as
> the correct one.
> 
> To reuse Ken's illustration:
> 
> > In code:
> >
> > sub handler {
> > my $r   = shift;
> > my $apr = Apache::Request->new($r);
> > my $t   = Template->new;
> > my $html;
> > $t->process('/foo/bar.tmpl', { apr => $apr }, \$html);
> > $apr->content_type('text/html');
> > $apr->send_http_header;
> > $apr->print( $html );
> > return OK;
> > }
> 
> sub handler {
> my $r   = shift;
> my $apr = Apache::Request->new($r);
> my $t   = HTML::Template->new(associate => $apr,
>   filename  => '/foo/bar.html');
> $apr->content_type('text/html');
> $apr->send_http_header;
> $apr->print( $t->output );
> return OK;
> }
> 
> > In template:
> >
> > 
> > 
> > [% apr.param('description') %]
> > 
> 
> 
> ">
> 
> 
> 
> For the template itself, "foo" will be looked for as $apr->param("foo"),
> and description as $apr->param("description").
> 
> (darren)
> 
> PS Hi Ken!
> 
> --
> The more we disagree, the better the chance that one of us is right.
> 
> 




Re: How to generate pre-filled forms? (fwd)

2002-04-26 Thread darren chamberlain

* Ken Clark <[EMAIL PROTECTED]> [2002-04-26 14:33]:
> I'll throw my technique into the ring, too.  I use Template Toolkit
> most of the time, and I pass the original Apache request object back
> to the template as a parameter.  Then I call the "param" method to
> fill in the "value" of form elements, like so:

[-- snip --]

> Nothing gets placed there the first time through as calling
> "$apr->param" returns nothing.  This seems to work great for me.  I've
> not used HTML::Template in a while, but possibly you can do this, too?

The constructor for HTML::Template takes an optional argument names
"associate", which should point to an object (or reference to a list of
objects) that can("param").  Paramters in the template that are not
explicitly filled in using the param method of the HTML::Template object
are looked for by iterating through this list and calling
param($template_variable_name), and takes the first non-false value as
the correct one.

To reuse Ken's illustration:

> In code:
>
> sub handler {
> my $r   = shift;
> my $apr = Apache::Request->new($r);
> my $t   = Template->new;
> my $html;
> $t->process('/foo/bar.tmpl', { apr => $apr }, \$html);
> $apr->content_type('text/html');
> $apr->send_http_header;
> $apr->print( $html );
> return OK;
> }

sub handler {
my $r   = shift;
my $apr = Apache::Request->new($r);
my $t   = HTML::Template->new(associate => $apr,
  filename  => '/foo/bar.html');
$apr->content_type('text/html');
$apr->send_http_header;
$apr->print( $t->output );
return OK;
}

> In template:
>
> 
> 
> [% apr.param('description') %]
> 


">



For the template itself, "foo" will be looked for as $apr->param("foo"),
and description as $apr->param("description").

(darren)

PS Hi Ken!

--
The more we disagree, the better the chance that one of us is right.



Re: How to generate pre-filled forms? (fwd)

2002-04-26 Thread Ken Y. Clark

Forgot to cc the list.

-- Forwarded message --
Date: Fri, 26 Apr 2002 11:35:37 -0400 (EDT)
From: Ken Y. Clark <[EMAIL PROTECTED]>
To: F.Xavier Noria <[EMAIL PROTECTED]>
Subject: Re: How to generate pre-filled forms?

On Fri, 26 Apr 2002, F.Xavier Noria wrote:

> Date: Fri, 26 Apr 2002 16:15:52 +0200
> From: F.Xavier Noria <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: How to generate pre-filled forms?
>
> I am writing some modules that receive a form, process it, and return a
> page that includes that very form. Is there a standard way to fill that
> returned form so the user sees the same data he sent there, as CGI.pm
> does?
>
> -- fxn
>
> PS: I am using Apache modules + HTML::Template if that matters.

I'll throw my technique into the ring, too.  I use Template Toolkit
most of the time, and I pass the original Apache request object back
to the template as a parameter.  Then I call the "param" method to
fill in the "value" of form elements, like so:

In code:

sub handler {
my $r   = shift;
my $apr = Apache::Request->new($r);
my $t   = Template->new;
my $html;
$t->process('/foo/bar.tmpl', { apr => $apr }, \$html);
$apr->content_type('text/html');
$apr->send_http_header;
$apr->print( $html );
return OK;
}

In template:



[% apr.param('description') %]


Nothing gets placed there the first time through as calling
"$apr->param" returns nothing.  This seems to work great for me.  I've
not used HTML::Template in a while, but possibly you can do this, too?
Template Toolkit makes it easy to call methods (or deference hashes
and hash references) with the "dot" notation.

HTH,

ky