Home  |  Linux  | Mysql  | PHP  | XML
From:Gurunandan R. Bhat Date:Tue Jun 30 04:20:28 2009
Subject:Re: Rendering data structures using CGI::Application
Sure. I think you would like to have the error messages next to the sub
that threw them, but here is what you want: (NOT TESTED!!)

In your module:

my $messages = [
	{text => 'quantity is undefined, zero or illegal'},
	{text => 'amount is undefined or illegal'},
	{text => 'payment is undefined or illegal'},
];

my $stack = [
	{
		sub => undef,
		filename => 'tests/purchase.pl',
		line => 43,
		package => 'main',
	},
	{
		sub => 'ISP::Transac::create_transaction',
		filename => '/usr/local/lib/perl5/site_perl/5.8.9/ISP/Transac.pm',
		line => 32,
		package => 'ISP::Transac',
	},
	{
		sub => 'ISP::Sanity::transaction_data',
		filename => '/usr/local/lib/perl5/site_perl/5.8.9/ISP/Sanity.pm',
		line => 55,
		package => 'ISP::Sanity',
	},
];

my $tpl = $app->load_tmpl('templatefile.tpl', die_on_bad_params => 0);
$tpl->param(
	MESSAGES => $messages,
	STACK => $stack,
);

return $tpl->output;

In your template file

<ul>
<!-- TMPL_LOOP NAME=MESSAGES -->
	<li><!-- TMPL_VAR NAME=TEXT --></li>
<!-- /TMPL_LOOP -->
</ul>

<ul>
<!-- TMPL_LOOP NAME=STACK -->
	<li>
	<ul>
	<!-- TMPL_VAR NAME=sub --><br />
	<!-- TMPL_VAR NAME=filename --><br />
	<!-- TMPL_VAR NAME=line --><br />
	<!-- TMPL_VAR NAME=package -->
	</ul>
	</li>
<!-- /TMPL_LOOP -->

	

HTH


On Mon, 2009-06-29 at 23:51 -0400, Steve Bertrand wrote:
> Gurunandan R. Bhat wrote:
> > How do you want the output to look? If you write in a sample output, I
> > could help with the template to generate that output
> 
> I would be extremely delighted to even get the following rendered for
> now, given the Data::Dumper output below. If I had a decent example,
> then I'd be able to learn from it, and go from there:
> 
> --- output displayed as I'd see it in the browser---
> 
> Error messages:
> 
> quantity is undefined, zero or illegal
> amount is undefined or illegal
> payment is undefined or illegal
> 
> Stack trace:
> 
> sub => undef;
> filename => tests/purchase.pl
> line => 43
> package => main
> 
> sub => ISP::Transac::create_transaction
> filename => /usr/local/lib/perl5/site_perl/5.8.9/ISP/Transac.pm
> line => 32
> package => ISP::Transac
> 
> sub => ISP::Sanity::transaction_data
> filename => /usr/local/lib/perl5/site_perl/5.8.9/ISP/Sanity.pm
> line => 55
> package => ISP::Sanity
> 
> --- end browser output ---
> 
> Here again is the actual data. $VAR1 is an array of the error messages,
> and $VAR2 is an array, where each element is a hash which represents a
> level in a stack trace.
> 
> $VAR1 = \[
>             'quantity is undefined, zero or illegal',
>             'amount is undefined or illegal',
>             'payment is undefined or illegal'
>           ];
> $VAR2 = \[
>             {
>               'sub' => undef,
>               'filename' => 'tests/purchase.pl',
>               'line' => 43,
>               'package' => 'main'
>             },
>             {
>               'sub' => 'ISP::Transac::create_transaction',
>               'filename' =>
> '/usr/local/lib/perl5/site_perl/5.8.9/ISP/Transac.pm',
>               'line' => 32,
>               'package' => 'ISP::Transac'
>             },
>             {
>               'sub' => 'ISP::Sanity::transaction_data',
>               'filename' =>
> '/usr/local/lib/perl5/site_perl/5.8.9/ISP/Sanity.pm',
>               'line' => 55,
>               'package' => 'ISP::Sanity'
>             }
>           ];
> 
> Thank you!
> 
> Steve

Navigate in group perl.beginners at sever nntp.perl.org
Previous Next


Your recent visits
Re: [PHP-WIN] problem with PEAR , windows platform , php 5.2.9-2 , IIS Version 6
Re: Substitution question
Re: [PHP-DB] PHP- Mysql problem
Re: [PHP-WIN] problem with PEAR , windows platform , php 5.2.9-2 , IIS Version 6
Appeon Application running without PowerBuilder on the server


  
© No Copyright
You are free to use Anything
Site Maintained by Zareef Ahmed
Powered By PHP Consultants