Re: [cgiapp] RFC: CGI::Application::Plugin::AJAX v0.02

2005-07-06 Thread Paul Campbell
On 05/07/05, Paul Campbell <[EMAIL PROTECTED]> wrote:
> 
> I'm thinking about upgrading to 4.x of CGIApp so I can get access to
> these callbacks.  Developing on Debian/Etch which is still on
> CGIApp-3.31.

Correcting myself:  Etch appears to have upgraded to 4.01 when I wasn't looking.

-- 
Paul Campbell
<[EMAIL PROTECTED]>
http://kemitix.net/bitware/

-
Web Archive:  http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
  http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [cgiapp] RFC: CGI::Application::Plugin::AJAX v0.02

2005-07-05 Thread Paul Campbell
On 05/07/05, Michael Peters <[EMAIL PROTECTED]> wrote:
> Paul Campbell wrote:
> > I'm interested in any feedback anyone might have for this module.
> 
> I know that you probably wrote most of this before the full callback
> system was done, but it would be really neat if more of this was
> invisible to the user. For instance
> 
>$self->run_modes
> (
> 'index'=> 'index',
> 'multiply' => 'multiply',
> 'divide'   => 'divide',
> 'upload'   => 'upload',
> &AJAX_run_modes,
> );
> 
> You don't need the &AJAX_run_modes() since your plugin can register them
> behind the scenes.

I'm thinking about upgrading to 4.x of CGIApp so I can get access to
these callbacks.  Developing on Debian/Etch which is still on
CGIApp-3.31.

I want to make it transparent.  Really, I do.  So much so, that
getting rid of this specific call is mentioned in the [1]TODO file.

[1] http://kemitix.net/cgi-bin/darcs.cgi/cap-ajax/TODO?c=annotate

> sub index
> {
> my $self = shift;
> my $ajax_client = AJAX_load_client;
> my $ajax_init   = AJAX_init;
> ...
> my $html = < 
> 
> Kemitix::AJAX::App::TestCGIApp
> $ajax_client
> 
> 
>...
> }
> 
> It would be wicked cool if you used a callback registered at postrun to
> actually post process the HTML to add this javascript to the  and
>  tags itself. Another feature that now becomes invisible to the user.

Now /that/ is an idea.  Of course, we'd need to include an option to
disable it, just in-case someone doesn't want the HTML post-processed.
 That, I think, will be going onto the TODO list.  Thanks.

> As for the AJAX_register_run_mode(), I got a little confused as to which
> portions where Perl and which were JavaScript on the initial reading.
> I'm still not completely certain of how it works but maybe that would
> become clearer as I play with it some more.

That confusion struck me too.  Given that we are mixing JavaScript and
Perl code into the same file, that is going to happen.  Unless we
moved the JavaScript out to another file (XML?) that defined the
JavaScript components.  We loose the ability to use interpolation from
Perl variables into the JavaScript.  Not that I can think of an
immediate instance where that would be useful - but I'm sure someone
could come up with one given time and the opportunity.

If the whole register_run_mode element was moved out to an XML file
(pulling this format out of the air):


















// javascript code
var t1val = ajax_elid('term1').value;
var t2val = ajax_elid('term2').value;
var t3val = ajax_elid('term2').value; // this variable is here to confuse you
if(length(t1val) && length(t2val)){ return true; }
return false; // don't call server if either term is blank














// javascript code






Having written that I'm tempted by it, or something like it.  It would
give a seperation of JavaScript from the Perl.  I've tried my best to
allow HTML to be created with the only JavaScript visible in the BODY
onload attribute, then gone and mixed JS in with Perl. I don't know
about your text editors, but might gets confused trying to highlight
it meaningfully.

There is more information available in the [2]repository to explain
where all the different parts of AJAX_register_run_mode are for and
how they work together.  Such as the trigger must return true or the
ajax_client won't actually make the request to the server.  Admittedly
that last bit still has to be written into it, but that is where that
'return true;' comes in.

[2] http://kemitix.net/repos/cap-ajax/README

I suppose this could be the justification for the X in AJAX. :P

-- 
Paul Campbell
<[EMAIL PROTECTED]>
http://kemitix.net/bitware/

-
Web Archive:  http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
  http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [cgiapp] RFC: CGI::Application::Plugin::AJAX v0.02

2005-07-05 Thread Michael Peters
Paul Campbell wrote:
> I'm interested in any feedback anyone might have for this module.

I know that you probably wrote most of this before the full callback
system was done, but it would be really neat if more of this was
invisible to the user. For instance

   $self->run_modes
(
'index'=> 'index',
'multiply' => 'multiply',
'divide'   => 'divide',
'upload'   => 'upload',
&AJAX_run_modes,
);

You don't need the &AJAX_run_modes() since your plugin can register them
behind the scenes.

sub index
{
my $self = shift;
my $ajax_client = AJAX_load_client;
my $ajax_init   = AJAX_init;
...
my $html = <

Kemitix::AJAX::App::TestCGIApp
$ajax_client


   ...
}

It would be wicked cool if you used a callback registered at postrun to
actually post process the HTML to add this javascript to the  and
 tags itself. Another feature that now becomes invisible to the user.

As for the AJAX_register_run_mode(), I got a little confused as to which
portions where Perl and which were JavaScript on the initial reading.
I'm still not completely certain of how it works but maybe that would
become clearer as I play with it some more.

-- 
Michael Peters
Developer
Plus Three, LP


-
Web Archive:  http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
  http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [cgiapp] RFC: CGI::Application::Plugin::AJAX v0.02

2005-07-04 Thread Steve Comrie

Paul,

I haven't had a chance yet to take a look at your Plugin. I intend too, 
I'm just a little busy getting back into the swing after most of last 
week out the window with YAPC and Canada day on friday.


I've previously done some C::A work with XMLHttpRequest and based my 
code off the SAJAX stuff to, although mine wasn't in plugin format.


Here's the mailing list archive:
http://www.mail-archive.com/cgiapp@lists.erlbaum.net/msg03078.html

My test code is running at:
http://www.unobserved.org/misc/rs/

Not sure whether or not there are differences / similarities in our 
code, but if you are intending on moving ahead with a C:A:P:Ajax plugin 
I'd be more then willing to collaborate with you on it.


---
Steve Comrie

Paul Campbell wrote:


I'm interested in any feedback anyone might have for this module.

More information:
http://kemitix.net/bitware/2005/07/02/cgiapplicationpluginajax-v002/

Download the code, including demo:
http://kemitix.net/files/cgiapp/CGI-Application-Plugin-AJAX-0.02.tar.gz

###

The buzzword of the moment in web development would appear to be
'AJAX'. Basically it is the use of the JavaScript accessible object
XMLHttpRequest to update the current webpage without have to go
through a complete, and expensive, page refresh cycle with the remote
server. Instead using XMLHttpRequest's asynchronous behaviour and an
appropriate JavaScript callback the updates are performed in the
background. Indeed several could be going on simultaneously.

What I have attempted here with CGI::Application::Plugin::AJAX is to
create a proof of concept that implements a flexible AJAX framework
into a CGI::Application module. The JavaScript comprising the core of
the AJAX client is a modification of [1]SAJAX.

[1] http://www.modernmethod.com/sajax/

I have a standard run-of-the-mill [2]demo. It implements what appears
to be the Hello World of AJAX: Multiply and Divide. There is also a
File Uploader. (Note: the file uploaded sends the file back to you, so
don't upload anything too large, neither you nor I will like it.)

[2] http://kemitix.net/cap-ajax/

Run modes are registered together with the JavaScript involved:

AJAX_register_run_mode
(
   'multiply' => 
   {

   # what element to attach the event to
   id => 'btnMultiply',

   # which event to attach to - onclick is the default if not given
   event => 'onclick',  


   # what to do when the above event it triggered
   trigger  => "
   var term1 = ajax_elid('term1').value;
   var term2 = ajax_elid('term2').value;
   ",

   # which CGI parameters are passed using which values
   # a parameter can be associated with an array for multiple values
   cgiargs  => 
   { # map the cgi argument names to the values

 # gathered by the trigger
   term1  => 'term1',
   term2  => ['term2'],
   },

   # Once the server replies, this is what we do with the answer
   callback => "
   ajax_elid('result').innerHTML = '= ' + result;
   ajax_elid('symbol').innerHTML = '*';
   ",
   }
);

NOTE: Although I have named this module within an existing Namespace,
I am not claiming it. I'm open to suggestions for a more appropriate
name for the plugin.

Thanks for any comments you can give.

 



--

Steve Comrie
LEAD SOFTWARE ARCHITECT | OCTANE

T: 416.977.2525
F: 416.977.8481

355 ADELAIDE ST. W. SUITE 1B
TORONTO, ONTARIO  M5V 1S2

WWW.OCTANE.TO 



Re: [cgiapp] RFC: CGI::Application::Plugin::AJAX v0.02

2005-07-03 Thread Paul Campbell
On 03/07/05, Ron Savage <[EMAIL PROTECTED]> wrote:
> On Sun, 3 Jul 2005 01:02:49 +0100, Paul Campbell wrote:
> 
> Hi Paul
> 
> > # Once the server replies, this is what we do with the answer
> > callback => "
> > ajax_elid('result').innerHTML = '= ' + result;
> > ajax_elid('symbol').innerHTML = '*'; ", } );
> 
> Which browsers support innerHTML?

Went looking to find out...

So innerHTML is a MS proprietary extension that isn't part of the DOM
standard that happens to be supported by Firefox.  Presumably because
it is used by so many sites.  Thus testing on FF and IE didn't show it
as being a problem.

So a DOM-way of doing the same would be:

ajax_elid('result').childNodes[0].nodeValue = '= ' + result;
ajax_elid('symbol').childNodes[0].nodeValue = '*';

However, this fails if the node is empty.  ('Has no properties').  A
helper/wrapper to check for that and add a childNode would be useful.

I appreciate your comment, Ron.  Thanks.

I'll refrain from working out a complete wrapper here, but will put
one into the distribution.

-- 
Paul Campbell
<[EMAIL PROTECTED]>
http://kemitix.net/blog/cossmass/pbem/

-
Web Archive:  http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
  http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [cgiapp] RFC: CGI::Application::Plugin::AJAX v0.02

2005-07-02 Thread Ron Savage
On Sun, 3 Jul 2005 01:02:49 +0100, Paul Campbell wrote:

Hi Paul

> # Once the server replies, this is what we do with the answer
> callback => "
> ajax_elid('result').innerHTML = '= ' + result;
> ajax_elid('symbol').innerHTML = '*'; ", } );

Which browsers support innerHTML?
--
Cheers
Ron Savage, [EMAIL PROTECTED] on 3/07/2005
http://savage.net.au/index.html
Let the record show: Microsoft is not an Australian company



-
Web Archive:  http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
  http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[cgiapp] RFC: CGI::Application::Plugin::AJAX v0.02

2005-07-02 Thread Paul Campbell
I'm interested in any feedback anyone might have for this module.

More information:
http://kemitix.net/bitware/2005/07/02/cgiapplicationpluginajax-v002/

Download the code, including demo:
http://kemitix.net/files/cgiapp/CGI-Application-Plugin-AJAX-0.02.tar.gz

###

The buzzword of the moment in web development would appear to be
'AJAX'. Basically it is the use of the JavaScript accessible object
XMLHttpRequest to update the current webpage without have to go
through a complete, and expensive, page refresh cycle with the remote
server. Instead using XMLHttpRequest's asynchronous behaviour and an
appropriate JavaScript callback the updates are performed in the
background. Indeed several could be going on simultaneously.

What I have attempted here with CGI::Application::Plugin::AJAX is to
create a proof of concept that implements a flexible AJAX framework
into a CGI::Application module. The JavaScript comprising the core of
the AJAX client is a modification of [1]SAJAX.

[1] http://www.modernmethod.com/sajax/

I have a standard run-of-the-mill [2]demo. It implements what appears
to be the Hello World of AJAX: Multiply and Divide. There is also a
File Uploader. (Note: the file uploaded sends the file back to you, so
don't upload anything too large, neither you nor I will like it.)

[2] http://kemitix.net/cap-ajax/

Run modes are registered together with the JavaScript involved:

AJAX_register_run_mode
(
'multiply' => 
{
# what element to attach the event to
id => 'btnMultiply',

# which event to attach to - onclick is the default if not given
event => 'onclick',  

# what to do when the above event it triggered
trigger  => "
var term1 = ajax_elid('term1').value;
var term2 = ajax_elid('term2').value;
",

# which CGI parameters are passed using which values
# a parameter can be associated with an array for multiple values
cgiargs  => 
{ # map the cgi argument names to the values
  # gathered by the trigger
term1  => 'term1',
term2  => ['term2'],
},

# Once the server replies, this is what we do with the answer
callback => "
ajax_elid('result').innerHTML = '= ' + result;
ajax_elid('symbol').innerHTML = '*';
",
}
);

NOTE: Although I have named this module within an existing Namespace,
I am not claiming it. I'm open to suggestions for a more appropriate
name for the plugin.

Thanks for any comments you can give.

-- 
Paul Campbell
<[EMAIL PROTECTED]>
http://kemitix.net/bitware/

-
Web Archive:  http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
  http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]