Re: PHP
Doug Kirk <[email protected]> Tue, 25 May 2004 14:38:19 -0500
| Newsgroups | gmane.comp.web.maverick.general |
|---|---|
| Message-ID | <[email protected]> |
The easiest way is to simply create some new Velocity templates that
provide you an easily parseable (from PHP) representation of the data
you need. Then just wrap the client request with a request to the
Maverick + Velocity processed pages using alternate Velocity templates
for the "view" layer. Since Velocity is just a nifty templating engine,
there's nothing that says that you have to output HTML, or XML, or
markup for that matter.
The really cool thing is that you can retain the existing user URLs if
you want, and simply specify a different view with a request parameter
(which a user with a browser would never do) to get to the alternate
Velocity template. Then, you're simply adding to the existing system
instead of replacing it. Maverick would just have to be configured to
dispatch to the alternate views.
For example a Velocity template like this:
---------Start of Velocity Template--------
$!firstName^$!lastName^$!email^$!phone
---------End of Velocity Template--------
(where the "$" indicates a Velocity variable,
the "!" indicates not to output anything if the value is null,
and the values are simply separated with "^" in a single line.
Velocity docs are at <http://jakarta.apache.org/velocity/>)
...can be processed like this:
<?php
$url = "http://localhost/my/java/url?param=value&view=data"; //
...set the Maverick+Velocity URL to read, with params
$f = fopen ("$url", "r");
$data = fread($f, 65536); // Get the result of Java+Velocity output
fclose($f);
// Now process the results in $data...
$results = explode("^", $data); // assuming variable-length
data separated by "^"
$firstName = $results[0];
$lastName = $results[1];
$email = $results[2];
$phone = $results[3];
// etc...
?>
--doug
On May 25, 2004, at 1:21 PM, Lee McColl wrote:
Hi all,
I've recently teamed up with an applications developer to offer my web
development skills and am currently picking apart his software. He
currently has a nifty Java based server app which displays information
through Maverick and Velocity. I believe there are lines in his
Maverick Web.xml that read -
<servlet>
<servlet-name>velocityViewer</servlet-name>
<servlet-class>net.nt.frontend.servlets.VelocityViewer</servlet-class>
<load-on-startup>10</load-on-startup>
</servlet>
It is these lines that I am assuming allow his Java server app to send
properties and results to his Velocity pages.
Anyway, what I want to do, if it is at all possible, is to change his
system so that it sends the information to and through PHP pages. I'm
happy to continue using Maverick if I can, but seeing as the system I
built that bolts onto his software uses PHP, I would like to exchange
all the .vm pages to also use the same PHP classes. Make sense? (I
babble).
How can I do this? And if it's not possible with Maverick, what system
can I use?
I originally thought Ambivalence was made for this, but having read the
manual for it, it now seems more like a PHP templating system to
seperate PHP code from the presentation, much like Maverick seperates
Java from presentation.... But I've already built the PHP templating
system using other means.
Please please help,
Lee
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_id66&op=click
[INVALID FOOTER]