You need to sign in to do that
Don't have an account?
kpriya Aggarwal
Hi, It's urgent please can anyone help me on this?
VF Page
<apex:page Controller="Contactsrd" sidebar="false"> <style type="text/css"> .popup { background-color: White; border-width: 2px; border-style: solid; z-index: 9999; left: 50%; padding:10px; position: absolute; width: 400px; margin-left: -250px; top:80px; } .popupBg{ background-color:grey; opacity: 0.20; filter: alpha(opacity = 70); position: absolute; width: 100%; height: 100%; top: 0; left: 0; z-index: 9998; } </style> <apex:form id="form"> <apex:pageblock id="pb"> <apex:pageBlockTable id="pbt" value="{!getcontactt}" var="ct"> <apex:column headerValue="Contact Name"> <apex:outputText value="{!ct.name}"></apex:outputText> </apex:column> <apex:column headerValue="Detail"> <apex:outputPanel > <apex:actionSupport event="onclick" action="{!detailPage}" rerender="popup,pb"> <input type="radio" name="det" /> <apex:param value="{!ct.id}" assignTo="{!id}" name="id"/> </apex:actionSupport> </apex:outputPanel> </apex:column> </apex:pageBlockTable> </apex:pageblock> <!--popup code starts--> <apex:outputPanel id="popup"> <apex:outputPanel styleClass="popupBg" layout="block" rendered="{!displayPopUp}"/> <apex:outputPanel styleClass="popup" layout="block" rendered="{!displayPopUp}"> <apex:messages /> <center><h2>{!ct_name} Information</h2></center> <apex:panelGrid columns="2" > <apex:outputLabel value="Contacts"/> <apex:inputText value="{!ct_name}"></apex:inputText> <apex:commandButton value="Update" action="{!updaterec}"/> <apex:commandButton value="cancel" action="{!closePopup}" rerender="popup,pb"/> </apex:panelGrid> </apex:outputPanel> </apex:outputPanel> <!-- end of popup code--> </apex:form> </apex:page>Controller:
public class Contactsrd{ Public String ct_name { get; set; } public boolean displayPopUp { get; set; } Contact cont {get; set;} List<Contact> clist= new List<Contact>(); //cont= new contact(); public PageReference closePopup() {//hide method displayPopup = false; return null; } public PageReference detailPage() {// action method which shows popup on selection displayPopup = true; system.debug('Select Item Id is :'+ApexPages.currentPage().getParameters().get('id')); String id = ApexPages.currentPage().getParameters().get('id'); Contact ac = [select id,name from Contact where id =: id]; ct_name = ac.name; //update ac; return null; } public list<Contact> getGetContactt() { list<Contact> ctl = [select id,name from Contact]; return ctl; } public Contactsrd(){ Id id= ApexPages.currentPage().getParameters().get('id'); cont=(id==null)? new Contact():[Select lastName FROM Contact Where Id= :id]; } public PageReference updaterec() {//update popup record //displayPopup = true; Try{upsert(cont);}catch(system.DMLException e){ApexPages.addMessages(e); return null;} //try{ //contact c= [SELECT Id FROM Contact WHERE Id=:id]; //c.Salutation= ct_name; //c.FirstName=ct_name; //c.LastName=ct_name; //update cont; return null; } }See below image.I got an error while upserting record.
All Answers
Thanks for your response.
Only error is resolved but changes are not done in record. Suppose record name is SDFC2 and am renaming with TCS. TCS is not exist in contacts' records.