Its a very common requirement to open a pop up by clicking a button . Once you are done with pop up, close the pop up and refresh the parent window so that user will be able to see the update on parent window at the same time.
<script language="JavaScript" type="text/javascript">
function CloseAndRefresh(){
window.opener.location.href="/{!$CurrentPage.parameters.id}";
window.top.close();
}
</script>
Note: I would suggest to check this setting Setup-> Personal Setup -> My Personal Information -> Personal Information
Here check for “Development Mode”. I have seen at various places and at community as well that if this check box is checked then popup would not close. Here, I would suggest to turn this checkbox off while you are testing this.
In below example I’ve created a custom multiselect picklist “Interests” on “Student” custom object. I’m displaying multiselect picklist to checkboxes in visualforce page.
Multiselect Picklist Field:
Controller:
public class SampleControllerExtn {
public Student__c student {get;set;}
public SampleControllerExtn(ApexPages.StandardController stdCtrl) {
student = (Student__c)stdCtrl.getRecord();
}
public void saveStudent(){
Upsert student;
}
//get the multi-select pick list values
public List<SelectOption> getMSPicklist {
get {
List<SelectOption> options = new List<SelectOption>();
for( Schema.PicklistEntry obj : Student__c.Interests__c.getDescribe().getPicklistValues()) {
options.add(new SelectOption(obj.getValue(), obj.getLabel()));
}
return options;
}
set;
}
//get and set the multi-select pick list as checkboxes
public String[] MSItems {
get {
List<String> selected = new List<String>();
List<SelectOption> options = this.getMSPicklist;
for(SelectOption obj : options) {
if (this.student.Interests__c !=null && this.student.Interests__c.contains(obj.getValue()))
selected.add(obj.getValue());
}
return selected;
}public set {
String selectedCheckBox = '';
for(String s : value) {
if (selectedCheckBox == '')
selectedCheckBox += s;
else selectedCheckBox += ';' + s;
}
student.Interests__c = selectedCheckBox;
}
}
}