01: /*
02: * (C) Copyright 2000 - 2006 Nabh Information Systems, Inc.
03: *
04: * This program is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU General Public License
06: * as published by the Free Software Foundation; either version 2
07: * of the License, or (at your option) any later version.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: */
19: package com.nabhinc.portlet.admin;
20:
21: import java.util.List;
22:
23: import javax.portlet.PortletException;
24: import javax.portlet.PortletRequest;
25:
26: import org.w3c.dom.Element;
27:
28: import com.nabhinc.portal.model.PortalConfiguration;
29: import com.nabhinc.portlet.mvcportlet.core.ControllerPortletConfig;
30: import com.nabhinc.portlet.mvcportlet.core.FormFieldPopulator;
31: import com.nabhinc.portlet.mvcportlet.core.ValueAndLabel;
32:
33: /**
34: *
35: *
36: * @author Padmanabh Dabke
37: * (c) 2006 Nabh Information Systems, Inc. All Rights Reserved.
38: */
39: public class PortalLocalesPopulator implements FormFieldPopulator {
40: private String plpName = null;
41:
42: public String[] getDefaultValues(PortletRequest req)
43: throws PortletException {
44: return null;
45: }
46:
47: public String getName() {
48: return plpName;
49: }
50:
51: public Object getValue(PortletRequest req) throws PortletException {
52: PortalConfiguration pc = PortalConfiguration.getInstance();
53: List<PortalConfiguration.LocaleConfig> localeList = pc
54: .getSupportedLocaleConfigs();
55: ValueAndLabel[] options = new ValueAndLabel[localeList.size()];
56: for (int i = 0; i < options.length; i++) {
57: PortalConfiguration.LocaleConfig lc = localeList.get(i);
58: options[i] = new ValueAndLabel(lc.toString(), lc.label);
59: }
60: return options;
61: }
62:
63: public void setName(String name) {
64: plpName = name;
65:
66: }
67:
68: public void init(Element xmlConfig, ControllerPortletConfig config)
69: throws PortletException {
70: // No initialization needed.
71:
72: }
73:
74: }
|