Author: knguyen
Date: Mon Oct 15 12:37:10 2007
New Revision: 18864
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18864&repname=
=3Djahia
Log:
add method Category.getTitle(Locale locale, String defaultValue) to allow p=
assing a default value in case the title is empty or null.
Modified:
branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/categorie=
s/Category.java
Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cat=
egories/Category.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/categories/Category.java&rev=3D188=
64&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/categorie=
s/Category.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/categorie=
s/Category.java Mon Oct 15 12:37:10 2007
@@ -582,6 +582,39 @@
}
=
/**
+ * Returns the title in the specified language if it exists, or null if
+ * it doesn't exist
+ *
+ * @param locale the locale which specifies the language for which to
+ * retrieve the title.
+ *
+ * @return a String containing the category title in the specified lan=
guage,
+ * or the default value if null or empty.
+ */
+ /**
+ *
+ * @param locale
+ * @param defaultValue
+ * @return
+ */
+ public String getTitle (Locale locale, String defaultValue) {
+ String result =3D null;
+ try {
+ result =3D categoryService.
+ getTitleForCategory (this, locale);
+ } catch (JahiaException je) {
+ logger.error (
+ "Error while trying to retrieve title for category " +=
this.getObjectKey ()
+ .toString (),
+ je);
+ }
+ if ( result =3D=3D null || "".equals(result.trim()) ){
+ return defaultValue;
+ }
+ return result;
+ }
+
+ /**
* Sets a title for this category in a given locale
*
* @param locale the locale in which we want to set the title
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list