function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DeepVDeepV 

popup visualforce shows no data

When I click the edit button, the popup displays but does not display any data. Please help!
What is the mistake I'm doing it here.
what I have tried so far:

Visual Force:

<apex:page standardcontroller="UCF_REL__c" extensions="UCFController" sidebar="false" > 
<apex:sectionheader title="UCF Review" /> 
<apex:messages />
 <apex:form rendered="{!displaySection}"> 
<script type="text/javascript"> function LegalNameChangePopup(){ var newwindow = window.open('RELLegalNameChangePopup', 'name=_blank','height=500,width=500,left=250,top=100'); newwindow.focus(); } 
</script>
 <apex:pageblock title="General Information" > 
<apex:pageblocksection title="Legal Name"> 
<apex:panelgrid columns="2"> 
<!-- <apex:outputlabel value="Account Name: " for="accountName" />-->
 <apex:outputfield id="accountName" value="{!aaccount.name}"/>
 <apex:commandbutton value="Edit" id="accpopup" onclick="LegalNameChangePopup();" styleclass="btn"/>
 </apex:panelgrid>
 </apex:pageblocksection> 
</apex:pageblock> 
<apex:pageblock > 
<apex:pageblocksection columns="4"> 
<apex:commandbutton action="{!step2}" value="Save and Continue" styleclass="btn" />
 <apex:commandbutton action="{!reset}" value="Reset Page" styleclass="btn" immediate="true"/>
 </apex:pageblocksection>
 </apex:pageblock> 
</apex:form>
 </apex:page>

VF for popup: RELLegalNameChangePopup

<apex:page standardcontroller="UCF_REL__c" extensions="UCFController" showheader="false" sidebar="false" id="the">
  <apex:form id="page"> 
<apex:pageBlock >
 <apex:pageBlockSection columns="1" title="Legal Name change"> 
<apex:pageblocktable value="{!aAccount}" var="item" id="editAccountName">
 <apex:column headervalue="Proposed Legal Name">
 <apex:inputtext value="{!item.Name}" />
 </apex:column> </apex:pageblocktable>
 </apex:pageBlockSection> 
</apex:pageBlock>
 </apex:form>
Best Answer chosen by DeepV
KdKomalKdKomal
Hi DeepV,

Please refer the code below which will open a popup with a parameter from the parent page.
<apex:page standardcontroller="Account" extensions="acctControllPopup" sidebar="false" > 
<apex:sectionheader title="UCF Review" /> 
<apex:messages />
 <apex:form rendered="{!displaySection}"> 
<script type="text/javascript"> 
function LegalNameChangePopup(nameId){
var name = document.getElementById(nameId).value;
var url="/apex/popQuestionPagewhichWillOpen?namePp=" + name;
var newwindow = window.open(url,'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no'); 
newwindow.focus(); } 
</script>
 <apex:pageblock title="General Information" > 
<apex:pageblocksection title="Legal Name"> 
<apex:inputText size="40" value="{!accountName}" id="targetName"/>
<apex:panelgrid columns="2"> 
<!-- <apex:outputlabel value="Account Name: " for="accountName" />-->
 <apex:outputfield id="accountName" value="{!account.name}"/>
  
 <apex:commandbutton value="Edit" id="accpopup" onclick="LegalNameChangePopup('{!$Component.targetName}');" styleclass="btn"/>
 </apex:panelgrid>
 </apex:pageblocksection> 
</apex:pageblock> 
<apex:pageblock > 
<apex:pageblocksection columns="4"> 
<apex:commandbutton action="{!step2}" value="Save and Continue" styleclass="btn" />
 <apex:commandbutton action="{!reset}" value="Reset Page" styleclass="btn" immediate="true"/>
 </apex:pageblocksection>
 </apex:pageblock> 
</apex:form>
 </apex:page>

Controller (acctControllPopup)-
 
public with sharing class acctControllPopup {

    public string accountName{get;set;}
    public string namePara{get;set;}
    Public string namePp;
    public string nameAcct;
    public acctControllPopup(ApexPages.StandardController controller) {
        displaySection=true;
        nameAcct= ApexPages.currentPage().getParameters().get('namePp');
        nameAcct= '%'+nameAcct+'%';
        system.debug('nameAcct '+nameAcct);
        aAccount = [Select Id,Name from Account where name like :nameAcct];
        
    }
    
    public List<account> aAccount{get;set;}
    public boolean displaySection{get;set;}
    
    public pageReference step2(){
    return null;
    }
    
    public pageReference reset(){
    return null;
    }
    
    public pageReference setPara(){
    //pageReference pageRef = new pageReference('/apex/popQuestionPagewhichWillOpen');
    //pageRef.getParameters().put('namePp', namePara);
    return null;

    }
}

Its a very basic one but it will probably get your job Done.

I hope it helps.

All Answers

KdKomalKdKomal
Hi Deep,

Could you please share the Controller code as well ?
Narender Singh(Nads)Narender Singh(Nads)
Hi,
Modify your script as follows:

<script type="text/javascript">
       function LegalNameChangePopup(){
           var newwindow = window.open('/apex/RELLegalNameChangePopup', 'name=_blank','height=500,width=500,left=250,top=100');
           newwindow.focus();
       } 
</script>

Let me know if it helps.
Thanks
DeepVDeepV
Hi Kd Komal,

this is what i have in the controller:

public Account aAccount { get; set; }
 public String aAccountID { get; set; }

//inside the constructor
 ID aAccountID = [Select AccountID from Contact where id = :contactid].AccountId;
aAccount = [select id, name from account where id = :aAccountID];
 
Narender Singh(Nads)Narender Singh(Nads)
Hi,
I suggest you share your entire controller class. It will be a whole lot easier to provide you with a solution that way.
DeepVDeepV
Narender, I have tried what you have mentioned. I get the error message when the pop up opens. page under construction.
KdKomalKdKomal
Hi DeepV,

I tried with the Account and It worked with the following results. Please refer the screenshots

User-added image

Following is the code :-

MainPage
<apex:page standardcontroller="Account" extensions="acctControllPopup" sidebar="false" > 
<apex:sectionheader title="UCF Review" /> 
<apex:messages />
 <apex:form rendered="{!displaySection}"> 
<script type="text/javascript"> function LegalNameChangePopup(){ var newwindow = window.open('popQuestionPagewhichWillOpen', 'name=_blank','height=500,width=500,left=250,top=100'); newwindow.focus(); } 
</script>
 <apex:pageblock title="General Information" > 
<apex:pageblocksection title="Legal Name"> 
<apex:panelgrid columns="2"> 
<!-- <apex:outputlabel value="Account Name: " for="accountName" />-->
 <apex:outputfield id="accountName" value="{!account.name}"/>
 <apex:commandbutton value="Edit" id="accpopup" onclick="LegalNameChangePopup();" styleclass="btn"/>
 </apex:panelgrid>
 </apex:pageblocksection> 
</apex:pageblock> 
<apex:pageblock > 
<apex:pageblocksection columns="4"> 
<apex:commandbutton action="{!step2}" value="Save and Continue" styleclass="btn" />
 <apex:commandbutton action="{!reset}" value="Reset Page" styleclass="btn" immediate="true"/>
 </apex:pageblocksection>
 </apex:pageblock> 
</apex:form>
 </apex:page>

Controller
public with sharing class acctControllPopup {

    public acctControllPopup(ApexPages.StandardController controller) {
        displaySection=true;
        aAccount = [Select Id,Name from Account Limit 10];
    }
    
    public List<account> aAccount{get;set;}
    public boolean displaySection{get;set;}
    
    public pageReference step2(){
    return null;
    }
    
    public pageReference reset(){
    return null;
    }
}

Popup Page
<apex:page standardcontroller="Account" extensions="acctControllPopup" showheader="false" sidebar="false" id="the">
  <apex:form id="page"> 
<apex:pageBlock >
 <apex:pageBlockSection columns="1" title="Legal Name change"> 
<apex:pageblocktable value="{!aAccount}" var="item" id="editAccountName">
 <apex:column headervalue="Proposed Legal Name">
 <apex:inputtext value="{!item.Name}" />
 </apex:column> </apex:pageblocktable>
 </apex:pageBlockSection> 
</apex:pageBlock>
 </apex:form>
 </apex:page>

Please let me know if you are trying to pass any data from main page to popup page ?​
DeepVDeepV
Narender, its a lot of lines in the code. It is not allowing me  to post the code here.
DeepVDeepV
Thanks Komal for all the code you have return. I will give a try what you have done, Yes I need to pass id from the main page to the popup.

When the user clicks on Edit Button, then the popup should show up a text field to edit the account name.
DeepVDeepV
meaning the users have the ability to change the account name field with the help of the popup
DeepVDeepV
When I click Edit, popup should show a text field to edit the account name.popup

I am unalbe to show account data on the page.
Narender Singh(Nads)Narender Singh(Nads)
Hi,
​Few points.
Write a new custom controller for your VF Page. It is always good to have modularised code. It's easily manageable.
Once you do that, you can pass account id as a parameter in the url of pop up page at the click of edit button.
Now in the controller of your pop get that parameter using Apexpages.currentpage().getParameters('Your Parameter name')

once you have the account id you can query that record and populate it in your inputtext field.
KdKomalKdKomal
Hi DeepV,

Please refer the code below which will open a popup with a parameter from the parent page.
<apex:page standardcontroller="Account" extensions="acctControllPopup" sidebar="false" > 
<apex:sectionheader title="UCF Review" /> 
<apex:messages />
 <apex:form rendered="{!displaySection}"> 
<script type="text/javascript"> 
function LegalNameChangePopup(nameId){
var name = document.getElementById(nameId).value;
var url="/apex/popQuestionPagewhichWillOpen?namePp=" + name;
var newwindow = window.open(url,'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no'); 
newwindow.focus(); } 
</script>
 <apex:pageblock title="General Information" > 
<apex:pageblocksection title="Legal Name"> 
<apex:inputText size="40" value="{!accountName}" id="targetName"/>
<apex:panelgrid columns="2"> 
<!-- <apex:outputlabel value="Account Name: " for="accountName" />-->
 <apex:outputfield id="accountName" value="{!account.name}"/>
  
 <apex:commandbutton value="Edit" id="accpopup" onclick="LegalNameChangePopup('{!$Component.targetName}');" styleclass="btn"/>
 </apex:panelgrid>
 </apex:pageblocksection> 
</apex:pageblock> 
<apex:pageblock > 
<apex:pageblocksection columns="4"> 
<apex:commandbutton action="{!step2}" value="Save and Continue" styleclass="btn" />
 <apex:commandbutton action="{!reset}" value="Reset Page" styleclass="btn" immediate="true"/>
 </apex:pageblocksection>
 </apex:pageblock> 
</apex:form>
 </apex:page>

Controller (acctControllPopup)-
 
public with sharing class acctControllPopup {

    public string accountName{get;set;}
    public string namePara{get;set;}
    Public string namePp;
    public string nameAcct;
    public acctControllPopup(ApexPages.StandardController controller) {
        displaySection=true;
        nameAcct= ApexPages.currentPage().getParameters().get('namePp');
        nameAcct= '%'+nameAcct+'%';
        system.debug('nameAcct '+nameAcct);
        aAccount = [Select Id,Name from Account where name like :nameAcct];
        
    }
    
    public List<account> aAccount{get;set;}
    public boolean displaySection{get;set;}
    
    public pageReference step2(){
    return null;
    }
    
    public pageReference reset(){
    return null;
    }
    
    public pageReference setPara(){
    //pageReference pageRef = new pageReference('/apex/popQuestionPagewhichWillOpen');
    //pageRef.getParameters().put('namePp', namePara);
    return null;

    }
}

Its a very basic one but it will probably get your job Done.

I hope it helps.
This was selected as the best answer
DeepVDeepV
thanks Komal, I don't know why. I'm getting the insufficient priveleges error messege.
KdKomalKdKomal
Hi varsha, 

Your profile has read access on the visualforce page right? 
DeepVDeepV
Yes, you got it Komal. Thanks for helping me out to resolve the issue. 
KdKomalKdKomal
Please mark it as the best answer if it helped you resolve the issue