You need to sign in to do that
Don't have an account?
Salesforce 283
Object records are displayed in one page. Each record has one edit button when we click on that one popup will be diplayed.
Hi Folks,
But when i am clicking on button popup have not displayed. Please go through below code. Thanks in advance.
VF Page:
<apex:page controller="popup4" >
<style type="text/css">
.popup
{
background-color: orange;
border-width: 2px;
border-style: solid;
z-index: 9999;
left: 50%;
padding:10px;
position: absolute;
width: 400px;
margin-left: -250px;
top:80px;
}
</style>
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!details}" var="ac">
<apex:column value="{!ac.name}"/>
<apex:column value="{!ac.phone}"/>
<apex:column headervalue="Details">
<apex:commandButton value="Edit" action="{!edit}" />
<apex:param name="id" value="{!ac.id}" assignTo="{!aid}"/>
</apex:column>
<apex:outputPanel >
<apex:outputPanel styleClass="popup" rendered="{!displaypopup}"/>
<apex:outputField value="{!ac.name}"/>
<apex:outputField value="{!ac.phone}"/>
<apex:outputField value="{!ac.Email__c}"/>
</apex:outputPanel>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
public with sharing class popup4 {
public String aid { get; set; }
public boolean displaypopup{set;get;}
public list<account>acct{set;get;}
public PageReference edit()
{
displaypopup=true;
string aid=apexpages.currentpage().getparameters().get('id');
acct=[select id,name,phone,email__c from account where id=:aid];
return null;
}
public list<account>details{set;get;}
public popup4()
{
details=[select name,phone from account];
}
}
But when i am clicking on button popup have not displayed. Please go through below code. Thanks in advance.
VF Page:
<apex:page controller="popup4" >
<style type="text/css">
.popup
{
background-color: orange;
border-width: 2px;
border-style: solid;
z-index: 9999;
left: 50%;
padding:10px;
position: absolute;
width: 400px;
margin-left: -250px;
top:80px;
}
</style>
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!details}" var="ac">
<apex:column value="{!ac.name}"/>
<apex:column value="{!ac.phone}"/>
<apex:column headervalue="Details">
<apex:commandButton value="Edit" action="{!edit}" />
<apex:param name="id" value="{!ac.id}" assignTo="{!aid}"/>
</apex:column>
<apex:outputPanel >
<apex:outputPanel styleClass="popup" rendered="{!displaypopup}"/>
<apex:outputField value="{!ac.name}"/>
<apex:outputField value="{!ac.phone}"/>
<apex:outputField value="{!ac.Email__c}"/>
</apex:outputPanel>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
public with sharing class popup4 {
public String aid { get; set; }
public boolean displaypopup{set;get;}
public list<account>acct{set;get;}
public PageReference edit()
{
displaypopup=true;
string aid=apexpages.currentpage().getparameters().get('id');
acct=[select id,name,phone,email__c from account where id=:aid];
return null;
}
public list<account>details{set;get;}
public popup4()
{
details=[select name,phone from account];
}
}
Hi salesforce developer 31,
When we use commandButton without rerender attribute then apex:param will not work. (It is known issue to salesforce).
So resolution is to use commandLink.
In controller 'acct' is getter setter and is a list containing only one record, so we have used acct[0].name
If any of my above answers resolved your question then mark this question as 'SOLVED', so other people can get help from this.
Warm Regards,
Darshan Shah :)
All Answers
Hi salesforce developer 31,
I am reposting your code with some updates: (put outputPanel outside the pageBlock and added param inside the commandButton).
Kindly let me know whether it works or not.
Page:
<apex:form>
<apex:outputPanel id="opPopup">
<apex:outputPanel styleClass="popup" rendered="{!displaypopup}">
<apex:outputField value="{!acct[0].name}"/>
<apex:outputField value="{!acct[0].phone}"/>
</apex:outputPanel>
</apex:outputPanel>
<apex:pageBlock >
<apex:pageBlockTable value="{!details}" var="ac">
<apex:column value="{!ac.name}"/>
<apex:column value="{!ac.phone}"/>
<apex:column headervalue="Details">
<apex:commandButton value="Edit" action="{!edit}" reRender="opPopup">
<apex:param name="id" assignTo="{!aid}" value="{!ac.id}" />
</apex:commandButton>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
Warm Regards,
Darshan Shah
Make output panel as below:
<apex:outputPanel id="opPopup">
<apex:outputPanel styleClass="popup" rendered="{!displaypopup}">
<apex:outputLabel value="Name: " />
<apex:outputField value="{!acct[0].name}"/><br/>
<apex:outputLabel value="Phone: " />
<apex:outputField value="{!acct[0].phone}"/>
</apex:outputPanel>
</apex:outputPanel>
If page is displaying some records with values then clicking on 'Edit' will also show some values.
Please check screenshot from my org below:
Kindly let me know if you need more information.
Regards,
Darshan
Try to make commandButton to commandLink
OR
you can post your class and page here so I can help.
Hi salesforce developer 31,
When we use commandButton without rerender attribute then apex:param will not work. (It is known issue to salesforce).
So resolution is to use commandLink.
In controller 'acct' is getter setter and is a list containing only one record, so we have used acct[0].name
If any of my above answers resolved your question then mark this question as 'SOLVED', so other people can get help from this.
Warm Regards,
Darshan Shah :)