如何从视觉力页面获取指定自定义对象记录的ID到apex类?
我正在尝试做一个小项目,但我陷入困境,因为我无法从 vf 页面到 apex 类中提取自定义对象的指定记录的 ID,代码如下所示
<apex:page standardController="enquiry__c" extensions='callme' recordSetVar="items"> <!--here enquiry__c is a custom object -->
<apex:form>
<apex:pageblock>
<apex:pageblocksection>
<apex:pageBlockTable value='{!items}' var='en' width="200" >
<apex:column value='{!en.name}'/>
<apex:column value='{!en.Student_Enquiry_Name__c}'/>
<apex:column value='{!en.phone__c}'/>
<apex:column value='{!en.email__c}'/>
<apex:column value='{!en.Status__c}'/>
<apex:column headerValue="Action">
<apex:commandButton value='convert to student'/>
</apex:column>
<apex:column headerValue="Record ID">
<apex:outputText value='{!en.id}' />
</apex:column>
</apex:pageBlockTable>
<apex:commandButton value='new' action='{!newenquiry}'/>
</apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>
是,当我单击特定记录旁边的“转换为学生”按钮时,我必须将该记录的 ID 获取到 apex 类中,并且 apex 代码是下面给出
public class callme
{
public enquiry__c e {get;set;}
public id i {get;set;}
public callme(ApexPages.StandardSetController c)
{
}
public PageReference newenquiry()
{
PageReference p=new PageReference('/apex/vfTab_on_enquiry');
return p;
}
public PageReference newcourse()
{
PageReference p=new PageReference('/apex/courseInsertion');
return p;
}
}
请帮我解决这个问题,提前致谢。
I'm trying to do a small project and I am stuck as I couldn't pull out the ID of the specified record of a custom object from vf page to apex class the code is given below
<apex:page standardController="enquiry__c" extensions='callme' recordSetVar="items"> <!--here enquiry__c is a custom object -->
<apex:form>
<apex:pageblock>
<apex:pageblocksection>
<apex:pageBlockTable value='{!items}' var='en' width="200" >
<apex:column value='{!en.name}'/>
<apex:column value='{!en.Student_Enquiry_Name__c}'/>
<apex:column value='{!en.phone__c}'/>
<apex:column value='{!en.email__c}'/>
<apex:column value='{!en.Status__c}'/>
<apex:column headerValue="Action">
<apex:commandButton value='convert to student'/>
</apex:column>
<apex:column headerValue="Record ID">
<apex:outputText value='{!en.id}' />
</apex:column>
</apex:pageBlockTable>
<apex:commandButton value='new' action='{!newenquiry}'/>
</apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>
So my question is when I click on button "convert to student" beside a particular record I have to get the ID of that record into apex class and the apex code is given below
public class callme
{
public enquiry__c e {get;set;}
public id i {get;set;}
public callme(ApexPages.StandardSetController c)
{
}
public PageReference newenquiry()
{
PageReference p=new PageReference('/apex/vfTab_on_enquiry');
return p;
}
public PageReference newcourse()
{
PageReference p=new PageReference('/apex/courseInsertion');
return p;
}
}
Please help me with this, thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
->您可以为此使用 actionFunction 。
->创建一个名为 callActionMethod 的 js 函数,并在单击“转换为学生”按钮时调用此函数。
->在 apex 类中创建 ConvertStudent 方法。
->创建一个名为 callConvertStudentMethod 的操作函数,并将记录 id 传递给参数。
Apex 控制器:
VF 页面:
-> you can use actionFunction for this.
-> create a js function called callActionMethod and invoke this function on the click of "convert to student" button.
-> create convertStudent method in apex class.
-> create an actionfunction named callConvertStudentMethod and pass the record id to the parameter.
Apex Controller:
VF Page: