You need to sign in to do that
Don't have an account?
Alexandre
How to loop 6 times?
Hi, I have this html in a visual force page. I am trying to repeat this code 6 times. Is there a for-loop function in apex that will allow me to do this.
such as
for (int x=0; x6; x++){
<table style="width:700px"><tr>
<td valign="middle" align="center">
<br/><br/><h1>Commercial Invoice</h1>
</td>
<td>
<img id="theImage" src="https://na1.salesforce.com/servlet/servlet.FileDownload?file=01530000000mvyc" />
</td>
</tr>
</table>
}
Or better yet, try apex:dataTable which iterates over a collection AND creates a table for you.
Also, don't do this:
Instead, do this:
<apex:image value="{!URLFOR($Action.Document.Download, docid)}"/>
Where 'docid' is from your iteration. This ensures your image won't break if moved to another environment (e.g. na1 becomes na8) or if salesforce.com changes the endpoint for downloading files.
Finally, pasting record IDs into a page makes the page useless in other environments. Any attempt to migrate such a page to an org without the same data (including the IDs) will break it and it will have to be fixed up manually. Not to mention there is nothing preventing the doc from being deleted which would also break the link. "hard coded" references like this are best left to Static Resources.
Check out the Visualforce Developer Guide for more info on Static Resources, apex:dataTable, etc.