1 16 17 package org.apache.struts.faces.taglib; 18 19 20 import java.util.Locale ; 21 22 import javax.faces.context.FacesContext; 23 24 import javax.servlet.jsp.PageContext ; 25 import javax.servlet.jsp.tagext.TagSupport ; 26 27 import org.apache.struts.Globals; 28 import org.apache.struts.faces.util.MessagesMap; 29 import org.apache.struts.util.MessageResources; 30 31 32 37 38 public class LoadMessagesTag extends TagSupport { 39 40 41 43 44 49 private String messages = null; 50 public void setMessages(String messages) { 51 this.messages = messages; 52 } 53 54 55 59 private String var = null; 60 public void setVar(String var) { 61 this.var = var; 62 } 63 64 65 67 68 73 public int doStartTag() { 74 75 Locale locale = 77 FacesContext.getCurrentInstance().getViewRoot().getLocale(); 78 79 MessageResources messages = null; 81 if (this.messages == null) { 82 messages = (MessageResources) 83 pageContext.getAttribute(Globals.MESSAGES_KEY, 84 PageContext.REQUEST_SCOPE); 85 if (messages == null) { 86 messages = (MessageResources) 87 pageContext.getAttribute(Globals.MESSAGES_KEY, 88 PageContext.APPLICATION_SCOPE); 89 } 90 } else { 91 messages = (MessageResources) 92 pageContext.getAttribute(this.messages, 93 PageContext.APPLICATION_SCOPE); 94 } 95 96 pageContext.setAttribute(var, 98 new MessagesMap(messages, locale), 99 PageContext.REQUEST_SCOPE); 100 101 return (SKIP_BODY); 103 104 } 105 106 107 110 public void release() { 111 112 this.messages = null; 113 this.var = null; 114 115 } 116 117 118 } 119 | Popular Tags |