You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by padilah padilah <ve...@yahoo.com> on 2003/07/24 06:43:22 UTC

insert-edit image

hi 
 
I have problem to insert image and edit image on my turbine-tdk project.
questions: 
1. how to insert dynamic image ? 
2. how to make windows (like windows compose in yahoo mail) ?
 
thanks.. 
 
this sample of my code.
 
/*
 * Created on May 13, 2003
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package com.miningtrading.content.modules.screens;
import org.apache.turbine.util.DynamicURI;
import org.apache.turbine.util.RunData;
import org.apache.velocity.context.Context;
/**
 * @author padilah
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */ 
public class MyImage extends DynamicURI
{ 
 
 /** The images directory */
  public static final String DIR = "images";
 /** tomcat specific - tomcat context */
    private String contextpath;
 /** Constructor */
  public MyImage (RunData data)
  {
   super(data);
   //the Tomcat context
   contextpath = data.getRequest().getContextPath();
  } 
 
 /** set the image and URI */
  public String setImage(String imagename)
  {
   return (
   getServerScheme() + //http
   "://" +
   getServerName()  + //www.foo.com
   ":" +
   getServerPort() + //port webserver running on (8080 for TDK)
   //the context for tomcat adds a / so no need to add another
   contextpath  +  //the tomcat context
   "/" +
   MyImage.DIR +
   "/" +
   imagename);
  }
  
 /** from this the Image Object is accessible from within the corresponding screen template 
  and can be accessed by $image.setImage("imagename.jpg"); */  
  public void doBuildTemplate(RunData data, Context context) throws Exception
  {
   MyImage image = new MyImage(data);
   context.put("image",image);
  } 
}


---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software