01: /*
02: * Created on Nov 15, 2005
03: */
04: package uk.org.ponder.rsf.renderer;
05:
06: import uk.org.ponder.messageutil.MessageLocator;
07: import uk.org.ponder.messageutil.TargettedMessageList;
08: import uk.org.ponder.rsf.components.UIBranchContainer;
09: import uk.org.ponder.rsf.components.UIMessage;
10: import uk.org.ponder.rsf.components.UIOutput;
11: import uk.org.ponder.stringutil.StringList;
12:
13: public class MessageRenderer {
14: private MessageLocator messagelocator;
15:
16: public void setMessageLocator(MessageLocator messagelocator) {
17: this .messagelocator = messagelocator;
18: }
19:
20: public UIMessage renderMessage(String key) {
21: UIMessage togo = UIMessage.make(key);
22: togo.setValue(messagelocator.getMessage(togo.messagekeys,
23: togo.arguments));
24: return togo;
25: }
26:
27: public UIBranchContainer renderMessageList(
28: TargettedMessageList messagelist) {
29: UIBranchContainer togo = new UIBranchContainer();
30: StringList renderered = messagelist == null ? new StringList()
31: : messagelist.render(messagelocator);
32: for (int i = 0; i < renderered.size(); ++i) {
33: UIOutput.make(togo, "message:", renderered.stringAt(i));
34: }
35: return togo;
36: }
37: }
|