You need to sign in to do that
Don't have an account?

Need to refresh a pageBlock instead of refreshing the whole page
Hi,
I have a requirement .......
On Clicking a button using the CommanButton i need to refresh a PageBlock.
Apart from from PageBlock it is also rfershing the complete Page which should not happen.
Can any one help me out by looking into my code . Such that when i click on the Continue Button it has to refresh the Page Block such that on clicking the Continue button it will showcase the PageBlock which i am looking , but at the same time it is refreshing the Page by which whatever the records that i selected will be get lost and user has to select the record once again. which should not happen.
Here is my code
<apex:page standardController="Recruiting_Event__c" extensions="MassEmailEventForCampus" id="pageid" sidebar="true" showHeader="true" tabStyle="Contact">
<style>
.mmSubheader {
background-color= #E2E3E5;
font size: 1em;
margin: 18px 0 7px;
padding: 4px 9px;
color: black;
font-weight:bold;
}
.label{
padding:3px;
color: #222222;font-family: Arial,Helvetica,sans-serif;
}
.he1 {
font-weight: bold;
-moz-user-select: text;
font-family: 'Arial','Helvetica',sans-serif;
font-size: 100%;
line-height: normal;
border-style: none solid none none;
border-width: 0 1px 0 0;
padding: 2px 0 3px;
vertical-align: baseline;
border-left-color: #EEEEEE;
border-right-color: #D0D0D0;
border-left: 1px solid;
border-right: 1px solid;
-moz-user-focus: normal;
outline: medium none;
text-align: left;
}
</style>
<script type="text/javascript">
document.getElementsByTagName("input").checked;
function checkAll(cb,cbid)
{
var inputElem = document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++)
{
if(inputElem[i].id.indexOf(cbid)!=-1){
inputElem[i].checked = cb.checked;
}
}
}
</script>
<script language="javascript" type="text/javascript">
var pickListArray=[];
var campaignPickListArray=[];
function popUpLookUpWindow(url,col,val) {
var colValue=document.getElementById(col).value;
if(colValue!='None'){
url=url+'&column='+colValue+'&val='+val;
newwindow=window.open(url,'name','height=430,width=620,toolbar=no,resizable=yes,scrollbars=yes');
if (window.focus) {newwindow.focus()}
}
}
function closePopUp(){
if (null!=newwindow)
{
newwindow.close();
}
}
</script>
<apex:form >
<apex:repeat value="{!pickListCol}" var="request">
<script>
pickListArray.push('{!request}');
</script>
</apex:repeat>
<apex:repeat value="{!pickListCampaignCol}" var="list">
<script>
campaignPickListArray.push('{!list}');
</script>
</apex:repeat>
<script>
function isPickList(selectedId,lookupId){
var val=document.getElementById(selectedId).value;
for (var i = 0; i < pickListArray.length; i++) {
// alert('pickListArray === ' + pickListArray[i]);
if (pickListArray[i] ===val){
document.getElementById(lookupId).style.display = "block";
break;
}else{
document.getElementById(lookupId).style.display = "none";
}
}
}
function isCampaignPickList(selectedId,lookupId){
var val=document.getElementById(selectedId).value;
for (var i = 0; i < campaignPickListArray.length; i++) {
// alert('campaignPickListArray=== ' + campaignPickListArray[i]);
if (campaignPickListArray[i] ===val){
document.getElementById(lookupId).style.display = "block";
break;
}else{
document.getElementById(lookupId).style.display = "none";
}
}
}
</script> <apex:sectionHeader subtitle="Mass Email"/>
<apex:pageBlock title="Step 1: Select email recipients">
<div class="mmSubheader">Select Event Name <apex:inputField value="{!eropty.Recruiting_Event__c}" id="crmcmpid">
</apex:inputfield>
<br></br>
Attended <apex:inputField value="{!eropty.Attended__c}" id="crmcmpid1">
</apex:inputfield>
Attending <apex:inputField value="{!eropty.Attending__c}" id="crmcmpid2">
</apex:inputfield>
Invited <apex:inputField value="{!eropty.Invited__c}" id="crmcmpid3">
</apex:inputfield>
No Show <apex:inputField value="{!eropty.No_Show__c}" id="crmcmpid5">
</apex:inputfield>
Not Attending <apex:inputField value="{!eropty.Not_Attending__c}" id="crmcmpid6">
</apex:inputfield>
No Response <apex:inputCheckbox value="{!eropty.No_Response__c}" id="crmcmp1d7"/>
<br></br>
</div>
<div class="mmSubheader" style="display:none">Choose Member Type to Search </div>
<div class="mmSubheader"></div>
<apex:outputPanel id="criteria">
<apex:actionstatus id="status" startText="Loading...">
<apex:facet name="stop">
<apex:outputPanel >
<apex:commandButton action="{!go}" value="Search" reRender="searchProgress,results1,dTable" status="searchProgress" />
<br/>
<apex:actionStatus id="searchProgress">
<apex:facet name="start">
<table align="center" border="0">
<tr>
<td style="vertical-align:middle;" align="center">
<img src="{!$Resource.saveStatus}"/>
</td>
</tr>
</table>
</apex:facet>
</apex:actionStatus>
</apex:outputPanel>
</apex:facet>
</apex:actionstatus>
</apex:outputPanel>
<br/>
<apex:pageBlockSection columns="1" >
<script type="text/javascript">new MenuButton('MyMenu', false);</script>
<apex:pageBlockTable id="dTable" value="{!contactList}" var="dat" border="1" cellspacing="2px" width="100%" headerClass="he1" cellpadding="4px" columnsWidth="60px,150px,150px,150px,170px" >
<apex:column ><apex:facet name="header">
<apex:inputCheckbox onclick="checkAll(this,'checkedone')"/>
</apex:facet>
<apex:inputCheckbox value="{!dat.selected}" id="checkedone"/></apex:column>
<apex:column headerValue="First Name" ><apex:outputField value="{!dat.con.FirstName}" rendered="{!IF(ISBLANK(dat.con.FirstName), 'false', 'true')}"/>
</apex:column>
<apex:column headerValue="Last Name" ><apex:outputField value="{!dat.con.LastName}" rendered="{!IF(ISBLANK(dat.con.LastName), 'false', 'true')}"/>
</apex:column>
<apex:column headerValue="Title" ><apex:outputField value="{!dat.con.Title}" rendered="{!IF(ISBLANK(dat.con.Title), 'false', 'true')}"/>
</apex:column>
<apex:column headerValue="Account Name" ><apex:outputField value="{!dat.con.AccountId}" rendered="{!IF(ISBLANK(dat.con.AccountId), 'false', 'true')}"/> </apex:column>
<apex:column headerValue="Email" ><apex:outputField value="{!dat.con.Email}" rendered="{!IF(ISBLANK(dat.con.Email), 'false', 'true')}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:commandLink action="{!previousResults}" value="Previous" reRender="emailTemplateBlock"/> | <apex:commandLink action="{!nextResults}" value="Next" reRender="dTable" />
<br></br><br></br>
</apex:pageBlock>
<apex:pageblock >
<apex:commandButton action="{!Save}" value="Continue..."/>
</apex:pageblock>
<apex:pageBlock title="Step 2: Select an email template" id="emailTemplateBlock" rendered="{!displaypblock}">
Select Email Template Folder:
<apex:selectList value="{!selectedEmailTemplateFolder}" multiselect="false" size="1">
<apex:selectOptions value="{!emailTemplateFolderOpts}" />
<apex:actionSupport event="onchange" action="{!refreshEmailTemplateSection}" rerender="emailTemplateBlock" />
</apex:selectList>
<br/><br></br>
Select Email Template:
<apex:selectList value="{!selectedEmailTemplate}" multiselect="false" size="1" >
<apex:selectOptions value="{!emailTemplateOpts}" />
<apex:actionSupport event="onchange" action="{!refreshEmailTemplateSectionid}" rerender="emailTemplateBlock" />
</apex:selectList>
<apex:outputLink target="_blank" value="{!emailTemplateId}"> Preview</apex:outputLink> <br/><br></br>
<apex:commandButton action="{!SendEmail}" value="Send Email" rendered="{!if(emailTemplateOpts.size > 0, true, false)}"/>
</apex:pageBlock> </apex:form>
</apex:page>
Regards
Micky
I have a requirement .......
On Clicking a button using the CommanButton i need to refresh a PageBlock.
Apart from from PageBlock it is also rfershing the complete Page which should not happen.
Can any one help me out by looking into my code . Such that when i click on the Continue Button it has to refresh the Page Block such that on clicking the Continue button it will showcase the PageBlock which i am looking , but at the same time it is refreshing the Page by which whatever the records that i selected will be get lost and user has to select the record once again. which should not happen.
Here is my code
<apex:page standardController="Recruiting_Event__c" extensions="MassEmailEventForCampus" id="pageid" sidebar="true" showHeader="true" tabStyle="Contact">
<style>
.mmSubheader {
background-color= #E2E3E5;
font size: 1em;
margin: 18px 0 7px;
padding: 4px 9px;
color: black;
font-weight:bold;
}
.label{
padding:3px;
color: #222222;font-family: Arial,Helvetica,sans-serif;
}
.he1 {
font-weight: bold;
-moz-user-select: text;
font-family: 'Arial','Helvetica',sans-serif;
font-size: 100%;
line-height: normal;
border-style: none solid none none;
border-width: 0 1px 0 0;
padding: 2px 0 3px;
vertical-align: baseline;
border-left-color: #EEEEEE;
border-right-color: #D0D0D0;
border-left: 1px solid;
border-right: 1px solid;
-moz-user-focus: normal;
outline: medium none;
text-align: left;
}
</style>
<script type="text/javascript">
document.getElementsByTagName("input").checked;
function checkAll(cb,cbid)
{
var inputElem = document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++)
{
if(inputElem[i].id.indexOf(cbid)!=-1){
inputElem[i].checked = cb.checked;
}
}
}
</script>
<script language="javascript" type="text/javascript">
var pickListArray=[];
var campaignPickListArray=[];
function popUpLookUpWindow(url,col,val) {
var colValue=document.getElementById(col).value;
if(colValue!='None'){
url=url+'&column='+colValue+'&val='+val;
newwindow=window.open(url,'name','height=430,width=620,toolbar=no,resizable=yes,scrollbars=yes');
if (window.focus) {newwindow.focus()}
}
}
function closePopUp(){
if (null!=newwindow)
{
newwindow.close();
}
}
</script>
<apex:form >
<apex:repeat value="{!pickListCol}" var="request">
<script>
pickListArray.push('{!request}');
</script>
</apex:repeat>
<apex:repeat value="{!pickListCampaignCol}" var="list">
<script>
campaignPickListArray.push('{!list}');
</script>
</apex:repeat>
<script>
function isPickList(selectedId,lookupId){
var val=document.getElementById(selectedId).value;
for (var i = 0; i < pickListArray.length; i++) {
// alert('pickListArray === ' + pickListArray[i]);
if (pickListArray[i] ===val){
document.getElementById(lookupId).style.display = "block";
break;
}else{
document.getElementById(lookupId).style.display = "none";
}
}
}
function isCampaignPickList(selectedId,lookupId){
var val=document.getElementById(selectedId).value;
for (var i = 0; i < campaignPickListArray.length; i++) {
// alert('campaignPickListArray=== ' + campaignPickListArray[i]);
if (campaignPickListArray[i] ===val){
document.getElementById(lookupId).style.display = "block";
break;
}else{
document.getElementById(lookupId).style.display = "none";
}
}
}
</script> <apex:sectionHeader subtitle="Mass Email"/>
<apex:pageBlock title="Step 1: Select email recipients">
<div class="mmSubheader">Select Event Name <apex:inputField value="{!eropty.Recruiting_Event__c}" id="crmcmpid">
</apex:inputfield>
<br></br>
Attended <apex:inputField value="{!eropty.Attended__c}" id="crmcmpid1">
</apex:inputfield>
Attending <apex:inputField value="{!eropty.Attending__c}" id="crmcmpid2">
</apex:inputfield>
Invited <apex:inputField value="{!eropty.Invited__c}" id="crmcmpid3">
</apex:inputfield>
No Show <apex:inputField value="{!eropty.No_Show__c}" id="crmcmpid5">
</apex:inputfield>
Not Attending <apex:inputField value="{!eropty.Not_Attending__c}" id="crmcmpid6">
</apex:inputfield>
No Response <apex:inputCheckbox value="{!eropty.No_Response__c}" id="crmcmp1d7"/>
<br></br>
</div>
<div class="mmSubheader" style="display:none">Choose Member Type to Search </div>
<div class="mmSubheader"></div>
<apex:outputPanel id="criteria">
<apex:actionstatus id="status" startText="Loading...">
<apex:facet name="stop">
<apex:outputPanel >
<apex:commandButton action="{!go}" value="Search" reRender="searchProgress,results1,dTable" status="searchProgress" />
<br/>
<apex:actionStatus id="searchProgress">
<apex:facet name="start">
<table align="center" border="0">
<tr>
<td style="vertical-align:middle;" align="center">
<img src="{!$Resource.saveStatus}"/>
</td>
</tr>
</table>
</apex:facet>
</apex:actionStatus>
</apex:outputPanel>
</apex:facet>
</apex:actionstatus>
</apex:outputPanel>
<br/>
<apex:pageBlockSection columns="1" >
<script type="text/javascript">new MenuButton('MyMenu', false);</script>
<apex:pageBlockTable id="dTable" value="{!contactList}" var="dat" border="1" cellspacing="2px" width="100%" headerClass="he1" cellpadding="4px" columnsWidth="60px,150px,150px,150px,170px" >
<apex:column ><apex:facet name="header">
<apex:inputCheckbox onclick="checkAll(this,'checkedone')"/>
</apex:facet>
<apex:inputCheckbox value="{!dat.selected}" id="checkedone"/></apex:column>
<apex:column headerValue="First Name" ><apex:outputField value="{!dat.con.FirstName}" rendered="{!IF(ISBLANK(dat.con.FirstName), 'false', 'true')}"/>
</apex:column>
<apex:column headerValue="Last Name" ><apex:outputField value="{!dat.con.LastName}" rendered="{!IF(ISBLANK(dat.con.LastName), 'false', 'true')}"/>
</apex:column>
<apex:column headerValue="Title" ><apex:outputField value="{!dat.con.Title}" rendered="{!IF(ISBLANK(dat.con.Title), 'false', 'true')}"/>
</apex:column>
<apex:column headerValue="Account Name" ><apex:outputField value="{!dat.con.AccountId}" rendered="{!IF(ISBLANK(dat.con.AccountId), 'false', 'true')}"/> </apex:column>
<apex:column headerValue="Email" ><apex:outputField value="{!dat.con.Email}" rendered="{!IF(ISBLANK(dat.con.Email), 'false', 'true')}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:commandLink action="{!previousResults}" value="Previous" reRender="emailTemplateBlock"/> | <apex:commandLink action="{!nextResults}" value="Next" reRender="dTable" />
<br></br><br></br>
</apex:pageBlock>
<apex:pageblock >
<apex:commandButton action="{!Save}" value="Continue..."/>
</apex:pageblock>
<apex:pageBlock title="Step 2: Select an email template" id="emailTemplateBlock" rendered="{!displaypblock}">
Select Email Template Folder:
<apex:selectList value="{!selectedEmailTemplateFolder}" multiselect="false" size="1">
<apex:selectOptions value="{!emailTemplateFolderOpts}" />
<apex:actionSupport event="onchange" action="{!refreshEmailTemplateSection}" rerender="emailTemplateBlock" />
</apex:selectList>
<br/><br></br>
Select Email Template:
<apex:selectList value="{!selectedEmailTemplate}" multiselect="false" size="1" >
<apex:selectOptions value="{!emailTemplateOpts}" />
<apex:actionSupport event="onchange" action="{!refreshEmailTemplateSectionid}" rerender="emailTemplateBlock" />
</apex:selectList>
<apex:outputLink target="_blank" value="{!emailTemplateId}"> Preview</apex:outputLink> <br/><br></br>
<apex:commandButton action="{!SendEmail}" value="Send Email" rendered="{!if(emailTemplateOpts.size > 0, true, false)}"/>
</apex:pageBlock> </apex:form>
</apex:page>
Regards
Micky
You can use "rerender" attribute to refresh a part of page on some condition. Please refer below link for sample code:
http://www.oyecode.com/2013/04/how-to-re-render-part-of-visualforce.html