01: /* MessageFactory.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Aug 9, 2007 2:16:26 PM 2007, Created by Dennis.Chen
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.jsf.zul.impl;
20:
21: import javax.faces.application.FacesMessage;
22: import javax.faces.context.FacesContext;
23:
24: /**
25: * For handling default JSF Messages.
26: *
27: * @author Dennis.Chen
28: *
29: */
30: public class MessageFactory {
31:
32: public static final String CONVERSION_MESSAGE_ID = "zul.jsf.conversion.message";
33: public static final String REQUIRED_MESSAGE_ID = "zul.jsf.required.message";
34:
35: /**
36: * Get default message by message id
37: * @param context a FacesContext instance
38: * @param messageid the message id.
39: * @return a FacesMessage instance
40: */
41: public static FacesMessage getMessage(FacesContext context,
42: String messageid) {
43: String message;
44: if (CONVERSION_MESSAGE_ID.equals(messageid)) {
45: message = "Formate Error, Cann't convert.";
46: } else if (REQUIRED_MESSAGE_ID.equals(messageid)) {
47: message = "Value Required";
48: } else {
49: message = messageid;
50: }
51: return new FacesMessage(message);
52: }
53:
54: }
|