📄 float_field.jsp
字号:
<%@ page language="java" %><%@ page import="org.jahia.utils.*" %><%@ page import="org.jahia.data.*" %><%@ page import="org.jahia.data.fields.*" %><%@ page import="org.jahia.params.*" %><%@ page import="org.jahia.services.*" %><%@ page import="org.jahia.services.pages.*" %><%@ page import="org.jahia.registries.*" %><%@ page import="java.util.*" %><%! Boolean isIE = (Boolean) request.getAttribute( "isIE" ); private String contextID (int id) { return JahiaTools.replacePattern(String.valueOf(id),"-","_"); }%><% HashMap engineMap = (HashMap) request.getAttribute( "org.jahia.engines.EngineHashMap" ); JahiaField theField = (JahiaField) engineMap.get( "theField" ); String engineUrl = (String) engineMap.get( "engineUrl" ); String dataSourceConnectUrl= (String) engineMap.get( "dataSourceConnectUrl" ); String dataSourceIDUrl = (String) engineMap.get( "dataSourceIDUrl" ); String localSwitchUrl = (String) engineMap.get( "localSwitchUrl" ); ParamBean jParams = (ParamBean) engineMap.get( "jParams" ); String theURL = (String) jParams.settings().getJahiaEnginesHttpPath(); String URLSep = (engineUrl.indexOf("?") == -1) ? "?" : "&" ; int pageID = theField.getPageID(); JahiaPage thePage = ServicesRegistry.getInstance().getJahiaPageService().lookupPage( pageID ); String defValue = theField.getDefinition().getDefaultValue(thePage.getPageTemplateID()); Boolean isSelectedField = (Boolean) engineMap.get( "isSelectedField" ); String contextID = contextID(theField.getID());%><% if (defValue != null && !defValue.equals("") && defValue.toUpperCase().indexOf("JAHIA_MULTIVALUE") != -1 ) { %><% String theSelectedField = theField.getValue(); String theNewField = ""; String strToRemove[] = {"<JAHIA", "_MULTIVALUE"}; for (int i = 0; i < strToRemove.length; i++) { String upperCaseField = theSelectedField.toUpperCase(); int index = upperCaseField.indexOf(strToRemove[i]); if (index != -1) { theNewField = theSelectedField.substring(0, index) + theSelectedField.substring(index + strToRemove[i].length(), theSelectedField.length()); theSelectedField = theNewField; } } if (theSelectedField.indexOf("[") != -1) { int startStr = theSelectedField.indexOf("["); int endStr = theSelectedField.indexOf("]>") + 2; theSelectedField = theSelectedField.substring(0,startStr) + theSelectedField.substring(endStr,theSelectedField.length()); }%><% if (defValue.indexOf("[") != -1) { int startStr = defValue.indexOf("[") + 1; int endStr = defValue.indexOf("]"); String theList = defValue.substring(startStr,endStr); %> <span class="input"><select class="input" name="listSelection_<%=contextID%>" onChange="document.mainForm.elements['_<%=theField.getID()%>'].value = document.mainForm.listSelection_<%=contextID%>.options[document.mainForm.listSelection_<%=contextID%>.selectedIndex].value;"> <% while (true) { String theSelection = ""; if (theList.indexOf(":") != -1) { endStr = theList.indexOf(":"); theSelection = theList.substring(0,endStr); theList = theList.substring(endStr + 1,theList.length()); if (theSelection.equals(theSelectedField)) { %> <option value="<%=theSelection%>" selected><%=theSelection%></option> <% } else { %> <option value="<%=theSelection%>"><%=theSelection%></option> <% } } else { theSelection = theList.substring(0,theList.length()); if (theSelection.equals(theSelectedField)) { %> <option value="<%=theSelection%>" selected><%=theSelection%></option> </select> <% } else { %> <option value="<%=theSelection%>"><%=theSelection%></option> </select></span> <% } break; } } }%><input name="_<%=theField.getID()%>" type="hidden" value="<%=theField.getValue()%>"><SCRIPT type="text/javascript"><!-- document.mainForm.elements['_<%=theField.getID()%>'].value = document.mainForm.listSelection_<%=contextID%>.options[document.mainForm.listSelection_<%=contextID%>.selectedIndex].value;// --></SCRIPT><% if ( isSelectedField.booleanValue() && isIE.booleanValue() ) { %><SCRIPT type="text/javascript"> <!-- function setfocus() { document.mainForm.listSelection_<%=contextID%>.focus(); } setfocus(); // --></SCRIPT><% }} else { int columns = 30; String userAgent = request.getHeader( "user-agent" ); if (userAgent != null) { if (userAgent.indexOf( "MSIE" ) != -1) { columns = 40; } }%><input class="input" type="text" name="_<%=theField.getID()%>" size="<%=columns%>" maxlength="250" value="<%=theField.getValue()%>" onBlur="checkFloat_<%=contextID(theField.getID())%>()"><br><% if ( isSelectedField.booleanValue() ) { %><SCRIPT type="text/javascript"> <!-- function setfocus() { document.mainForm.elements["_<%=theField.getID()%>"].focus(); } setfocus(); // --></SCRIPT><% } } %><SCRIPT type="text/javascript"><!--function checkFloat_<%=contextID(theField.getID())%>() { if ( !(isNaN(document.mainForm.elements["_<%=theField.getID()%>"].value )) || (document.mainForm.elements["_<%=theField.getID()%>"].value == "") ) { document.mainForm.elements["_<%=theField.getID()%>"].value = (document.mainForm.elements["_<%=theField.getID()%>"].value).replace(" ",""); return true; } else { document.mainForm.elements["_<%=theField.getID()%>"].value = 0; document.mainForm.elements["_<%=theField.getID()%>"].focus(); alert("The value must be a number"); return false; }}// --></SCRIPT>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -