You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by Ko...@cec.eu.int on 2003/05/19 14:53:52 UTC

RE: Jetspeed TLD

Can anyone commit this to cvs?

It solves the bug i've been talking about and doesn't need the dreaded ecs

Koen

/*
 * Created on 19-mei-2003
 *
 */
package org.apache.jetspeed.services.jsp.tags;

// Java classes
import java.util.MissingResourceException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;

import
org.apache.jetspeed.services.customlocalization.CustomLocalizationService;
import org.apache.jetspeed.services.rundata.JetspeedRunData;
import org.apache.jetspeed.util.ServiceUtil;
import org.apache.turbine.services.jsp.JspService;
import org.apache.turbine.services.localization.LocalizationService;
import org.apache.turbine.util.Log;

/**
 * @author serryko
 *
 */
public class JetspeedL10NTag extends TagSupport
{
	private String key = null;
	private String alt = null;

	public void setKey(String value)
	{
		this.key = value;
	}

	public String getKey()
	{
		return this.key;
	}

	public void setAlt(String value)
	{
		this.alt = value;
	}

	public String getAlt()
	{
		return this.alt;
	}

	/**
	 * Method called when the tag is encountered to send attributes to
the
	 * output stream
	 *
	 * @return SKIP_BODY, as it is intended to be a single tag.
	 */
	public int doStartTag() throws JspException
	{
		JetspeedRunData data = (JetspeedRunData)
pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);

		try
		{
			String result =  this.alt != null &&
this.alt.trim().length() > 0 ? this.alt : this.key;
			try 
			{
				CustomLocalizationService locService =
(CustomLocalizationService) ServiceUtil.getServiceByName(
					LocalizationService.SERVICE_NAME);
				result = locService.getString(null,
locService.getLocale(data), key);            
			}
			catch (MissingResourceException mre)
			{
				Log.error(mre);
			}
			catch (Exception oe)
			{
				Log.error(oe);
			}

			// Output the result
			if (result != null)
			{
				pageContext.getOut().print(result);
			}
		}
		catch (Exception e)
		{
			String message = "Error processing key '" + this.key
+ "'.";
			Log.error(message, e);
			try
			{
				data.getOut().print("Error translating key
'" + this.key + "'. See log for more information.");
			}
			catch (java.io.IOException ioe)
			{
			}
		}
		return EVAL_BODY_INCLUDE;
	}
}

-----Original Message-----
From: Koen.SERRY@cec.eu.int [mailto:Koen.SERRY@cec.eu.int]
Sent: maandag 19 mei 2003 14:32
To: jetspeed-dev@jakarta.apache.org
Subject: Jetspeed TLD


Hi all,

there seems to be a small bug inside the l10n (localisation taglib) as the
"key" and "alt" attributes aren't quite as one could expect. Apparently the
"key" references the bundle to be used (in velocity this is handled
correctly) the alt attribute is the key to be used in the bundle. Is it
possible that the turbine service is called in a wrong way. I looked as the
custom tag, but as I'm not that familiar with maven, I wasn't able to
recompile without changing the build file.

Koen

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org