You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by de...@apache.org on 2016/09/03 12:14:37 UTC
svn commit: r1759081 - in /ofbiz/trunk/specialpurpose/example:
config/ExampleUiLabels.xml
src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java
Author: deepak
Date: Sat Sep 3 12:14:36 2016
New Revision: 1759081
URL: http://svn.apache.org/viewvc?rev=1759081&view=rev
Log:
(OFBIZ-7991) Applied patch from jira issue
=====================================
Add UI labels for success / error messages in example component
=====================================
Thanks Tanmay for your contribution.
Modified:
ofbiz/trunk/specialpurpose/example/config/ExampleUiLabels.xml
ofbiz/trunk/specialpurpose/example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java
Modified: ofbiz/trunk/specialpurpose/example/config/ExampleUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/example/config/ExampleUiLabels.xml?rev=1759081&r1=1759080&r2=1759081&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/example/config/ExampleUiLabels.xml (original)
+++ ofbiz/trunk/specialpurpose/example/config/ExampleUiLabels.xml Sat Sep 3 12:14:36 2016
@@ -623,6 +623,9 @@
<value xml:lang="zh">表单挂件样例</value>
<value xml:lang="zh-TW">表單器件範例</value>
</property>
+ <property key="ExampleGeneralErrorRenderingScreen">
+ <value xml:lang="en">General error rendering screen [${screenLocation}]: ${errorString}</value>
+ </property>
<property key="ExampleGroupField">
<value xml:lang="en">Group</value>
<value xml:lang="it">Gruppo</value>
@@ -637,6 +640,9 @@
<value xml:lang="zh">数据项组</value>
<value xml:lang="zh-TW">資料項目群組</value>
</property>
+ <property key="ExampleIOErrorRenderingScreen">
+ <value xml:lang="en">I/O error rendering screen [${screenLocation}]: ${errorString}</value>
+ </property>
<property key="ExampleLanguageTextVersion">
<value xml:lang="de">Verion der gewählten sprache</value>
<value xml:lang="en">Version of the choosen language</value>
@@ -770,6 +776,9 @@
<value xml:lang="zh">原样例</value>
<value xml:lang="zh-TW">原範例</value>
</property>
+ <property key="ExampleParserConfigurationErrorRenderingScreen">
+ <value xml:lang="en">Parser configuration error rendering screen [${screenLocation}]: ${errorString}</value>
+ </property>
<property key="ExamplePermissionError">
<value xml:lang="en">Security Error: to run ${resourceDescription} you must have the EXAMPLE_${mainAction} or EXAMPLE_ADMIN permission</value>
<value xml:lang="fr">Erreur de sécurité : pour exécuter ${resourceDescription} vous devez avoir l'autorisation EXAMPLE_${mainAction} ou EXAMPLE_ADMIN</value>
@@ -884,6 +893,9 @@
<value xml:lang="zh">节点</value>
<value xml:lang="zh-TW">節點</value>
</property>
+ <property key="ExampleSAXErrorRenderingScreen">
+ <value xml:lang="en">SAX (XML parse) error rendering screen [${screenLocation}]: ${errorString}</value>
+ </property>
<property key="ExampleScanRepositoryStrukture">
<value xml:lang="de">Repository Struktur überprüfen</value>
<value xml:lang="en">Scan repository structure</value>
@@ -920,6 +932,9 @@
<value xml:lang="zh">待实现</value>
<value xml:lang="zh-TW">待實現</value>
</property>
+ <property key="ExampleUnableToPrintPDFFromXSL-FO">
+ <value xml:lang="en">Unable to print PDF from XSL-FO: ${errorString}</value>
+ </property>
<property key="ExampleViewPermissionError">
<value xml:lang="en">You do not have permission to view this page. ("EXAMPLE_VIEW" or "EXAMPLE_ADMIN" needed)</value>
<value xml:lang="fr">Vous n'avez pas l'autorisation de voir cette page ("EXAMPLE_VIEW" ou "EXAMPLE_ADMIN" nécessaire)</value>
Modified: ofbiz/trunk/specialpurpose/example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java?rev=1759081&r1=1759080&r2=1759081&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java (original)
+++ ofbiz/trunk/specialpurpose/example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java Sat Sep 3 12:14:36 2016
@@ -24,6 +24,7 @@ import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
import javax.print.Doc;
@@ -45,6 +46,8 @@ import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;
import org.apache.ofbiz.base.util.Debug;
import org.apache.ofbiz.base.util.GeneralException;
+import org.apache.ofbiz.base.util.UtilMisc;
+import org.apache.ofbiz.base.util.UtilProperties;
import org.apache.ofbiz.entity.util.EntityUtilProperties;
import org.apache.ofbiz.service.DispatchContext;
import org.apache.ofbiz.service.ServiceUtil;
@@ -58,8 +61,10 @@ import freemarker.template.TemplateExcep
public class ExamplePrintServices {
public static final String module = ExamplePrintServices.class.getName();
+ public static final String resource = "ExampleUiLabels";
public static Map<String, Object> printReportPdf(DispatchContext dctx, Map<String, ? extends Object> context) {
+ Locale locale = (Locale)context.get("locale");
String screenLocation = "component://example/widget/example/ExampleReportScreens.xml";
String reportScreenName = "ExampleReport";
Map<String, Object> workContext = new HashMap<String, Object>();
@@ -72,11 +77,11 @@ public class ExamplePrintServices {
screenStringRenderer = new MacroScreenRenderer(EntityUtilProperties.getPropertyValue("widget", "screen.name", dctx.getDelegator()),
EntityUtilProperties.getPropertyValue("widget", "screen.screenrenderer", dctx.getDelegator()));
} catch (TemplateException e) {
- String errMsg = "General error rendering screen [" + screenLocation + "]: " + e.toString();
+ String errMsg = UtilProperties.getMessage(resource, "ExampleGeneralErrorRenderingScreen", UtilMisc.toMap("errorString", e.toString()), locale);
Debug.logError(e, errMsg, module);
return ServiceUtil.returnError(errMsg);
} catch (IOException e) {
- String errMsg = "IO error rendering screen [" + screenLocation + "]: " + e.toString();
+ String errMsg = UtilProperties.getMessage(resource, "ExampleIOErrorRenderingScreen", UtilMisc.toMap("errorString", e.toString()), locale);
Debug.logError(e, errMsg, module);
return ServiceUtil.returnError(errMsg);
}
@@ -90,19 +95,19 @@ public class ExamplePrintServices {
try {
reportScreenRenderer.render(screenLocation, reportScreenName);
} catch (GeneralException e) {
- String errMsg = "General error rendering screen [" + screenLocation + "]: " + e.toString();
+ String errMsg = UtilProperties.getMessage(resource, "ExampleGeneralErrorRenderingScreen", UtilMisc.toMap("errorString", e.toString()), locale);
Debug.logError(e, errMsg, module);
return ServiceUtil.returnError(errMsg);
} catch (IOException e) {
- String errMsg = "IO error rendering screen [" + screenLocation + "]: " + e.toString();
+ String errMsg = UtilProperties.getMessage(resource, "ExampleIOErrorRenderingScreen", UtilMisc.toMap("errorString", e.toString()), locale);
Debug.logError(e, errMsg, module);
return ServiceUtil.returnError(errMsg);
} catch (SAXException e) {
- String errMsg = "SAX (XML parse) error rendering screen [" + screenLocation + "]: " + e.toString();
+ String errMsg = UtilProperties.getMessage(resource, "ExampleSAXErrorRenderingScreen", UtilMisc.toMap("errorString", e.toString()), locale);
Debug.logError(e, errMsg, module);
return ServiceUtil.returnError(errMsg);
} catch (ParserConfigurationException e) {
- String errMsg = "Parser configuration error rendering screen [" + screenLocation + "]: " + e.toString();
+ String errMsg = UtilProperties.getMessage(resource, "ExampleParserConfigurationErrorRenderingScreen", UtilMisc.toMap("errorString", e.toString()), locale);
Debug.logError(e, errMsg, module);
return ServiceUtil.returnError(errMsg);
}
@@ -149,7 +154,7 @@ public class ExamplePrintServices {
try {
job.print(myDoc, aset);
} catch (PrintException pe) {
- String errMsg = "Unable to print PDF from XSL-FO: " + pe.toString();
+ String errMsg = UtilProperties.getMessage(resource, "ExampleUnableToPrintPDFFromXSL-FO", UtilMisc.toMap("errorString", pe.toString()), locale);
Debug.logError(pe, errMsg, module);
return ServiceUtil.returnError(errMsg);
}