Package: org.springframework.orm.hibernate4
Class: HibernateTransactionManager
Package: org.springframework.orm.hibernate4
Class: HibernateTransactionManager
package com.pkm.evict_entity import grails.util.Holders import org.hibernate.SessionFactory /** * Created by pritom on 3/08/2016. */ class EvictEntityInstance { public static void _evict(def domainInstance) { getBean(SessionFactory).currentSession.evict(domainInstance) } public static <T> T getBean(Class<T> requiredType) { try { return Holders.applicationContext.getBean(requiredType) } catch (Exception e) { return null } } }
global with sharing class QuoteCustomPdfGenerator { private ApexPages.StandardController sc; public Quote q {get; private set;} public String id {get; private set;} public QuoteCustomPdfGenerator(ApexPages.StandardController controller) { this.sc = sc; this.id = ApexPages.currentPage().getParameters().get('Id'); this.q = [SELECT Id,Name From Quote WHERE Id=:this.id]; } public PageReference viewPdf() { return null; } webService static String createQuotePdf(String Id) { try { PageReference pageRef = new PageReference('/apex/QuoteCustomPdfView?Id='+Id); Blob content = pageRef.getContent(); QuoteDocument doc = new QuoteDocument(Document = content, QuoteId = Id); insert doc; return 'SUCCESS'; } catch(exception ex) { System.debug('--- Error ----------'+ ex); return ex.getMessage(); } } }
<apex:page standardController="Quote" extensions="QuoteCustomPdfGenerator" action="{!viewPdf}" renderAs="pdf"> This is my custom pdf for the quote=[[{!q.Name}]] </apex:page>
function SaveQuoteAsCustomPDF(quoteId) { try { var res = sforce.apex.execute("QuoteCustomPdfGenerator","createQuotePdf",{Id : quoteId}); if(res=='SUCCESS') { window.location.reload(); } else { alert('Error in attaching file ----'+ res); } } catch(er) { alert(er); } }
{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")} {!REQUIRESCRIPT("/resource/1470022474000/SaveQuoteAsCustomPDF")} /* Location from step 5 */ var pdfOverlay = QuotePDFPreview.quotePDFObjs['quotePDFOverlay']; pdfOverlay.dialog.buttonContents = '<input value=\"Save Quote As PDF\" class=\"btn\" name=\"save\" onclick=\"SaveQuoteAsCustomPDF(\'{!Quote.Id}\');\" title=\"Save Quote As PDF\" type=\"button\" /><input value=\"Close\" class=\"btn\" name=\"cancel\" onclick=\"QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').close();\" title=\"Close\" type=\"button\" />'; pdfOverlay.setSavable(true); pdfOverlay.setPDFContents('/apex/QuoteCustomPdfView?Id={!Quote.Id}',null,null); pdfOverlay.display();
<apex:page standardController="Account" extensions="APEX_CONTROLLER_CLASS_NAME" action="{!YOUR_ACTION_NAME}"> DO YOUR OTHER WORKS HERE... </apex:page>
public class CommonJsonParser { public cls_Parent[] parentList; class cls_Parent { public Integer intType; public Double doubleType; public String stringType; public cls_Child[] childList; } class cls_Child { public Integer param_1; public String param_2; } public static CommonJsonParser parse(String json){ return (CommonJsonParser) System.JSON.deserialize(json, CommonJsonParser.class); } public static String test() { String json = '{"parentList":[' + '{"intType":1,"doubleType":1.5,"stringType":"String_1",' + '"childList":[' + '{"param_1":1,"param_2":"String_100"},' + '{"param_1":5,"param_2":"String_101"}]}'+ ',{"intType":2,"doubleType":2.5,"stringType":"String_2",' + '"childList":[' + '{"param_1":6,"param_2":"String_102"},' + '{"param_1":2,"param_2":"String_103"},' + '{"param_1":1,"param_2":"String_104"}]}]}'; CommonJsonParser obj = parse(json); String output = ''; for(cls_Parent cParent : obj.parentList) { output += '<br/>'; output += '[[ Integer_Value=' + cParent.intType; output += ', Double_Value=' + cParent.doubleType; output += ', String_Value=' + cParent.stringType + ' ]]'; for(cls_Child cChild: cParent.childList) { output += '<br/> Param_1=' + cChild.param_1; output += ', Param_2=' + cChild.param_2; } } return output; } }
public with sharing class CommonController { private ApexPages.StandardController standardController; public Account account { get; private set; } public CommonController (ApexPages.StandardController standardController) { this.standardController = standardController; Id recordId = standardController.getId(); account = (Account) standardController.getRecord(); } public PageReference doSomething() { //after some tasks return to Account details view return standardController.view(); } public PageReference cancel() { // return to account details view return standardController.view(); } }
<apex:page standardController="Account" extensions="CommonController"> Account_Selected=<b>{!Account.Name}</b><br/> <apex:form > <apex:commandButton value="Do something in CommonController.doSomething()" action="{!doSomething}"/> <apex:commandButton value="Cancel this process & return to details view" action="{!cancel}"/> </apex:form> </apex:page>