Skip to content

Instantly share code, notes, and snippets.

@tyoshikawa1106
Last active December 16, 2015 14:19
Show Gist options
  • Save tyoshikawa1106/5447874 to your computer and use it in GitHub Desktop.
Save tyoshikawa1106/5447874 to your computer and use it in GitHub Desktop.
CancelButton Component
<apex:component controller="CancelButtonController" id="cancelButtonComponent">
<apex:attribute name="cancelButtonLabel" type="String" assignTo="{!prmCancelButtonLabel}" description="cancelButtonLabel" />
<apex:attribute name="returnUrl" type="PageReference" assignTo="{!prmReturnUrl}" description="returnUrl" />
<apex:attribute name="reRenderArea" type="String" description="reRenderArea" />
<apex:commandButton value="{!prmCancelButtonLabel}" title="{!prmCancelButtonLabel}" action="{!doReturn}" reRender="{!reRenderArea}" id="cancelButton" />
</apex:component>
public with sharing class CancelButtonController {
public String prmCancelButtonLabel {get; set;}
public PageReference prmReturnUrl {get; set;}
private static final PageReference DEFAULT_URL = new PageReference('/home/home.jsp');
/*
* コンストラクタ
* @param : なし
* @return : なし
*/
public CancelButtonController() {
this.prmCancelButtonLabel = '';
this.prmReturnUrl = null;
}
/*
* 前ページ遷移
* @param : なし
* @return : 遷移先URL
*/
public PageReference doReturn() {
return getReturnUrl(this.prmReturnUrl);
}
/*
* 遷移先URL取得
* @param : 前ページURL [prmReturnUrl]
* @return : 遷移先URL
*/
private PageReference getReturnUrl(PageReference prmReturnUrl) {
return prmReturnUrl == null ? DEFAULT_URL : prmReturnUrl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment