You need to sign in to do that
Don't have an account?
NikiG22
Issue with attachment extention
Hello - i am having issues with my attachment extention now working on my VP? please help.
Here is my extention code:
public class AllAttachmentsController { public AllAttachmentsController(ApexPages.StandardSetController controller) { } public List<Attachment> ATT {get;set;} public AllAttachmentsController (ApexPages.StandardController stdController) { } public List<String> getAttLinks() { Id caseid = ApexPages.currentPage().getParameters().get('Id'); List<String> attLinks = new List<String>(); String strURL; String strResult ; ATT=[SELECT Id, Name FROM Attachment WHERE parentId = :ApexPages.currentPage().getParameters().get('Id')]; integer j = ATT.size(); for(integer i=0; i<j; i++) { strURL= 'https://' + ApexPages.currentPage().getHeaders().get('Host') + '/servlet/servlet.FileDownload?file=' + ATT[i].Id; attLinks.add(strURL); } return attLinks ; } static testmethod void testshow() { attachment ac=new attachment(); list<account> acc=new list<account>(); account a=new account(name='test'); acc.add(a); ApexPages.StandardController sc = new ApexPages.standardController(ac); ApexPages.StandardSetController sc1 = new ApexPages.standardSetController(acc); AllAttachmentsController obj = new AllAttachmentsController (sc); AllAttachmentsController obj1 = new AllAttachmentsController (sc1); obj.getAttLinks(); } }
and here is my VP:
<apex:page standardController="Candidate__c" extensions="AllAttachmentsController" recordSetVar="Candidate__c" sidebar="false" showheader="false" id="candidatelist"> <style> <!--Table Header--> th.classhead{ width:100%; font-size:16px; color:black; font-family:Verdana,Geneva,sans-serif; } <!--out side table--> table.outtertable{ margin-top:0px; margin-bottom:0px; margin-right:50px; margin-left:50px; padding:3px; border-style:solid; border-width:3px; border-color:#74BDE2; background-color:#ebeff3; } table.innertable{ margin-top:0px; margin-bottom:0px; margin-right:2px; margin-left:0px; padding:15px; border-style:solid; border-width:2px; width:100%; border-color:#74BDE2; background-color:#ffffff; } table.dottedtable{ margin-top:0px; margin-bottom:0px; margin-right:2px; margin-left:0px; padding:15px; width:100%; colspan:3; background-color:#FFFFFF; border-style:dashed; border-width:2px; border-color:#f1f1f1; } pageBlockTable.block{ background-color:#FFFFFF; border-style:none; border-width:1px; border-color:#FFFFFF; } </style> <!-- Image Header --> <head> <center><h class="margin"><a href="http://www.healthecareers.com" target="_blank"><img src="https://c.na3.content.force.com/servlet/servlet.ImageServer?id=01550000000PNYo&oid=00D500000007FIS&lastMod=1327507164000"/></a> </h> </center> </head> <!--Start List View--> <apex:pageBlock mode="listview" > <apex:pageBlockTable columns="5" columnsWidth="25%" width="90%" value="{!Candidate__c}" align="center" var="c" style="block"> <apex:column value="{!c.First_Name__c}" /> <apex:column value="{!c.Last_Name__c}"/> <apex:column value="{!c.JobSeeker_Type_All__c}"/> <apex:column value="{!c.Years_of_exp__c}"/> <apex:column headerValue="Resume" > <a href="{!attLinks}" target="blank">CLICK ME</a> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:page>
when i click on the "View Resume" link in my VP it gived me a weird error?
The name '%5B%5D' can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores.
any help would be very appriciated.
Niki
I figured it out:Its not the best but it works.
i did a phantopm page of attachments:
then i created a link to it on my page:
All Answers
%5B %5D are url codes for opening and closing square brackets. Is the file that you are trying to view have opening or closing square brackets in the file name?
no it dosent. i clicked on it again but got the maintenance page? the site has accedd to my page, extention and class.
this is the url that pops up
http://healthecareers.force.com/[]
I figured it out:Its not the best but it works.
i did a phantopm page of attachments:
then i created a link to it on my page:
Hi Niki,
I'm also facing the same problem.Can u help me out in this.I'm getting values from Xml and displaying them in a link.When I clicked on the link then getting error as
The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores.
Thanks in advance
Sure - Try removing the spaces in the Page name So insted of this "Web Lead Landing Page" do this "WebLeadLandingPage" or this "Web_Lead_Landing_Page"