Page:
----
<apex:page StandardController="Event" extensions="eventcontroller">
<script>
function confirmCancel()
{
var isCancel = confirm("Are you sure you wish to cancel?");
if (isCancel) return true;
return false;
}
var newWin=null;
function fillFields(oSel)
{
var oForm = oSel.parent;
//alert(oSel.options[oSel.selectedIndex].value);
switch (oSel.options[oSel.selectedIndex].value)
{
case "Yes":
// document.getElementById('j_id0:parent:j_id3:choice').disabled=true;
document.getElementById('test1').style.display='none';
document.getElementById('j_id0:parent:j_id30:choice').style.display='none';
break;
case "No":
document.getElementById('test1').style.display='block';
document.getElementById('test2').style.display='block';
document.getElementById('j_id0:parent:j_id30:choice').style.display='block';
break;
default :
//document.getElementById('j_id0:parent:j_id30:choice').disabled=true;
document.getElementById('test1').style.display='none';
document.getElementById('j_id0:parent:j_id30:choice').style.display='none';
}
}
</script>
<apex:sectionHeader title="Complete Meeting Edit" subtitle="Complete Meeting"/>
<apex:form id="parent">
<apex:pageMessages > </apex:pageMessages>
<apex:pageBlock title="Complete Meeting Edit" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!save1}" value="Save"/>
<apex:commandButton action="{!cancel}" value="Cancel" onclick="return confirmCancel()" immediate="true"/>
</apex:pageBlockButtons>
<table style="padding-left:200px">
<tr>
<td>
</td>
</tr>
<tr>
<td align="right"><b>Meeting is Valid:</b>
</td>
<td align="left">
<apex:inputField value="{!events.Attend__c}" required="true" onchange="fillFields(this)"/>
</td>
</tr>
<tr>
<td align="right"><p id="test1" style="display:none" ><b>Reason for Failure:</b></P>
</td>
<td id="test2" align="left">
<apex:inputField value="{!events.Reason__c}" required="true" id="choice" style="display:none"/>
</td>
</tr>
</table>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
============
public class eventcontroller
{
public eventcontroller(ApexPages.StandardController controller)
{
}
Event events;
public Event getevents()
{
if(events== null)
events = new Event();
return events;
}
public PageReference save1()
{
Event e = new Event();
String eventid= System.currentPageReference().getParameters().get('eid');
system.debug('Event:'+eventid);
e = [Select e.Attend__c, e.Id, e.Reason__c from Event e where e.id=:eventid];
system.debug('Event details:'+e);
e.Attend__c=events.Attend__c;
e.Reason__c=events.Reason__c;
e.Meeting_Completed__c =true;
update e;
//ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Record(s) have been Updated Successfully.Please Refresh Your Account Record to see the imported data'));
PageReference redirecturl = new PageReference('https://ap1.salesforce.com/'+eventid);
return redirecturl;
//return null;
}
}
No comments:
Post a Comment
Share your Comments .............