| 1 13 package com.tonbeller.wcf.log; 14 15 import java.util.MissingResourceException ; 16 import java.util.ResourceBundle ; 17 18 import org.w3c.dom.Element ; 19 20 import com.tonbeller.wcf.component.FormListener; 21 import com.tonbeller.wcf.controller.RequestContext; 22 import com.tonbeller.wcf.form.NodeHandlerSupport; 23 import com.tonbeller.wcf.form.XmlComponent; 24 import com.tonbeller.wcf.ui.ListItem; 25 import com.tonbeller.wcf.ui.Select; 26 27 public class LogItems extends NodeHandlerSupport implements FormListener { 28 29 LogHandler handler; 30 ResourceBundle res; 31 32 35 public void revert(RequestContext context) { 36 Element list = getElement(); 37 Select.removeAllItems(list); 38 39 String confs[] = handler.getConfigNames(); 40 41 for (int i = 0; i < confs.length; i++) { 42 Element item = ListItem.addListItem(list); 43 ListItem.setId(item, String.valueOf(confs[i].hashCode())); 44 ListItem.setValue(item, confs[i]); 45 46 String label = handler.getLabel(confs[i]); 47 if (label == null) { 48 try { 49 label = res.getString(confs[i]); 50 } catch (MissingResourceException e) { 51 label = confs[i]; 52 } 53 } 54 55 ListItem.setLabel(item, label); 56 } 57 } 58 59 62 public boolean validate(RequestContext context) { 63 return true; 64 } 65 66 69 public void initialize(RequestContext context, XmlComponent comp, Element element) 70 throws Exception { 71 super.initialize(context, comp, element); 72 73 res = ResourceBundle.getBundle("com.tonbeller.wcf.log.logging", context.getLocale()); 74 75 comp.addFormListener(this); 76 77 LogForm form = (LogForm) comp; 78 handler = form.getLogHandler(); 79 80 revert(context); 81 } 82 83 } 84 | Popular Tags |