[Catalyst] Database contents not displayed after hitting page
refresh
cranky
sharath.g at hcl.in
Wed Sep 3 09:55:35 BST 2008
It's working now. Thanx Emmanuel, that really helped.
Emmanuel Quevillon-3 wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> cranky wrote:
>> Hi, I'm a newbie to catalyst. I have built a small app, similar to the
>> one in
>> catalyst manual (basic CRUD). I have a page wherein a <table> displays
>> its
>> contents after getting it from the database (SQLite3), the problem is, it
>> doesn't display the contents after I refresh the page.
>>
>> I'm using TT2 for html, here it is:
>>
>> ------------------------------------------------------
>> <table>
>> [% WHILE (item = data.next) %]
>> <tr>
>> <td> [% item.function | html %] </td>
>> <td> [% item.testdate | html %] </td>
>> <td> [% item.tester | html %] </td>
>> <td> [% item.qalead | html %]</td>
>> <td> [% item.nopassed | html %] </td>
>> </table>
>> -------------------------------------------------------
>>
>> and the perl code looks like this:
>>
>> -------------------------------------------------------
>> sub ShowData : Local {
>> my ($self, $c) = @_;
>> my $data = $c->model('Ttrack::Ttrack');
>> $c->stash->{data} = $data;
>> $c->stash->{template} = 'ShowData.tt2';
>> }
>> -------------------------------------------------------
>>
>> I generated the modules required under 'Model' by this command:
>>
>> C:\formdata\> perl script\formdata_create.pl model Ttrack DBIC::Schema
>> formdata::Schema::Ttrack create=static dbi:SQLite:database
>>
>> Where am I doing wrong?
>>
>
> Hi 'cranky',
>
> You need to perform a search in your 'ShowData' function to get data
> returned by the Resultset of your model 'Ttrack::Ttrack'.
> At this time, $data is only a resultset object without any data in it.
> Replace :
>
> my $data = $c->model('Ttrack::Ttrack');
>
> with
>
> my $data = $c->model('Ttrack::Ttrack')->search();
>
> This will return all the data contained inside your table Ttrack.
>
> Hope this will help.
>
> Regards
>
> Emmanuel
>
>
> - --
> - -------------------------
> Emmanuel Quevillon
> Biological Software and Databases Group
> Institut Pasteur
> +33 1 44 38 95 98
> tuco at_ pasteur dot fr
> - -------------------------
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFIvjb35ox+AMIKvTIRAhYfAKCDIRe8iSvmfVCDxhqDQ6jIDvB1rACeK6pQ
> K02JPJ6tRrarACA+k+fHIAk=
> =NaFY
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
--
View this message in context: http://www.nabble.com/Database-contents-not-displayed-after-hitting-page-refresh-tp19282861p19285358.html
Sent from the Catalyst Web Framework mailing list archive at Nabble.com.
More information about the Catalyst
mailing list