Я пытаюсь получить изображения в таблице, и когда мы нажимаем на это изображение, оно должно загружаться. Я использую apex: commandLink, но изображение не загружается и не открывается.когда мы нажимаем на изображение, DoresViewingStatus будет обновляться как просмотренное.Пожалуйста, помогите, так как я застрял здесь на долгое время.
Страница Visualforce: -
<apex:pageBlockTable value="{!DORESAttachmentsWrapperList}" var="AttachVar" border="3px" width="98.5%">
<apex:column >
<apex:facet name="header">File</apex:facet>
<apex:commandLink action="{!DORESupdateHistory1}" styleClass="{!IF(AttachVar.DoresViewingStatus == 'Not Viewed' && (runningUser.Profile.Name == 'Profile1' || runningUser.Profile.Name =='Profile2'),'actionLink disableLink','actionLink')}"
value="{!AttachVar.attachmentName}" >
<apex:param value="{!AttachVar.attachmentID}" name="DORESupdateHistory1" assignTo="{!DORESSelectedId1}"/>
</apex:commandLink >
</apex:column>
Контроллер -
DORESupdateHistory1 обновит время и имя человека в таблице, который нажимает на новый прикрепленныйобраз.
public String DORESSelectedId1{get;set;}
public PageReference DORESupdateHistory1(){
system.debug('--DORESSelectedId1---' + DORESSelectedId1);
List<Profile> Profile= [Select Name from Profile where Id =:UserInfo.getProfileId() LIMIT 1];
list<attachment> relatedPaadAttachment = [select ID,parentID,name from attachment where ID=:DORESSelectedId1 limit 1];
system.debug('--DORESSelectedId1---' + DORESSelectedId1);
List<PAAD_Application_Attachment__c> ClickedAttachList1 = [Select id,Name,Type__c,CreatedDate,Dores_Viewer_Name__c,Dores_Viewed_Time__c,Dores_Viewing_Status__c from PAAD_Application_Attachment__c where id = :relatedPaadAttachment[0].parentID]; //To get the clicked attachment Id
if(ClickedAttachList1[0].Dores_Viewing_Status__c == 'Not Viewed' && Profile[0].Name == 'Profile1' || Profile[0].Name == 'Profile2'){
ClickedAttachList1[0].Dores_Viewing_Status__c = 'Viewed';
ClickedAttachList1[0].Dores_Viewed_Time__c = system.now();
ClickedAttachList1[0].Dores_Viewer_Name__c = UserInfo.getName();
update ClickedAttachList1;
List<PAAD_Application_Attachment__c> viewedattach1= [SELECT Id,Dores_Viewing_Status__c FROM PAAD_Application_Attachment__c where Dores_Viewing_Status__c != 'Viewed' and PAAD_Applicant__c=:app.ID];
List<PAAD_Application_Attachment__c> attach1 = [SELECT Id FROM PAAD_Application_Attachment__c where PAAD_Applicant__c=:app.ID];
if(viewedattach1.size() == attach1.size()){
List<PAAD_Applicant__c> attachcheck1= [SELECT Id,New_Dores_Attachment_Checker__c FROM PAAD_Applicant__c where ID=:app.ID];
if(attachcheck1[0].New_Dores_Attachment_Checker__c == 'Y') {
attachcheck1[0].New_Dores_Attachment_Checker__c = '';
update attachcheck1;
}
}
List<AttachmentWrapper> dummyWrapperList = new List<AttachmentWrapper>();
for(AttachmentWrapper wrap : DORESAttachmentsWrapperList){
if(DORESSelectedId1 != wrap.attachmentID){
dummyWrapperList.add(wrap);
}else{
dummyWrapperList.add(new AttachmentWrapper(ClickedAttachList1[0].Type__c,ClickedAttachList1[0].Member__c, ClickedAttachList1[0].Description_Final__c, relatedPaadAttachment[0].ID,relatedPaadAttachment[0].name, ClickedAttachList1[0].CreatedDate,'Attached', ClickedAttachList1[0].Dores_Viewed_Time__c, ClickedAttachList1[0].Dores_Viewer_Name__c, ClickedAttachList1[0].Dores_Viewing_Status__c));
}
}
DORESAttachmentsWrapperList.clear();
DORESAttachmentsWrapperList.addAll(dummyWrapperList);
}
return null;
}