IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Bibliothèques et frameworks PHP Discussion :

[Framework] [PHP.MVC] Probleme de forward sur .tpl


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    Membre du Club
    Inscrit en
    Mai 2004
    Messages
    59
    Détails du profil
    Informations forums :
    Inscription : Mai 2004
    Messages : 59
    Points : 44
    Points
    44
    Par défaut [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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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:
    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 ?
    merci ....

  2. #2
    Rédacteur

    Homme Profil pro
    Geek entrepreneur
    Inscrit en
    Novembre 2004
    Messages
    1 224
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Geek entrepreneur

    Informations forums :
    Inscription : Novembre 2004
    Messages : 1 224
    Points : 2 373
    Points
    2 373
    Par défaut
    Je connais Struts mais pas php.mvc. A l'oeil nu je note uniquement la différence sur les chemins du tpl. Est ce qu'il ne devrait pas comporter l'arborescence pour y arriver ?
    Sinon pour débugger, t'as la possibilité de logger des choses. T'as déjà l'outils $this->log que j'ai vu dans le code qui doit servir a ca.
    Et sinon, tu peux aussi faire des écritures dans des fichiers. Ici ce qui serait intéressant c'est de vérifier que tu passes bien par la ou tu penses. Tu pourrais aussi faire un affichage de l'objet $mapping et du résultat du findForwardConfig dans un fichier.

  3. #3
    Membre du Club
    Inscrit en
    Mai 2004
    Messages
    59
    Détails du profil
    Informations forums :
    Inscription : Mai 2004
    Messages : 59
    Points : 44
    Points
    44
    Par défaut
    merci pour le coup d'oeil alors en fait il n'y a pas besoin de mettre l'arborescence complete du ficheir car dans un fichier de config on déclare tous les repertoires de l'application comem ceci:
    function getModulePaths() {

    // Setup the main module include() directories here
    // Note: could be placed in a n xml config file later !!
    $appDirs = array();
    $appDirs[] = ''; // starting with the sub-application home directory
    $appDirs[] = 'WEB-INF';
    $appDirs[] = 'WEB-INF/classes';
    $appDirs[] = 'WEB-INF/configRules';
    $appDirs[] = 'WEB-INF/data';
    $appDirs[] = 'WEB-INF/data/myspace';
    $appDirs[] = 'WEB-INF/tpl';

    return $appDirs;

    }
    ce bout de code ci marche vu que mes liens entre mes differentes actions, fomulaires ... fonctionnent car j'ai du corriger quelques erreures de sytnaxes mineures .... pour obtenir la page blanche que j'ai a présent.
    Je vais essayer de mettre en place les logs ... mais j'y arrive moyennement

Discussions similaires

  1. [PHP-JS] Probleme sur la validation w3c Strict
    Par Magicdemon dans le forum Langage
    Réponses: 4
    Dernier message: 05/09/2008, 16h06
  2. [PHP-JS] probleme lien sur bouton
    Par jguep dans le forum Langage
    Réponses: 2
    Dernier message: 11/01/2007, 11h26
  3. Réponses: 1
    Dernier message: 28/07/2006, 21h24
  4. [PHP-JS] Probleme sur connexion
    Par shub dans le forum Langage
    Réponses: 5
    Dernier message: 09/06/2006, 13h02

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo