Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks
Bibliothèques et frameworks Forum d'entraide sur les frameworks, templates, bibliothèques de code (PDFLib, eZPdf, JpGraph, Artichow, PEAR, etc). Avant de poster : FAQ bibliothèques, toutes les FAQ PHP et cours bibliothèques
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 29/03/2006, 14h24   #1
Membre à l'essai
 
Inscription : mai 2004
Messages : 59
Détails du profil
Informations forums :
Inscription : mai 2004
Messages : 59
Points : 24
Points : 24
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 :
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 ?
merci ....
the_edge est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 29/03/2006, 14h47   #2
Rédacteur
 
Homme
Geek entrepreneur
Inscription : novembre 2004
Messages : 1 035
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Geek entrepreneur

Informations forums :
Inscription : novembre 2004
Messages : 1 035
Points : 1 813
Points : 1 813
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.
hugo123 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 29/03/2006, 15h23   #3
Membre à l'essai
 
Inscription : mai 2004
Messages : 59
Détails du profil
Informations forums :
Inscription : mai 2004
Messages : 59
Points : 24
Points : 24
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:
Citation:
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
the_edge est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 22h55.


 
 
 
 
Partenaires

Hébergement Web