[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] RE: Many HTML <select>'s ... one Data Source


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Howdy,

On Thu, 19 Feb 2004, Bill McCormick wrote:
> > OpenThought is in fact capable of using CGI::Application, via 
> > a CGI::App subclass called OpenPlugin::Application.  In fact, 
> > usage through CGI::App/OpenPlugin::App is the recommended 
> > method, and is how all the examples in the docs are shown.
>
> This seems like a great project; your web site presentation is very
> helpful. I'll first take a look at the docs. The first thing I need to
> see is how easily it integrates into my existing C::A framework. Does it
> slide in or am I looking at a rewrite at some level? 

Good question.

One of OpenThought's chief benefits is that you don't have to reload the
page.  The user already has a page loaded, you may simply want to fill a
select list that is currently empty.

In CGI::App-speak, this can be done in two run modes.  The first run-mode
is to load the user interface into the browser.  The second run-mode is
what is used to fill the select list.  For example, if the user is
performing a search, they'd enter their search criteria, click "Search",
and the second run-mode would fill the select list.

The difference between this and your current application is that this
second run-mode isn't returning HTML, it's returning just the data needed
to fill the select list (remember, the page isn't being reloaded).

If you have this HTML currently loaded in the browser:

    <form>
      <select name="MySelectList">
    </form

In your app, you could use the following in your second run-mode to fill
in your select list:

  my $sql = "SELECT name, ssn FROM sometable";

  my $sth = $dbh->prepare($sql);
  $sth->execute;

  # The key "MySelectList" corresponds to the field name in the HTML
  $data->{'MySelectList'} = $sth->fetchall_arrayref;

  return $OpenThought->serialize({ update => $data });

Based on the SELECT statement above, your select list would be populated
with a bunch of names, and the "ssn" would be the value for each name.

So would you have to change any code?  Probably somewhat, but you may end
up using *less* code overall to build your app.  Your app would also run
much faster since you don't have to load a new page every time a user
clicks a button :-)
  -Eric


- -- 
 Eric Andreychek              | Lucy: "What happens if you practice the
 Eric Conspiracy Secret Labs  |  piano for 20 years and then end up not
 suppressed         |  being rich and famous?"
 http://openthought.net       | Schroeder: "The joy is in the playing."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQFANSbRR5UKaDAjAG4RAkbsAJ9bM5C9Ok0v6jZ2I6SiuEywNb4kjwCgsa8l
bof7XRfQukgb9Zwakxi4hIA=
=vODC
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.