📄 viewdatasourceid_engine.java
字号:
//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .////// ViewDataSourceID_Engine// EV 04.12.2000//// getInstance()// authoriseRender()// renderLink()// needsJahiaData()// handleActions()//package org.jahia.engines.viewdatasourceid;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.exceptions.JahiaException;public class ViewDataSourceID_Engine implements JahiaEngine { private static ViewDataSourceID_Engine theObject = null; private String engineName = "viewdatasourceid"; /*** * constructor * EV 04.12.2000 * */ private ViewDataSourceID_Engine() { // JahiaConsole.println( "Engine", "***** Starting ViewDataSourceID Engine *****" ); } // end constructor /*** * getInstance * EV 04.12.2000 * */ public static synchronized ViewDataSourceID_Engine getInstance() { if (theObject == null) { theObject = new ViewDataSourceID_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 * */ public String renderLink( ParamBean jParams, Object theObj ) throws JahiaException { JahiaField theField = (JahiaField) theObj; String params = "";// params += "&mode=displayid"; params += "?mode=displayid"; 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("displayid")) { JahiaConsole.println( "ViewDataSourceID_Engine", ipAddr + " is accessing ViewDataSourceID " + fid ); displayID( jParams, fid ); } } } // end handleAction /*** * displayID() * EV 04.12.2000 * */ public void displayID( ParamBean jParams, int fieldID ) throws JahiaException { try { PrintWriter out = jParams.getResponse().getWriter(); jParams.getResponse().setContentType( "text/html" ); String dsUrl = jParams.composeEngineUrl( "datasourcefield", "&mode=displaydata&fid=" + fieldID ); String html = ""; html += "<html><head><title>Data Source ID</title></head>\n"; html += "<body bgcolor=\"black\" onLoad=\"document.ds.dsid.focus();document.ds.dsid.select()\">\n"; html += "<font color=\"white\" size=\"2\"><b>Data Source ID :</b><br>\n"; html += "<form name=\"ds\"><input type=\"text\" name=\"dsid\" size=\"60\" value=\"" + dsUrl + "\"><br>\n"; html += "<input type=\"button\" value=\"Close\" onClick=\"window.close()\">\n"; html += "</form></body></html>"; out.println( html ); } 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 ViewDataSourceID_Engine
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -