我知道这是保存记录的方法
<apex:commandButton action="{!save}" value="Save"/>我想要一个按钮,不保存当前记录(即,取消)并导航到已保存记录的列表(即该对象类型的对象列表)。
就像这样..。
<apex:commandButton action="{!cancel}" value="Cancel"/>发布于 2012-01-19 13:31:29
对象的列表视图是您的基本URL /对象的3个字母的前缀/ o,例如:
https://na1.salesforce.com/a0C/o因此,您只需创建一个操作方法,该方法返回一个具有适当URL并设置为重定向(pr.setRedirect(true))的Pagereference。
或者,您可以使用您的控制器作为标准控制器的扩展,并且仅使用call cancel on the standard controller
// controller extension
public class TimeSheetExtension
{
ApexPages.standardController m_sc = null;
public TimeSheetExtension(ApexPages.standardController sc)
{
m_sc = sc;
}
public PageReference doCancel()
{
return m_sc.cancel();
}
}
// page
<apex:commandButton action="{!doCancel}" value="Cancel"/>请注意,这并不一定会将您带到列表视图,它会返回到您在转到VF页面之前查看的最后一个页面。
发布于 2012-05-21 21:12:30
您还应该向Cancel按钮添加immediate标记,这样表单在执行Cancel操作之前不会运行任何验证。
<apex:commandButton action="{!cancel}" immediate="true" value="Cancel"/>请参阅http://blogs.developerforce.com/developer-relations/2008/12/using-the-immediate-attribute-on-commandlinks-and-commandbuttons.html
发布于 2015-04-10 15:08:10
当应用取消操作visualforce时,您应该停止表单validation.Use下面的任何一种方法,以根据您的要求停止表单验证。
方法1:
在visualforce页面的doctype中使用html-5意味着您应该在取消按钮中使用html-formnovalidate和immediate。例如
<apex:commandButton action="{!cancel}" value="Cancel" immediate="true"
html-formnovalidate="formnovalidate" />方法2:
您应该使用仅在停止表单验证时才需要的immediate关键字。例如
<apex:commandButton action="{!cancel}" value="Cancel" immediate="true"/>https://stackoverflow.com/questions/8921434
复制相似问题