From commits-return-41159-archive-asf-public=cust-asf.ponee.io@ofbiz.apache.org Sat Feb 1 10:08:41 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 784A1180657 for ; Sat, 1 Feb 2020 11:08:40 +0100 (CET) Received: (qmail 20138 invoked by uid 500); 1 Feb 2020 10:08:39 -0000 Mailing-List: contact commits-help@ofbiz.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ofbiz.apache.org Delivered-To: mailing list commits@ofbiz.apache.org Received: (qmail 20128 invoked by uid 99); 1 Feb 2020 10:08:39 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Feb 2020 10:08:39 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 49F038B690; Sat, 1 Feb 2020 10:08:39 +0000 (UTC) Date: Sat, 01 Feb 2020 10:08:39 +0000 To: "commits@ofbiz.apache.org" Subject: [ofbiz-framework] branch release17.12 updated: Improved: Improve error message page to support Theming (OFBIZ-10753) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <158055171922.27487.6352875528004535583@gitbox.apache.org> From: jleroux@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: ofbiz-framework X-Git-Refname: refs/heads/release17.12 X-Git-Reftype: branch X-Git-Oldrev: 832217135a4f1e6cffef2ef15d115f43613166bc X-Git-Newrev: 9b9db9e5111dc5bdf3c3a2fed39e81563343d7ef X-Git-Rev: 9b9db9e5111dc5bdf3c3a2fed39e81563343d7ef X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. jleroux pushed a commit to branch release17.12 in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git The following commit(s) were added to refs/heads/release17.12 by this push: new 9b9db9e Improved: Improve error message page to support Theming (OFBIZ-10753) 9b9db9e is described below commit 9b9db9e5111dc5bdf3c3a2fed39e81563343d7ef Author: Nicolas Malin AuthorDate: Mon Mar 25 09:31:02 2019 +0000 Improved: Improve error message page to support Theming (OFBIZ-10753) When OFBiz raise an error, the framework use a jsp page to display it. I improved the error page generation to support also ftl template rendering and by this way extend the theme engine to support to overide it On controler.xml we can now use : /error/error.jsp or component://common/webcommon/error/Error.ftl (default configuration) On your theme you can add your own error page : The component://common/webcommon/error/Error.ftl contains the logic theming connection and to simplify source code, all framework old error page (error.jsp) have been removed to centralize all on this new page. Thanks to Marine Desmarchelier for the error page design git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1856175 13f79535-47bb-0310-9956-ffa450edef68 # Conflicts: # framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlServlet.java # themes/common/template/ErrorPage.ftl --- .../accounting/webapp/accounting/error/error.jsp | 52 ------------- applications/accounting/webapp/ap/error/error.jsp | 52 ------------- applications/accounting/webapp/ar/error/error.jsp | 52 ------------- .../commonext/webapp/ofbizsetup/error/error.jsp | 52 ------------- .../content/webapp/content/error/error.jsp | 52 ------------- .../humanres/webapp/humanres/error/error.jsp | 52 ------------- .../webapp/manufacturing/error/error.jsp | 52 ------------- .../marketing/webapp/marketing/error/error.jsp | 53 ------------- applications/marketing/webapp/sfa/error/error.jsp | 53 ------------- applications/order/webapp/ordermgr/error/error.jsp | 52 ------------- applications/party/webapp/partymgr/error/error.jsp | 53 ------------- .../product/webapp/catalog/error/error.jsp | 53 ------------- .../product/webapp/facility/error/error.jsp | 53 ------------- .../workeffort/webapp/workeffort/error/error.jsp | 53 ------------- .../common/webcommon/WEB-INF/common-controller.xml | 2 +- framework/common/webcommon/error/Error.ftl | 42 +++++++++++ framework/resources/templates/error.jsp | 53 ------------- .../ofbiz/webapp/control/ControlServlet.java | 86 +++++++++++++++------- .../ofbiz/webapp/control/RequestHandler.java | 15 ++-- framework/webtools/webapp/webtools/error/error.jsp | 52 ------------- framework/widget/dtd/widget-theme.xsd | 3 +- .../org/apache/ofbiz/widget/model/ModelTheme.java | 17 +++++ themes/common/widget/Theme.xml | 1 + 23 files changed, 131 insertions(+), 874 deletions(-) diff --git a/applications/accounting/webapp/accounting/error/error.jsp b/applications/accounting/webapp/accounting/error/error.jsp deleted file mode 100644 index 5f4de01..0000000 --- a/applications/accounting/webapp/accounting/error/error.jsp +++ /dev/null @@ -1,52 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - diff --git a/applications/accounting/webapp/ap/error/error.jsp b/applications/accounting/webapp/ap/error/error.jsp deleted file mode 100644 index 5f4de01..0000000 --- a/applications/accounting/webapp/ap/error/error.jsp +++ /dev/null @@ -1,52 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - diff --git a/applications/accounting/webapp/ar/error/error.jsp b/applications/accounting/webapp/ar/error/error.jsp deleted file mode 100644 index 5f4de01..0000000 --- a/applications/accounting/webapp/ar/error/error.jsp +++ /dev/null @@ -1,52 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - diff --git a/applications/commonext/webapp/ofbizsetup/error/error.jsp b/applications/commonext/webapp/ofbizsetup/error/error.jsp deleted file mode 100644 index 5f4de01..0000000 --- a/applications/commonext/webapp/ofbizsetup/error/error.jsp +++ /dev/null @@ -1,52 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - diff --git a/applications/content/webapp/content/error/error.jsp b/applications/content/webapp/content/error/error.jsp deleted file mode 100644 index 5f4de01..0000000 --- a/applications/content/webapp/content/error/error.jsp +++ /dev/null @@ -1,52 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - diff --git a/applications/humanres/webapp/humanres/error/error.jsp b/applications/humanres/webapp/humanres/error/error.jsp deleted file mode 100644 index 5f4de01..0000000 --- a/applications/humanres/webapp/humanres/error/error.jsp +++ /dev/null @@ -1,52 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - diff --git a/applications/manufacturing/webapp/manufacturing/error/error.jsp b/applications/manufacturing/webapp/manufacturing/error/error.jsp deleted file mode 100644 index 5f4de01..0000000 --- a/applications/manufacturing/webapp/manufacturing/error/error.jsp +++ /dev/null @@ -1,52 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - diff --git a/applications/marketing/webapp/marketing/error/error.jsp b/applications/marketing/webapp/marketing/error/error.jsp deleted file mode 100644 index 83f0147..0000000 --- a/applications/marketing/webapp/marketing/error/error.jsp +++ /dev/null @@ -1,53 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> - -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - diff --git a/applications/marketing/webapp/sfa/error/error.jsp b/applications/marketing/webapp/sfa/error/error.jsp deleted file mode 100644 index 83f0147..0000000 --- a/applications/marketing/webapp/sfa/error/error.jsp +++ /dev/null @@ -1,53 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> - -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - diff --git a/applications/order/webapp/ordermgr/error/error.jsp b/applications/order/webapp/ordermgr/error/error.jsp deleted file mode 100644 index 5f4de01..0000000 --- a/applications/order/webapp/ordermgr/error/error.jsp +++ /dev/null @@ -1,52 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - diff --git a/applications/party/webapp/partymgr/error/error.jsp b/applications/party/webapp/partymgr/error/error.jsp deleted file mode 100644 index 83f0147..0000000 --- a/applications/party/webapp/partymgr/error/error.jsp +++ /dev/null @@ -1,53 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> - -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - diff --git a/applications/product/webapp/catalog/error/error.jsp b/applications/product/webapp/catalog/error/error.jsp deleted file mode 100644 index 83f0147..0000000 --- a/applications/product/webapp/catalog/error/error.jsp +++ /dev/null @@ -1,53 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> - -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - diff --git a/applications/product/webapp/facility/error/error.jsp b/applications/product/webapp/facility/error/error.jsp deleted file mode 100644 index 83f0147..0000000 --- a/applications/product/webapp/facility/error/error.jsp +++ /dev/null @@ -1,53 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> - -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - diff --git a/applications/workeffort/webapp/workeffort/error/error.jsp b/applications/workeffort/webapp/workeffort/error/error.jsp deleted file mode 100644 index 83f0147..0000000 --- a/applications/workeffort/webapp/workeffort/error/error.jsp +++ /dev/null @@ -1,53 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> - -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - diff --git a/framework/common/webcommon/WEB-INF/common-controller.xml b/framework/common/webcommon/WEB-INF/common-controller.xml index d0f6717..57e0b9a 100644 --- a/framework/common/webcommon/WEB-INF/common-controller.xml +++ b/framework/common/webcommon/WEB-INF/common-controller.xml @@ -23,7 +23,7 @@ under the License. Common ControlServlet Configuration File - /error/error.jsp + component://common/webcommon/error/Error.ftl diff --git a/framework/common/webcommon/error/Error.ftl b/framework/common/webcommon/error/Error.ftl new file mode 100644 index 0000000..6090bc7 --- /dev/null +++ b/framework/common/webcommon/error/Error.ftl @@ -0,0 +1,42 @@ +<#-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<#if !visualTheme?has_content> + <#-- Try to resolve the default theme--> + <#assign visualTheme = Static["org.apache.ofbiz.widget.model.ThemeFactory"].resolveVisualTheme(null)/> + +<#if visualTheme?has_content> + <#assign errorPageLocation = visualTheme.modelTheme.getErrorTemplateLocation('screen')/> + +<#if errorPageLocation?has_content> + <#include visualTheme.modelTheme.getErrorTemplateLocation('screen')/> +<#else> +<#-- Not error page found to we use a raw output --> + + + OFBiz Message + + +
+

ERROR MESSAGE

+
+

${request.getAttribute('_ERROR_MESSAGE_')?replace("\n", "
")}

+
+ + + \ No newline at end of file diff --git a/framework/resources/templates/error.jsp b/framework/resources/templates/error.jsp deleted file mode 100644 index adcf72b..0000000 --- a/framework/resources/templates/error.jsp +++ /dev/null @@ -1,53 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> - -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - \ No newline at end of file diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlServlet.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlServlet.java index d552473..7ffa93b 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlServlet.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlServlet.java @@ -18,9 +18,12 @@ *******************************************************************************/ package org.apache.ofbiz.webapp.control; +import freemarker.template.Template; import java.io.IOException; import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; import javax.servlet.RequestDispatcher; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; @@ -31,6 +34,7 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.ofbiz.base.util.Debug; +import org.apache.ofbiz.base.util.StringUtil; import org.apache.ofbiz.base.util.UtilCodec; import org.apache.ofbiz.base.util.UtilGenerics; import org.apache.ofbiz.base.util.UtilHttp; @@ -239,41 +243,67 @@ public class ControlServlet extends HttpServlet { if (errorPage != null) { Debug.logError("An error occurred, going to the errorPage: " + errorPage, module); - RequestDispatcher rd = request.getRequestDispatcher(errorPage); + Map context = new HashMap<>(); + context.put("request", request); + context.put("response", response); + context.put("session", session); + context.put("dispatcher", dispatcher); + context.put("delegator", delegator); + context.put("security", security); + context.put("locale", UtilHttp.getLocale(request)); + context.put("timeZone", UtilHttp.getTimeZone(request)); + context.put("userLogin", session.getAttribute("userLogin")); + context.put("visualTheme", UtilHttp.getVisualTheme(request)); + + boolean errorPageFailed = false; + if (errorPage.endsWith(".jsp")) { + RequestDispatcher rd = request.getRequestDispatcher(errorPage); + + // use this request parameter to avoid infinite looping on errors in the error page... + if (request.getAttribute("_ERROR_OCCURRED_") == null && rd != null) { + request.setAttribute("_ERROR_OCCURRED_", Boolean.TRUE); + Debug.logError("Including errorPage: " + errorPage, module); - // use this request parameter to avoid infinite looping on errors in the error page... - if (request.getAttribute("_ERROR_OCCURRED_") == null && rd != null) { - request.setAttribute("_ERROR_OCCURRED_", Boolean.TRUE); - Debug.logError("Including errorPage: " + errorPage, module); - - // NOTE DEJ20070727 after having trouble with all of these, try to get the page out and as a last resort just send something back + try { + rd.include(request, response); + } catch (Throwable t) { + errorPageFailed = true; + } + } else { + if (rd == null) { + Debug.logError("Could not get RequestDispatcher for errorPage: " + errorPage, module); + } + errorPageFailed = true; + } + } else { + try { + Template template = FreeMarkerWorker.getTemplate(errorPage); + FreeMarkerWorker.renderTemplate(template, context, response.getWriter()); + } catch (Exception e) { + errorPageFailed = true; + } + } + if (errorPageFailed) { + StringBuilder errorMessage = new StringBuilder("") + .append("

ERROR MESSAGE

") + .append("
").append("

") + .append("ERROR in error page, (infinite loop or error page not found with name ") + .append("[").append(errorPage).append("]").append("

") + .append("Original error detected, maybe it would be helps you : ") + .append(StringUtil.replaceString((String) request.getAttribute("_ERROR_MESSAGE_"), "\n", "
")) + .append("

"); try { - rd.include(request, response); + response.getWriter().print(errorMessage.toString()); } catch (Throwable t) { - Debug.logWarning("Error while trying to send error page using rd.include (will try response.getOutputStream or response.getWriter): " + t.toString(), module); - - String errorMessage = "ERROR rendering error page [" + errorPage + "], but here is the error text: " + request.getAttribute("_ERROR_MESSAGE_"); try { - response.getWriter().print(errorMessage); + int errorToSend = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; + Debug.logWarning("Error while trying to write error message using response.getOutputStream or response.getWriter, sending error code [" + errorToSend + "], and message [" + errorMessage + "]", module); + response.sendError(errorToSend, errorMessage.toString()); } catch (Throwable t2) { - try { - int errorToSend = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; - Debug.logWarning("Error while trying to write error message using response.getOutputStream or response.getWriter: " + t.toString() + "; sending error code [" + errorToSend + "], and message [" + errorMessage + "]", module); - response.sendError(errorToSend, errorMessage); - } catch (Throwable t3) { - // wow, still bad... just throw an IllegalStateException with the message and let the servlet container handle it - throw new IllegalStateException(errorMessage); - } + // wow, still bad... just throw an IllegalStateException with the message and let the servlet container handle it + throw new IllegalStateException(errorMessage.toString()); } } - - } else { - if (rd == null) { - Debug.logError("Could not get RequestDispatcher for errorPage: " + errorPage, module); - } - - String errorMessage = "ERROR in error page, (infinite loop or error page not found with name [" + errorPage + "]), but here is the text just in case it helps you: " + request.getAttribute("_ERROR_MESSAGE_") + ""; - response.getWriter().print(errorMessage); } } diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java index 3243a46..864f352 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java @@ -18,6 +18,8 @@ *******************************************************************************/ package org.apache.ofbiz.webapp.control; +import java.net.MalformedURLException; +import org.apache.ofbiz.base.location.FlexibleLocation; import static org.apache.ofbiz.base.util.UtilGenerics.checkMap; import java.io.IOException; @@ -734,14 +736,17 @@ public class RequestHandler { /** Returns the default error page for this request. */ public String getDefaultErrorPage(HttpServletRequest request) { - String errorpage = null; + URL errorPage = null; try { - errorpage = getControllerConfig().getErrorpage(); - } catch (WebAppConfigurationException e) { + String errorPageLocation = getControllerConfig().getErrorpage(); + errorPage = FlexibleLocation.resolveLocation(errorPageLocation); + } catch (WebAppConfigurationException | MalformedURLException e) { Debug.logError(e, "Exception thrown while parsing controller.xml file: ", module); } - if (UtilValidate.isNotEmpty(errorpage)) return errorpage; - return "/error/error.jsp"; + if (errorPage == null) { + return "/error/error.jsp"; + } + return errorPage.toString(); } /** Returns the default status-code for this request. */ diff --git a/framework/webtools/webapp/webtools/error/error.jsp b/framework/webtools/webapp/webtools/error/error.jsp deleted file mode 100644 index 5f4de01..0000000 --- a/framework/webtools/webapp/webtools/error/error.jsp +++ /dev/null @@ -1,52 +0,0 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---%> -<%@ page import="org.apache.ofbiz.base.util.*" %> - - -OFBiz Message - - - -<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %> - - -
-
- - - - -
- - - - - - - -
-
:ERROR MESSAGE:
-
-
<%=UtilFormatOut.replaceString(errorMsg, "\n", "
")%>
-
-
-
-
- - diff --git a/framework/widget/dtd/widget-theme.xsd b/framework/widget/dtd/widget-theme.xsd index 14a8c61..de4f204 100644 --- a/framework/widget/dtd/widget-theme.xsd +++ b/framework/widget/dtd/widget-theme.xsd @@ -157,7 +157,7 @@ under the License. - + @@ -183,6 +183,7 @@ under the License. + diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTheme.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTheme.java index 0309b10..4df4836 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTheme.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTheme.java @@ -366,6 +366,13 @@ public class ModelTheme implements Serializable { } return null; } + public String getErrorTemplateLocation(String name) { + ModelTemplate modelTemplate = modelTemplateMap.get(name); + if (modelTemplate != null) { + return modelTemplate.getErrorTemplateLocation(); + } + return null; + } public Map getModelCommonScreens() { return modelCommonScreensMap; @@ -385,6 +392,7 @@ public class ModelTheme implements Serializable { private final String formRendererLocation; private final String menuRendererLocation; private final String treeRendererLocation; + private final String errorTemplateLocation; /** * Constructor to initialize a ModelTemplate class from xml definition @@ -402,6 +410,7 @@ public class ModelTheme implements Serializable { String formRendererLocation = null; String menuRendererLocation = null; String treeRendererLocation = null; + String errorTemplateLocation = null; for (Element templateFile : UtilXml.childElementList(template)) { switch (templateFile.getAttribute("widget")) { case "screen": @@ -416,12 +425,16 @@ public class ModelTheme implements Serializable { case "menu": menuRendererLocation = templateFile.getAttribute("location"); break; + case "error": + errorTemplateLocation = templateFile.getAttribute("location"); + break; } } this.screenRendererLocation = screenRendererLocation; this.formRendererLocation = formRendererLocation; this.menuRendererLocation = menuRendererLocation; this.treeRendererLocation = treeRendererLocation; + this.errorTemplateLocation = errorTemplateLocation; } /** @@ -441,6 +454,7 @@ public class ModelTheme implements Serializable { this.formRendererLocation = exist && currentModelTemplate.formRendererLocation != null ? currentModelTemplate.formRendererLocation : originModelTemplate.formRendererLocation; this.treeRendererLocation = exist && currentModelTemplate.treeRendererLocation != null ? currentModelTemplate.treeRendererLocation : originModelTemplate.treeRendererLocation; this.menuRendererLocation = exist && currentModelTemplate.menuRendererLocation != null ? currentModelTemplate.menuRendererLocation : originModelTemplate.menuRendererLocation; + this.errorTemplateLocation = exist && currentModelTemplate.errorTemplateLocation != null ? currentModelTemplate.errorTemplateLocation : originModelTemplate.errorTemplateLocation; } public String getName() { return name; @@ -471,5 +485,8 @@ public class ModelTheme implements Serializable { public String getMenuRendererLocation() { return menuRendererLocation; } + public String getErrorTemplateLocation() { + return errorTemplateLocation; + } } } diff --git a/themes/common/widget/Theme.xml b/themes/common/widget/Theme.xml index f108de1..46a5ee1 100644 --- a/themes/common/widget/Theme.xml +++ b/themes/common/widget/Theme.xml @@ -92,6 +92,7 @@ under the License. +