You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shale.apache.org by stephan opitz <st...@gmail.com> on 2006/07/24 16:24:42 UTC

language defined error messages..

i wrote a class which should handle all exceptions and error message
in form of FacesMessage:

package de.fhb.ShaleTest.view;

import javax.faces.application.FacesMessage;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shale.util.Messages;

import de.fhb.ShaleTest.general.BaseViewController;
import de.fhb.ShaleTest.general.Properties;

public class MessageLang extends BaseViewController {

	private final Log log = LogFactory.getLog(this.getClass());
	
	Messages messagesRessouce = null;

	public MessageLang() {
		
		String locale = getFacesContext().getViewRoot().getLocale().toString();

		String actMessagesRessoucePath = Properties.MessagesRessoucePath;

		if (locale.equals("de") == false) {
			actMessagesRessoucePath += "_" + locale;
		}

		messagesRessouce = new Messages(actMessagesRessoucePath, this
				.getClass().getClassLoader());

	}
	
	public String getMessage (String whichMessage) {

		String message = messagesRessouce.getMessage(whichMessage);
		
		return message;
		
	}
	
	public void setFacesMessage(String whichMessage) {

		String message = messagesRessouce.getMessage(whichMessage);

		getFacesContext().addMessage(null, new FacesMessage(message));

	}
}

it works with the login like in mailreader...

problem if a have a myfaces component, which get its info from a
function - i get nullpointer...

how is this handles: if a swap from one page to another on which is
something like the myfaces datatable...

the table is defined like this

	<component jsfid="collage:dataTable" extends="t:dataTable">
		<attributes>
			...
			<set name="value" value="#{pagedSort.cars}" />
....

get its values from managed bean pagedSort and list cars...

but how i can maybe create language defined error messages... other
standard solutions available?

i have the list working and can swap but without error messages -
everything shit