[Catalyst] How to clear off request parameter element

2009-02-23 Thread kakimoto

hi all


 I have an app with a listing method in the controller. It goes a little
like this:

sub list
{
  # get object from model based on $c-request-param('id');

  IF (object)
  {
   return;
  }
  ELSE
  {
   return all objects belonging to the current user;
  }

return 1;
}



then , i have a deletion method which will delete a given object (by ID
specific in a form via POST method) and list out all objects belonging
to the current user.

sub delete
{
 # get specific object based on ID  ($c-request-param('id');)

  #delete object

 $c-forward( 'list' );
}


The problem here is that sub list will always call the
$c-request-param('id'); which is no longer valid once an object has
been deleted.

 What is the best way to delete the 'id' attribute off $c-request-param??

thank you.

K. akimoto

___
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/


Re: [Catalyst] How to clear off request parameter element

2009-02-23 Thread Jason Gottshall

kakim...@tpg.com.au wrote:

hi all


 I have an app with a listing method in the controller. It goes a little
like this:

sub list
{
  # get object from model based on $c-request-param('id');

  IF (object)
  {
   return;
  }
  ELSE
  {
   return all objects belonging to the current user;
  }

return 1;
}



then , i have a deletion method which will delete a given object (by ID
specific in a form via POST method) and list out all objects belonging
to the current user.

sub delete
{
 # get specific object based on ID  ($c-request-param('id');)

  #delete object

 $c-forward( 'list' );
}


The problem here is that sub list will always call the
$c-request-param('id'); which is no longer valid once an object has
been deleted.

 What is the best way to delete the 'id' attribute off $c-request-param??

thank you.

K. akimoto


What if, after the delete is performed, the user decides to bookmark the 
list of items? The bookmark will be the URL to delete, instead of the 
more appropriate URL to list. Instead of forwarding within the current 
request, you should consider an actual redirect to your list page. It 
admittedly does require an extra request cycle, but the user's 
experience will be more correct.


--
Jason Gottshall
jgottsh...@capwiz.com


___
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/