I am new to web programming but have experience working on perl scripts that have to do with file processing. Recently got a copy of MVC project source code. As I am trying to come to terms with template files, control & view modules, one question that came across is:
I see the template file in .tt extension(mypage.tt), there is the control module in .pm extension(MyPage.pm)) containing handler function to call the template and call to process subroutine in the View module(View.pm). But how does it generate .pl or html. I can't seem to find a perl executable or html file in the project. What should i enter in my url under
localhost/myapp/....
to call execute the script
I have loaded the project in my local directory with apache & mod_perl installed. Would be helpful if someone can explain if i need to write a perl script to call the handler function in the .pm file and generate the html if that's not too much to ask for :).
You project, if it is really a mod_perl app will have Apache configuration that maps URLs to handler methods.
Template files with a .tt extension typically are from the Template Toolkit, and perform their generation step by calling a method called process() on an instance of Template.
So you need to find the Apache handlers. They will tell you which methods are running, and then you can read hose methods to see how the template toolkit is being employed to generate the HTML.
Related
The compiled JavaScript output of a GWT application is divided into various files, for instance
*.cache.html
*.gwt.rpc
hosted.html
*.nocache.js
...
I know this is done with the purpose of minimizing the size of the JavaScript, which has to be downloaded by users. For instance so that a Firefox user does not have to load the JavaScript specifically compiled for IE6.
However, especially for small GWT applications it might often be faster to download a single file of say 500kb rather than make two sequential requests first for the 5kb *.nocache.js script and then for the rest of the app (cache.html files, etc.).
This leads me to the question: Is there any framework or procedure to bundle the output of the GWT compiler into a single JavaScript file?
First, you can merge all permutations in a single file by using so-called "soft permutations".
Then, you can inline your *.nocache.js into the HTML host page (e.g. using a JSP's #include directive) to cut one additional request (you might have to add a <meta name=gwt:property content='baseUrl=myapp'> where myapp is the subfolder where the .nocache. files are located).
AFAIK that's what Google are doing for their GWT apps.
Alternatively, you can run the permutation selection on the server-side if you can totally replace the selection script (*.nocache.js) with server-side content negotiation (based on User-Agent and Accept-Language request headers for instance) that can directly generates a <script> tag for the appropriate *.cache.js file (provided you use the xsiframe linker).
AFAIK, Google use all these techniques for their GWT apps (such as Google Groups). For a small app, though, I'm not sure it's worth the effort…
Also, the last two techniques work best when your HTML host page is already dynamic and therefore already non-cacheable; otherwise you're mostly moving the problem, not solving it.
I wonder whether the sso linker can be used when you collapse all properties and soft-permutations down to a single hard permutation.
Yes, but it's maybe not something you want. See this answer: https://stackoverflow.com/a/4453716/66416 to this stackoverflow question: Merge GWT generated files.
I found another way to accomplish this: Writing a custom Linker for GWT. Two examples for linkers which compile into a single JavaScript file are:
GwtNodeLinker.java from Gwt Node project
ServerSingleScriptLinker.java from Env.js project
I tried include only zend mail part in my program and entire zf is not included.Is it possible to use particular components of zf rather using entire zend.How can i include only zend mail in my program?
Yes it is possible.
There is a project at http://epic.codeutopia.net/pack/ that allows you to download a zip file of the specific components you need. However, it is limited in selection of versions.
You can also manually extract the files you need from a downloaded copy of the framework. You must make sure that you get all the dependencies. The components are supposed to have very low dependency on others so you shouldn't need the entire MVC stack, for example, just to use the Zend_Mail component. You might, however, have to grab Zend_Exception, but I'm not sure.
After you get the source, you will just include it like any other script. In your case it might look as follows.
<?php
require_once "/path/to/Zend/Mail.php";
$mailer = new Zend_Mail();
//code
I've started using Zend framework, and Im following this simple Zend form tutorial. The form is located in application/forms directory I have included the Zend framework in the Path (by going to computer properties). However when i access form.php page, i get this error:
Fatal error: Class 'Zend_Form' not found
I have also tried by copying the Zend folder from the Zend framework in the library folder of the application, however error still remains same. Thanks.
It sounds like you are confusing two notions: the system path and the include path.
The system path is an operating system concept. When you ask the OS to execute a command, the system path is a list of places to look for the executable.
In contrast, the include path is a PHP concept that tells PHP a list of folders in which to look for files invoked by PHP include/require statements.
Any path that you find in "Computer > Properties" is almost certainly the OS-level system path. What you need to do is to make sure the Zend folder on the PHP include path, either by moving the Zend folder or by modifying PHP's include path to include a point to the Zend folder.
In a typical ZF app, the include folder is set in index.php (the front controller). So, the only explanation for not finding Zend_Form is that the autoloader is not being instantiated.
If you are using Zend_Application, this happens automatically. However, it seems like you are bypassing public/index.php and the whole Zend_Application instantiation by trying to directly "access" a file called form.php directly. If this file contains only the definition of your form (extending Zend_Form), then the absence of autoloading could easily explain the error message you are getting.
I'd try instantiating the form in a controller action, by which time in the request processing cycle, the autoloading is probably already in place.
[At that point, given the file locations you cite, we might run into a resource-loader issue, but that's a somewhat different issue that can be handled by instantiating a Zend_Application_Module_Autoloader in your Bootstrap.]
It looks like you do not use Zend_Loader. You should focus on it.
You can also manually in your custom form class include Zend_Form class.
Greetings,
I'm looking for a way to launch a GWT module when a user clicks on an XML file and have the module consume the xml data. Ideally I would like to render the XML in a rich manner and would prefer to use GWT controls instead of having to lay it out by hand via xslt + javascript.
I'm supposing one way would be to point the xml to a well known xslt that creates a simple html page that forces a redirect to the gwt module but how would I transfer the xml data to said module to allow for enhanced formatting?
Another way would be to have the process that produces the xml also include the bootstrap gwt module but it would be creating multiple bootstrap instances over time and pollute the user's directory.
The use case is that a user would run this app on their local machine which outputs an XML file. If they try and view the xml file in a browser, I'd like to have the GWT module take over and present the data accordingly. I would rather they not have to go to a page and upload the data manually.
Appreciate any ideas on the matter.
TIA
If it's something that runs on the user's machine, I would recommend to ship an executable, or generate a parallel HTML file to present the data. JavaScript run from file:/// will not be able to acces the filesystem.
I am looking to compile my gwt application into a single, monolithic, cross-browser compatible .html file. Ultimately, I'm trying to design an Amazon mechanical turk template via gwt. These templates must be a single .html file, since they are hosted on Amazon's machines. The .html file can reference external sources, but via absolute address only since I have no control over the file hierarchy.
It does not concern me that the monolithic file will load slower than having separate files for each browser. I am developing a fairly simple web form containing only client-side code that will be seen by very few people. Therefore, speed and cross-browser correctness are not primary concerns.
I have found that by adding the following line to my MODULE_NAME.gwt.xml I can generate a single javascript file that works exclusively for a single browser (e.g. firefox as shown below):
<set-property name="user.agent" value="gecko">
I then embed the generated code into my .html file, and it works for the single browser specified. Unfortunately, when I try opening the .html file in other browsers, the gwt generated javascript does not load.
Is there a linker command that I can add to this file that will do the trick? I tried to invoke the SingleScriptLinker via:
<add-linker name="sso" />
but got the following error:
[ERROR] The module must have exactly
one distinct permutation when using
the Single Script Linker.
I also attempted to tweak the contents of the generated javascript files in order to make them compatible enough to embed in the .html file, but the javascript generated by gwt is too confusing (even in the detailed output mode). Is there a walk-through for how to do this?
I'm using the gwt eclipse plugin on OSX.
As luck would have it, I have found a workaround soon after posting my question:
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/79e9634110487490
In short, the answer is to use cross-site scripting.
Add the following line to MODULE_NAME.gwt.xml:
< add-linker name="xs" />
gwt will generate a MODULE_NAME.nocache.js file as well as some MD5.cache.js files (note the MD5 files end with .js, not .html).
Compile your application
Now, put all of these .js files on server A.
Modify your MODULE_NAME.html file to contain an absolute reference to MODULE_NAME.nocache.js on server A.
Upload MODULE_NAME.html to server B.
The cross-site linker makes everything work.