001 package net.sf.tacos.seam; 002 003 import java.util.Iterator; 004 import java.util.List; 005 006 import org.apache.tapestry.AbstractComponent; 007 import org.apache.tapestry.IMarkupWriter; 008 import org.apache.tapestry.IRequestCycle; 009 import org.apache.tapestry.html.Shell; 010 011 public abstract class Remoting extends AbstractComponent { 012 /** 013 * {@inheritDoc} 014 */ 015 protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) { 016 writer.begin(getTemplateTagName()); 017 renderIdAttribute(writer, cycle); 018 renderInformalParameters(writer, cycle); 019 renderBody(writer, cycle); 020 writer.end(); 021 } 022 023 protected void prepareForRender(IRequestCycle cycle) { 024 super.prepareForRender(cycle); 025 if (!cycle.isRewinding()){ 026 Shell shell = Shell.get(cycle); 027 shell.includeAdditionalContent( 028 "<script src=\"seam/resource/remoting/resource/remote.js\" type=\"text/javascript\"></script>"); 029 StringBuffer include = new StringBuffer(); 030 Iterator<String> it = getInclude().iterator(); 031 while (it.hasNext()) { 032 include.append(it.next()); 033 if(it.hasNext()) 034 include.append("&"); 035 036 } 037 shell.includeAdditionalContent( 038 "<script src=\"seam/resource/remoting/interface.js?"+include+"\" type=\"text/javascript\"></script>"); 039 } 040 } 041 042 public abstract List<String> getInclude(); 043 044 }