perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert <rob...@robert.cz>
Subject (Emb)perl & JavaScript
Date Sun, 01 Sep 2002 16:57:20 GMT
Hi,

  I'd like to have a (emb)perl library that would hide the JavaScript
ugliness behind couple of simple Perl calls, but I can't find anything
interesting. Ideally it would work in the Embperl::Form::Validate way,
but offered more advanced stuff like (database) table edit widget,
inteligent date widget, menu tree widget etc. Have anybody heard about
such thing? If not would there be any person interested in using and/or
creating it? Here's an example of what I'm talking about: To edit bigger
part of the (database) table at once, as opposed to the editing it line
by line (eg, editing lines on the invoice), you would write something
like example below (working demo is on
http://www.robert.cz/misc/table-edit-demo.html ). Any comments?

- Robert

PS1 I use something close to the demo code in a real life project and it
seems to work quite fine. Now I want more... ;-)
PS2 You need IE5+ or Moz1+ to view the demo.


============================================================================================================

[-

use TableEdit;

# init table data with DBIx::Recordset or whichever way you want, just
make sure it's array of hashes
# *set = DBIx::Recordset->Search(...);
@set = (
	{ id => 101, firstname => 'Gerald',   lastname => 'Richter', age =>
'36', country => 'DE' },
	{ id => 102, firstname => 'Sherlock', lastname => 'Holmes',  age =>
'46', country => 'UK' },
	{ id => 103, firstname => 'Robert',   lastname => '',        age =>
'34', country => 'CZ' },
);

@table_def = (
	{ field => 'firstname', title => 'First Name', width => '140', align =>
'left' },
	{ field => 'lastname',  title => 'Last Name',  width => '160', align =>
'right' },
	{ field => 'age',       title => 'Age',        width => '80',  default
=> '18', },
	{ field => 'country',   title => 'Country',    width => '90',  default
=> 'CZ', 
		select => [ [ 'CZ', 'DE', 'UK', 'US' ], [ 'Czech Rep.', 'Germany',
'U.K.', 'USA' ] ] },
	{ field => 'id', title => 'Id', width => '0' },

if ($req_rec->method eq 'POST') {
	@tmp = @{ fdat2rset( \%fdat, \@table_def ) };
	foreach $r (@tmp) {
		# save data line by line with DBIx::Recordset or whichever way you
want 
		# $set->Update({ $record }) if $r->{status} eq 'UPDATE';
		# $set->Delete({ $record }) if $r->{status} eq 'DELETE';
		# $set->Insert({ $record }) if $r->{status} eq 'INSERT';
	}
	# exit & redirect back to the edit mode
}

-]


<body>

<h1>TableEdit Demo</h1>

<form method=post>
	<input readonly onClick='mlAddLine(); return false;' class=mlButton
value='NEW LINE'>
	[+ table_edit( \@table_def, \@set ) +]<hr>
<input type=submit class=mlButton value='SAVE FORM'>
</form>
</body>

============================================================================================================


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


Mime
View raw message