I'm trying to use an object to represent a column. The value is the
database is a potentially long string (and that is what I want to keep
in the database :) but when it is displayed, I want to format it into
lines of a reasonable length. I have written a class (see below) and
added this line in my driver class:
QD1::Sequence->has_a(seq => 'my_seq', deflate => 'deflate');
This works when displaying a list, but when I click on edit I get an
empty space where the textbox should be:
<p><b>Seq</b>: </p><input TYPE="submit" NAME="edit" VALUE="edit">
What am I doing wrong?
Thanks, Dave
--package my_seq;
# Class to prepare seq column entries for display
use strict; use warnings;
use overload ( '""' => \&display );
our $VERSION = '0.01'; my $line_length = 60;
# A blessed array [$value] would be better than the single-element hash # but HTML::Element can't cope with that :(
sub new { my ($proto, $value) = @_; my($class) = ref $proto || $proto; print STDERR "my_seq::new\n"; bless {seq=>$value}, $class; }
sub display { my $self = shift; print STDERR "my_seq::display\n"; my $seq = $self->{seq}; my $length = length $seq; my @result; for (my $pos = 0; $pos < $length; $pos += $line_length) { push @result, substr($seq, $pos, $line_length); }
return join "\n", @result; }
sub deflate { print STDERR "my_seq::deflate()\n"; return $_[0]->{seq}; }
sub line_length { my $self = shift; $line_length = $_[0] if @_ and $_[0] >= 1; return $line_length; }
_______________________________________________ maypole mailing list maypole at lists.netthink.co.uk http://lists.netthink.co.uk/listinfo/maypole
This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:56 GMT