Le forum (ô combien francophone) des utilisateurs de Powerbuilder.
Pages: 1
Discussion fermée
1) Création d'un profil de connexion
Dans PowerBuilder, cliquer sur le bouton Application server profiles
:
Entrer les valeurs suivantes :
* Profile name : asp_jboss
* Server type : JBoss
* Serveur name : <le nom de la machine>
* Port : 9000
* Login name : admin@system
* Password : <le mot de passe entré lors de la configuration>
Cliquer sur Test
pour vérifier que la connexion est ok.
2) Création de l'environnement (workspace, target, librairie)
Créer un workspace jboss.pbw
, une target jboss.pbt
et une librairie jboss.pbl
avec une application sans wizard jboss
(original non ? )_
3) Création d'un NVO
Cliquer sur New
, dans l'onglet PB Object
choisir Custom Class
Créer une fonction of_hello_world( as_nom )
public function string of_hello_world(string as_nom); String ls_html ls_html = 'Hello ' + as_nom + ' !<br />It is ' + String( Now(), 'hh:mm:ss' ) & + '.<br />Enjoy PB to the web !' Return ls_html end function
Enregistrer la classe sous : n_hello_world
4) Création du composant pour le serveur d'application
Cliquer sur New
, dans l'onglet Project
choisir Application Server Component Wizard
, entrer les paramètres suivants :
* Destination library : jboss.pbl
* Project : p_jboss_appscomps
(par défaut)
* Components : cocher n_hello_world
* Application server profile : choisir asp_jboss
* Package Name : pkg_hello_world
* tout le reste : valeurs par défaut.
Cliquer sur Deploy
. Pour avoir une idée de tous les fichiers générés, jeter un coup d'oeil dans :C:\PBAppServer1\deploy\
C:\PBAppServer1\repository\
C:\jboss-4.0.5.GA\server\default\deploy\
Les caractéristiques du bean (~NVO) sont trouvées dans les fichiers :C:\PBAppServer1\deploy\ejbjars\pkg_hello_world\META-INF\jboss.xml
C:\PBAppServer1\deploy\ejbjars\pkg_hello_world\META-INF\ejb-jar.xml
5) Appel du composant sur le serveur web
5.1) page JSP
Enregistrer dans C:\jboss-4.0.5.GA\server\default\deploy\jbossweb-tomcat55.sar\ROOT.war\hello_world.jsp
le code suivant :
<%@ page language="java" buffer="8kb" autoFlush="true" isThreadSafe="true" isErrorPage="false" import="javax.rmi.*,javax.naming.*,pkg_hello_world.ejb.*" %> <% // déclarations String ls_nom, ls_html ; n_hello_world lnv_hello_world; InitialContext ljo_context = new InitialContext(); // récupération paramètre de page ?nom= if (request.getParameter("nom") == null) { ls_nom = new String( "visitor" ) ; } else { ls_nom = request.getParameter( "nom" ); } // instanciation NVO lnv_hello_world = ((n_hello_worldHome) PortableRemoteObject.narrow( ljo_context.lookup( "pkg_hello_world/n_hello_world" ),n_hello_worldHome.class )).create() ; // code HTML ls_html = lnv_hello_world.of_hello_world( ls_nom ) ; %> <html> <head> <title>Tutorial PBWeb+JBoss</title> </head> <body> <br /> <%=ls_html%> <br /> </body> </html>
Pour l'édition JSP avec coloration syntaxique si vous n'avez pas d'IDE Java ou d'éditeur approprié, jetez un coup d'oeil à SciTE (1,2Mo)
5.2) test de la page
Lancer : http://localhost:8080/hello_world.jsp?nom=Jo l'indien
NB : bien évidemment il s'agit d'un tutorial, le même effet peut-être obtenu avec 3 lignes de code JSP...
Dernière modification par eRaSorZ (22-02-2007 17:07:43)
Hors ligne
Discussion fermée
Pages: 1