Mailing List Archive

chained requests
Hi

How do I create a single controller, that would be able to handle the
following requests

/test/productA/create

and

/test/productB/create


--
Kind regards,

Theo Bot
Re: chained requests [ In reply to ]
Theo
You can create a single Products controller with two methods to handle those paths

#Path:- /test/productA/create
sub create_a :Global :Path('/test/productA/create'){
my $self = shift;
my $c = shift;
}

#Path:- /test/productB/create
sub create_b :Global :Path('/test/productB/create'){
my $self = shift;
my $c = shift;
}

Thanks

Tony B. Okusanya

From: catalyst-bounces@lists.scsys.co.uk [mailto:catalyst-bounces@lists.scsys.co.uk] On Behalf Of Theo Bot
Sent: Friday, November 03, 2017 9:52 AM
To: The elegant MVC web framework <catalyst@lists.scsys.co.uk>
Subject: [EXTERNAL] [Catalyst] chained requests

Hi
How do I create a single controller, that would be able to handle the following requests
/test/productA/create
and
/test/productB/create


--
Kind regards,

Theo Bot


U.S. BANCORP made the following annotations
---------------------------------------------------------------------
Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation.

---------------------------------------------------------------------
Re: chained requests [ In reply to ]
Hi Theo,

I hope that these resources on chained action methods will help you get started:

From the Catalyst Manual…
https://metacpan.org/pod/distribution/Catalyst-Manual/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod#CONVERT-TO-A-CHAINED-ACTION

Examples from the Catalyst wiki…
http://wiki.catalystframework.org/wiki/gettingstarted/howtos/chainedexamples.view

A Catalyst advent calendar entry…
http://www.catalystframework.org/calendar/2006/10


Here is a code snippet that could work for your case…

# see also ChainedParent for non-Root controllers
sub base : Chained(‘/’) PathPart(‘test’) CaptureArgs(1) {
my ($self, $c, $product_id) = @_;
# do something with $product_id
}

sub create : Chained(‘base’) PathPart(‘create’) Args(0) {
my ($self, $c) = @_;
}

Best,
--Trevor

From: catalyst-bounces@lists.scsys.co.uk [mailto:catalyst-bounces@lists.scsys.co.uk] On Behalf Of Theo Bot
Sent: Friday, November 3, 2017 7:52 AM
To: The elegant MVC web framework <catalyst@lists.scsys.co.uk>
Subject: [Catalyst] chained requests

Hi
How do I create a single controller, that would be able to handle the following requests
/test/productA/create
and
/test/productB/create


--
Kind regards,

Theo Bot
Re: chained requests [ In reply to ]
Trevor,

Thanks, I think I can get this to work.

Regards, Theo

On Tue, Nov 7, 2017 at 9:36 PM, Trevor Leffler <tleffler@uw.edu> wrote:

> Hi Theo,
>
>
>
> I hope that these resources on chained action methods will help you get
> started:
>
>
>
> From the Catalyst Manual…
>
> https://metacpan.org/pod/distribution/Catalyst-Manual/
> lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod#CONVERT-TO-A-CHAINED-ACTION
>
>
>
> Examples from the Catalyst wiki…
>
> http://wiki.catalystframework.org/wiki/gettingstarted/
> howtos/chainedexamples.view
>
>
>
> A Catalyst advent calendar entry…
>
> http://www.catalystframework.org/calendar/2006/10
>
>
>
>
>
> Here is a code snippet that could work for your case…
>
>
>
> # see also ChainedParent for non-Root controllers
>
> sub base : Chained(‘/’) PathPart(‘test’) CaptureArgs(1) {
>
> my ($self, $c, $product_id) = @_;
>
> # do something with $product_id
>
> }
>
>
>
> sub create : Chained(‘base’) PathPart(‘create’) Args(0) {
>
> my ($self, $c) = @_;
>
> }
>
>
>
> Best,
>
> --Trevor
>
>
>
> *From:* catalyst-bounces@lists.scsys.co.uk [mailto:catalyst-bounces@
> lists.scsys.co.uk] *On Behalf Of *Theo Bot
> *Sent:* Friday, November 3, 2017 7:52 AM
> *To:* The elegant MVC web framework <catalyst@lists.scsys.co.uk>
> *Subject:* [Catalyst] chained requests
>
>
>
> Hi
>
> How do I create a single controller, that would be able to handle the
> following requests
>
> /test/productA/create
>
> and
>
> /test/productB/create
>
>
>
> --
>
> Kind regards,
>
> Theo Bot
>
> _______________________________________________
> List: Catalyst@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/
>
>


--
Met vriendelijke groet,

Theo Bot