You need to sign in to do that
Don't have an account?
Render the value of outputfield after click on it (without button)
Hi,
i am developing an application that is comparable to a email client. I have a pageblocktable with the emails and various field of the single mail.
I have a formula field too. I use this field to call some images and use it to create the "outlook flag follow up"(on a object "Email__c" there is a field "flagstatus__c" and formula field "flag__c" ):
- If the flagstatus__c is "NULL" -> GRAY FLAG
- If the flagstatus__c is "TO_DO"-> RED FLAG
- If the flagstatus__c is "COMPLETE" -> CHECK FLAG
CASE(FlagStatus__c , "TO_DO",IMAGE("/resource/FlagRed",""), "COMPLETE", IMAGE("/resource/FlagCompleted",""),IMAGE("/resource/FlagNull",""))
I have no button to rerender the value of this field but i call a remoteaction after click on the flag(now is in outputtext, but i think that with an outputfield i have the same result). The remote action update the value but this it is not rendered on the table in the page.
How i can render the value without using a button (with the option "rerender=")? The problem is that the remote action is asynchronous?
This is a part of the table :
<apex:pageBlockTable id="maintable" style="cursor:pointer" value="{!Emails}" var="e" columns="5" cellspacing="5" onRowClick="show(this)" > <apex:column onclick="setRemoteFlagState('{!e.Id}');" headerValue="State" width="4%" > <apex:outputText escape="false" value="{!e.Flag__c}"/> </apex:column> </apex:pageBlockTable>
This is the remote action
@RemoteAction global static String setFlagState(String emailId) { List<E2C_Email__c> emails = [select FlagStatus__c from E2C_Email__c where Id = :emailId]; if (emails.size() > 0) { if (emails.get(0).FlagStatus__c=='NULL'){ emails.get(0).FlagStatus__c='TO_DO'; update(emails.get(0)); return emails.get(0).FlagStatus__c; } else if (emails.get(0).FlagStatus__c=='TO_DO'){ emails.get(0).FlagStatus__c='COMPLETE'; update(emails.get(0)); return emails.get(0).FlagStatus__c; } else{ emails.get(0).FlagStatus__c='NULL'; update(emails.get(0)); return emails.get(0).FlagStatus__c; } System.debug('stato email '+emails[0].read__c); return emails[0].Read__c; } else { System.debug('Nessuna Email corrispondente'); return null; } }
This is the javascript code:
function setRemoteFlagState(emailId) { Visualforce.remoting.Manager.invokeAction( '{!$RemoteAction.E2CViewEmail_ProvaController4.setFlagState}', emailId, function(result, event){ if (event.status) if (result.replace != null) { alert(result); } else if (event.type === 'exception') { document.getElementById("responseErrors").innerHTML = event.message; } else { document.getElementById("responseErrors").innerHTML = event.message; } }, {escape: true} ); }
I can't see the solution off the top of my head
but I'd suggest looking at apex:actionStatus with facets to put image code in the start and stop sections.