📄 baseformeventimpl.java
字号:
/* * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a> * * @version $Id: BaseFormEventImpl.java 4709 2006-03-31 20:41:54Z novotny $ */package org.gridsphere.provider.event.jsr.impl;import org.apache.commons.fileupload.FileItem;import org.apache.commons.fileupload.FileItemFactory;import org.apache.commons.fileupload.FileUpload;import org.apache.commons.fileupload.disk.DiskFileItemFactory;import org.apache.commons.fileupload.servlet.ServletFileUpload;import org.apache.commons.fileupload.servlet.ServletRequestContext;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.gridsphere.portlet.impl.SportletProperties;import org.gridsphere.provider.portletui.beans.*;import org.gridsphere.services.core.persistence.QueryFilter;import javax.portlet.PortletRequest;import javax.portlet.PortletResponse;import javax.servlet.http.HttpServletRequest;import java.io.IOException;import java.util.*;/** * The <code>FormEventImpl</code> provides methods for creating/retrieving visual beans * from the <code>PortletRequest</code> */public abstract class BaseFormEventImpl { protected transient static Log log = LogFactory.getLog(BaseFormEventImpl.class); protected PortletRequest portletRequest; protected PortletResponse portletResponse; protected Locale locale = null; protected Map<String, TagBean> tagBeans = null; protected List<FileItem> fileItems = null; protected String cid = null; protected String compId = null; protected BaseFormEventImpl() { } public BaseFormEventImpl(PortletRequest request, PortletResponse response) { this.portletRequest = request; this.portletResponse = response; locale = (Locale) portletRequest.getPortletSession(true).getAttribute(SportletProperties.LOCALE); if (locale == null) locale = portletRequest.getLocale(); if (locale == null) locale = Locale.ENGLISH; cid = (String) portletRequest.getAttribute(SportletProperties.COMPONENT_ID); compId = (String) portletRequest.getAttribute(SportletProperties.GP_COMPONENT_ID); } public PortletRequest getRequest() { return portletRequest; } protected void configureBean(TagBean tagBean) { tagBean.setLocale(locale); if (cid != null) tagBean.addParam(SportletProperties.COMPONENT_ID, cid); if (compId != null) tagBean.addParam(SportletProperties.GP_COMPONENT_ID, compId); } /** * Return an existing <code>ActionLinkBean</code> or create a new one * * @param beanId the bean identifier * @return a ActionLinkBean */ public ActionLinkBean getActionLinkBean(String beanId) { String beanKey = getBeanKey(beanId); if (tagBeans.containsKey(beanKey)) { return (ActionLinkBean) tagBeans.get(beanKey); } ActionLinkBean al = new ActionLinkBean(beanId); configureBean(al); tagBeans.put(beanKey, al); return al; } /** * Return an existing <code>ParamBean</code> or create a new one * * @param beanId the bean identifier * @return a ParamBean */ public ParamBean getParamBean(String beanId) { String beanKey = getBeanKey(beanId); if (tagBeans.containsKey(beanKey)) { return (ParamBean) tagBeans.get(beanKey); } ParamBean ap = new ParamBean(beanId); configureBean(ap); tagBeans.put(beanKey, ap); return ap; } /** * Return an existing <code>ActionSubmitBean</code> or create a new one * * @param beanId the bean identifier * @return a ActionSubmitBean */ public ActionSubmitBean getActionSubmitBean(String beanId) { String beanKey = getBeanKey(beanId); if (tagBeans.containsKey(beanKey)) { return (ActionSubmitBean) tagBeans.get(beanKey); } ActionSubmitBean as = new ActionSubmitBean(beanId); configureBean(as); tagBeans.put(beanKey, as); return as; } /** * Return an existing <code>CheckBoxBean</code> or create a new one * * @param beanId the bean identifier * @return a CheckBoxBean */ public CheckBoxBean getCheckBoxBean(String beanId) { String beanKey = getBeanKey(beanId); if (tagBeans.containsKey(beanKey)) { return (CheckBoxBean) tagBeans.get(beanKey); } CheckBoxBean cb = new CheckBoxBean(beanId); configureBean(cb); tagBeans.put(beanKey, cb); return cb; } /** * Return an existing <code>CalendarBean</code> or create a new one * * @param beanId the bean identifier * @return a CalendarBean */ public CalendarBean getCalendarBean(String beanId) { String beanKey = getBeanKey(beanId); if (tagBeans.containsKey(beanKey)) { return (CalendarBean) tagBeans.get(beanKey); } CalendarBean ca = new CalendarBean(beanId); configureBean(ca); tagBeans.put(beanKey, ca); return ca; } /** * Return an existing <code>RadioButtonBean</code> or create a new one * * @param beanId the bean identifier * @return a RadioButtonBean */ public RadioButtonBean getRadioButtonBean(String beanId) { String beanKey = getBeanKey(beanId); if (tagBeans.containsKey(beanKey)) { return (RadioButtonBean) tagBeans.get(beanKey); } RadioButtonBean rb = new RadioButtonBean(beanId); configureBean(rb); tagBeans.put(beanKey, rb); return rb; } /** * Return an existing <code>PanelBean</code> or create a new one * * @param beanId the bean identifier * @return a PanelBean */ public PanelBean getPanelBean(String beanId) { String beanKey = getBeanKey(beanId); if (tagBeans.containsKey(beanKey)) { return (PanelBean) tagBeans.get(beanKey); } PanelBean pb = new PanelBean(beanId); configureBean(pb); tagBeans.put(beanKey, pb); return pb; } /** * Return an existing <code>TextFieldBean</code> or create a new one * * @param beanId the bean identifier * @return a TextFieldBean */ public TextFieldBean getTextFieldBean(String beanId) { String beanKey = getBeanKey(beanId); //log.debug("Checking for textfieldbean with bean key=" + beanKey); if (tagBeans.containsKey(beanKey)) { return (TextFieldBean) tagBeans.get(beanKey); } TextFieldBean tf = new TextFieldBean(beanId); configureBean(tf); tagBeans.put(beanKey, tf); return tf; } /** * Return an existing <code>TextEditorBean</code> or create a new one * * @param beanId the bean identifier * @return a TextEditorBean */ public TextEditorBean getTextEditorBean(String beanId) { String beanKey = getBeanKey(beanId); //log.debug("Checking for texteditorbean with bean key=" + beanKey); if (tagBeans.containsKey(beanKey)) { return (TextEditorBean) tagBeans.get(beanKey); } TextEditorBean te = new TextEditorBean(beanId); configureBean(te); tagBeans.put(beanKey, te); return te; } /** * Return an existing <code>RichTextEditorBean</code> or create a new one * * @param beanId the bean identifier * @return a RichTextEditorBean */ public RichTextEditorBean getRichTextEditorBean(String beanId) { String beanKey = getBeanKey(beanId); if (tagBeans.containsKey(beanKey)) { return (RichTextEditorBean) tagBeans.get(beanKey); } RichTextEditorBean rt = new RichTextEditorBean(beanId); configureBean(rt); tagBeans.put(beanKey, rt); return rt; } /** * Return an existing <code>TreeBean</code> or create a new one. * * @param beanId bendId of the bean Idetifier * @return a TreeBean */ public TreeBean getTreeBean(String beanId) { String beanKey = getBeanKey(beanId); if (tagBeans.containsKey(beanKey)) { return (TreeBean) tagBeans.get(beanKey); } TreeBean tr = new TreeBean(beanId); configureBean(tr); tagBeans.put(beanKey, tr); return tr; } /** * Return an existing <code>HiddenFieldBean</code> or create a new one * * @param beanId the bean identifier * @return a HiddenFieldBean */ public HiddenFieldBean getHiddenFieldBean(String beanId) { String beanKey = getBeanKey(beanId); if (tagBeans.containsKey(beanKey)) { return (HiddenFieldBean) tagBeans.get(beanKey); } HiddenFieldBean hf = new HiddenFieldBean(beanId); configureBean(hf); tagBeans.put(beanKey, hf); return hf; } /** * Return an existing <code>FileInputBean</code> or create a new one * * @param beanId the bean identifier * @return a FileInputBean * @throws IOException if an error occurs */ public FileInputBean getFileInputBean(String beanId) throws IOException { String beanKey = getBeanKey(beanId); if (tagBeans.containsKey(beanKey)) { return (FileInputBean) tagBeans.get(beanKey); } FileInputBean fi = new FileInputBean(beanId); configureBean(fi); tagBeans.put(beanKey, fi); return fi; } /** * Return an existing <code>PasswordBean</code> or create a new one * * @param beanId the bean identifier * @return a PasswordBean */ public PasswordBean getPasswordBean(String beanId) { String beanKey = getBeanKey(beanId); if (tagBeans.containsKey(beanKey)) { return (PasswordBean) tagBeans.get(beanKey); } PasswordBean pb = new PasswordBean(beanId); configureBean(pb); tagBeans.put(beanKey, pb); return pb; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -