[Framework] [PHP.MVC] Probleme de forward sur .tpl
Bonjour,
j'essaie de prendre en main le portage PHP du framework JAVA Struts qui est PHP.MVC. J'ai deux soucis dessus, le premier s'adresse a ceux qui connaissent le framework surtout...:
dans mon ficher de config j'ai paramétré l'action suivante:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
<form-beans>
<!-- Show Basket form bean (checks ShowBasket form variables) -->
<!-- Note: name="MyXpaceForm matches action name = "MyXpaceForm" -->
<form-bean name="MyXpaceForm" type="MyXpaceForm"/>
<form-bean name="MySpaceForm" type="MySpaceForm"/>
</form-beans>
<!-- ========== Action Mapping Definitions ============================== -->
<action-mappings>
<action path = "MySpaceAction"
type = "MySpaceAction"
name = "MySpaceForm"
scope = "request"
validate = "false"
input = "MySpace.tpl"
parameter = "submit">
<!-- Forwards: We Forward by default (redirect="false") -->
<forward name="MySpace-open" path="MySpace.tpl"/>
<!--<forward name="failure" path="myErrorPage.tpl"/>-->
</action>
</action-mappings> |
j'ai crée un formulaire, une action et une vue associée:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| lass MySpaceForm extends ActionForm {
// ----- Instance Variables --------------------------------------------- //
var $toto;
// ----- Public Methods ------------------------------------------------- //
function setToto($toto) {
$this->toto = $toto;
}
function getToto($toto) {
return $this->toto;
}
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
| <?php
/*
* $Header: kooka/WEB-INF/classes/CartAction.php
* $Revision:
* $Date: 2003.03.30
*
* ====================================================================
*
* License: GNU General Public License
*
* Copyright (c) 2002,2003 John C.Wildenauer. All rights reserved.
*
* This file is part of php.MVC.
*
* php.MVC is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* php.MVC is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
/**
* Implementation of an <strong>Action</strong> class that provides a mapping
* from a submit button name or request parameter to a particular action
* method.
*
* @author John C Wildenauer (php.MVC port)<br>
* Credits: Craig R. McClanahan (Jakata Struts class: see jakarta.apache.org)
* @version
* @public
*/
class MySpaceAction extends Action{
//class MySpaceAction extends LookupDispatchAction{
// ----- Instance Variables --------------------------------------------- //
/**
* The <code>Log</code> instance for this application.
* @private
* @type Log
*
*var $log = NULL;*/
/**
* The mySpace default Action class path.<br>
* Eg: 'mySpaceAction' => MySpaceAction
* @private
* @type string
*/
var $actionPath = 'mySpaceAction';
// ----- Constructor ---------------------------------------------------- //
/* function MySpace() {
// Setup the base class first
// Base name of the KookaKart properties file
$config = 'LocalStringsKooka_en_AU';
parent::LookupDispatchAction($config);
$this->log = new Log();
$this->log->setLog('isTraceEnabled' , False);
$this->log->setLog('isDebugEnabled' , False);
$this->log->setLog('isErrorEnabled' , False);
}*/
// ----- Protected Methods ---------------------------------------------- //
/**
* A lookup table that provides a mapping from a string resource item
* (LocalStringsKooka.properties) to a method name in this class.
*
* <p>Returns an array of key/value pairs.
*
* @public
* @returns array
*/
function getKeyMethodMap() {
// LocalStringsKooka.properties key => CartAction->function()
$map = array();
$map['link.MySpace-open'] = 'openMySpace'; // List the cart (shopping)
return $map;
}
// ----- Public Methods ------------------------------------------------- //
/**
* Display the shopping cart (browse items).
*
* @param ActionMapping The ActionMapping we are using
* @param ActionForm The ActionForm instance
* @param HttpRequestBase The server request we are processing
* @param HttpResponseBase The server response we are creating
* @public
* @returns ForwardConfig
*/
function openMySpace($mapping, $form, &$request, &$response) {
// Forward control to the specified success URI
return $mapping->findForwardConfig('MySpace-open');
#return $mapping->findForwardConfig('failure');
}
}
?> |
et le fichier MySpace.tpl est bien définit, j'écrit dedans une chaine de caractère toto pour tester la redirection de mon action. Or sur l'appel de l'url:
Citation:
http://localhost/myproject/MyXpace/Main.php?do=MySpaceAction&submit=openMySpace
je tombe sur une page blanche.... comem si le forward n'avait pas fonctionné ... si je supprime mon fichier tpl, j'obtiens le meme résultat.... je comprends pas trop pourquoi ce comportement, et je ne sais pas trop commetn debugger.... (en JAVA je pouvais placer des points d'arret mais ici .... c'est pas le cas...) qqn connait suffisemment ce framework pour savoir quel est mon probleme ? :roll:
merci ....