Getting Started With JRuby on Rails for Sun GlassFish Enterprise Server v3 Prelude

ProcedureCreating the Views That Display the Images Generated by Java2D Code.

With this task, you will perform the following actions:

  1. Find a JPEG image that you can use with this application.

  2. Add the image to <JRUBY_HOME>/samples/imageprocess/public/image file.

  3. Go to <JRUBY_HOME>/samples/imageprocess/app/views/home file.

  4. Open the index.html.erb file in a text editor.

  5. Replace the contents of this file with the following HTML markup:

    <html>
    	<body>
    		<img src="../../images/kids.jpg"/><p>
    		<%= link_to "Perform a ColorConvertOp on this image", :action => "seeimage" %>
    	</body>
    </html>

    This page loads an image from <JRUBY_HOME>/samples/imageprocess/public/images and provides a link that references the seeimage action. The seeimage action maps to the seeimage view, which shows the processed image.

  6. Replace kids.jpg from line 3 of index.html.erb with the name of your image that you saved from step 3 of this procedure.

  7. Save index.html.erb file.

  8. Open seeimage.html.erb file in a text editor.

  9. Replace the contents of this file with the following HTML markup:

    <html>
    	<body>
    		<img src="/home/processimage"/><p>
    		<%= link_to "Back", :action => "index" %>
    	</body>
    </html>

    The img tag on this page accesses the processimage action in HomeController. The processimage action is where you will put the Java2D code to process the image you loaded into index.html.erb.