📄 datasourcefield_engine.java
字号:
//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .////// DataSourceField_Engine// EV 04.12.2000//// getInstance()// authoriseRender()// renderLink()// needsJahiaData()// handleActions()//package org.jahia.engines.datasourcefield;import java.io.*; // PrintWriterimport java.util.*; // Enumerationimport java.net.*; // URLEncoderimport org.jahia.utils.*; // JahiaConsoleimport org.jahia.data.*; // JahiaDataimport org.jahia.data.fields.*; // JahiaFieldimport org.jahia.params.*; // ParamBeanimport org.jahia.engines.*; // JahiaEngine interface, EngineParamsimport org.jahia.registries.*; // ServicesRegistryimport org.jahia.exceptions.JahiaException;public class DataSourceField_Engine implements JahiaEngine { private static DataSourceField_Engine theObject = null; private String engineName = "datasourcefield"; /*** * constructor * EV 04.12.2000 * */ private DataSourceField_Engine() { // JahiaConsole.println( "Engine", "***** Starting DataSourceField Engine *****" ); } // end constructor /*** * getInstance * EV 04.12.2000 * */ public static synchronized DataSourceField_Engine getInstance() { if (theObject == null) { theObject = new DataSourceField_Engine(); } return theObject; } // end getInstance /*** * authoriseRender * EV 04.12.2000 * */ public boolean authoriseRender( ParamBean jParams ) { return (jParams.getOperationMode() == jParams.EDIT); } // end authoriseRender /*** * renderLink * EV 04.12.2000 * to be changed... normally, won't need a link * */ public String renderLink( ParamBean jParams, Object theObj ) throws JahiaException { JahiaField theField = (JahiaField) theObj; String params = "";// params += "&mode=displaywindow"; params += "?mode=displaywindow"; params += "&fid=" + theField.getID(); return jParams.composeEngineUrl( engineName, params ); } // end renderLink /*** * needsJahiaData * EV 04.12.2000 * it doesn't need JahiaData !! * */ public boolean needsJahiaData( ParamBean jParams ) { return false; } // end needsJahiaData /*** * handleActions * EV 04.12.2000 * */ public void handleActions( ParamBean jParams, JahiaData jData ) throws JahiaException { String mode = jParams.getRequest().getParameter( "mode" ); String ipAddr = jParams.getRequest().getRemoteAddr(); int fid = jParams.getFieldID(); if (mode != null) { if (mode.equals("displaydata")) { JahiaConsole.println( "DataSourceField_Engine", ipAddr + " is accessing DataSourceField " + fid ); handleFieldData( jParams ); } } } // end handleAction /*** * handleFieldData() * EV 04.12.2000 * */ public void handleFieldData( ParamBean jParams ) throws JahiaException { String html = ""; String theValue = ""; int fieldID = jParams.getFieldID(); JahiaField theField = ServicesRegistry.getInstance().getJahiaFieldService().loadField( fieldID, jParams ); if (theField != null) { theValue = theField.getValue(); } else { theValue = "- error in retrieving field -"; } sendFieldData( jParams, theValue ); } // end handleFieldData /*** * sendFieldData() * EV 04.12.2000 * */ public void sendFieldData( ParamBean jParams, String fieldValue ) throws JahiaException { try { PrintWriter out = jParams.getResponse().getWriter(); jParams.getResponse().setContentType( "text/html" ); out.println( fieldValue ); } catch (IOException ie) { String errorMsg = "Error while returning a datasource field : " + ie.getMessage() + " -> BAILING OUT"; JahiaConsole.println( "DataSourceField_Engine", errorMsg ); throw new JahiaException( "Cannot retrieve remote data", errorMsg, JahiaException.DATA_ERROR, JahiaException.CRITICAL ); } } // end sendFieldData} // end DataSourceField_Engine
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -