📄 multientrylistboxtag.java
字号:
/*
* SSL-Explorer
*
* Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package com.sslexplorer.input.tags;
import java.util.StringTokenizer;
import javax.servlet.jsp.JspException;
import org.apache.struts.taglib.TagUtils;
import com.sslexplorer.core.CoreUtil;
/**
* Custom tag than renders a component that allows the user to entry some value
* in a field, click on an <i>Add</i> button and have the value moved into a
* second list field. Values may also be removed from the second list. *
* <p>
* Originally written to lists of users to be built up, this component is now
* generic.
* <p>
* Values are passed between the component and the format implementation in
* newline delimited <i>Property List</i> format. See
* {@link com.sslexplorer.boot.PropertyList} for more details on this.
* <p>
* Titles may be provide for each side of the component using message resource
* keys.
* <h3>Supported Attributes</h3>
*
* TODO document the supported attributes
*
* @author Brett Smith <brett@3sp.com>
*/
public class MultiEntryListBoxTag extends AbstractMultiFieldTag {
// Protected instance variables
protected String entrySize;
protected String entryTitleKey;
protected String entryStyleClass;
protected String entryName;
protected String targetUnique;
protected String indicator;
protected boolean includeUserAttributes;
protected boolean includeSession;
protected boolean showReplacementVariables;
protected String replacementVariablesTitleKey;
protected String variables;
protected String replacementVariablesBundle;
/**
* Constructor
*/
public MultiEntryListBoxTag() {
super();
this.type = "hidden";
targetUnique = "true";
indicator = null;
name = null;
showReplacementVariables = false;
replacementVariablesBundle = null;
includeSession = true;
includeUserAttributes = true;
setStyleId("multiEntry");
setRows("5");
}
/*
* (non-Javadoc)
*
* @see org.apache.struts.taglib.html.BaseFieldTag#doStartTag()
*/
public int doStartTag() throws JspException {
String entryTitle = null;
if (entryTitleKey != null) {
entryTitle = TagUtils.getInstance().message(pageContext, getBundle(), getLocale(), entryTitleKey, new String[] {});
if (entryTitle == null) {
JspException e = new JspException(messages.getMessage("message.message", "\"" + entryTitleKey + "\""));
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
}
String targetTitle = prepareTargetTitle();
StringBuffer results = new StringBuffer("<div ");
results.append(prepareStyles());
results.append(">");
results.append(this.renderInputElement());
results.append("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
if (entryTitle != null || targetTitle != null) {
results.append("<tr class=\"header\"><td class=\"entry\">");
if (entryTitle != null) {
results.append(entryTitle);
}
results.append("</td><td class=\"actions\"/><td class=\"target\">");
if (targetTitle != null) {
results.append(targetTitle);
}
results.append("</td></tr>");
}
results.append("<tr class=\"body\"><td class=\"entry\">");
results.append(renderEntryComponent());
results.append("</td><td class=\"actions\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
results.append("<tr><td>");
results.append(renderAddComponent());
results.append("</td></tr><tr><td>");
results.append(renderRemoveSelectedComponent());
if (isAllowReordering()) {
results.append("</td></tr><tr><td>");
results.append(renderUpComponent());
results.append("</td></tr><tr><td>");
results.append(renderDownComponent());
}
results.append("</td></tr></table></td><td class=\"target\">");
results.append(renderTargetComponent());
results.append("</td></tr></table></div>");
TagUtils.getInstance().write(this.pageContext, results.toString());
return (EVAL_BODY_BUFFERED);
}
/**
* Get the size of the field to use for the entry side.
*
* @return the entrySize.
*/
public String getEntrySize() {
return entrySize;
}
/**
* Set the size of the field to use on the entry side.
*
* @param entrySize size of entry field
*/
public void setEntrySize(String entrySize) {
this.entrySize = entrySize;
}
/**
* Get the message resources key to use for the title on the entry side
*
* @return message resources key for entry title
*/
public String getEntryTitleKey() {
return entryTitleKey;
}
/**
* Set the message resources key to use for the title on the entry side
*
* @param entryTitleKey message resources key for entry title
*/
public void setEntryTitleKey(String entryTitleKey) {
this.entryTitleKey = entryTitleKey;
}
/**
* Set the CSS class to use for the entry field
*
* @param entryStyleClass CSS class to use for entry field
*/
public void setEntryStyleClass(String entryStyleClass) {
this.entryStyleClass = entryStyleClass;
}
/**
* Set the name attribute to use for the entry field
*
* @param entryName name attribute use for entry field
*/
public void setEntryName(String entryName) {
this.entryName = entryName;
}
/**
* Set the name of the <i>Indicator</i>. Using this in conjunction with
* AjaxTags allows a throbber to be displayed whilst the XML data is being
* retrieved.
* <p>
* The value of the indicator must match the value provided to the AjaxTags
* autocomplete tag and there must also be an image with the same name (with
* .gif append) in the themes top level image directory.
*
* @param indicator indicator name
*/
public void setIndicator(String indicator) {
this.indicator = indicator;
}
/**
* Set the messsage resources key to use for the title of the replacement
* variables popup.
*
* @param replacementVariablesTitleKey replacement variables title message
* resources key
*/
public void setReplacementVariablesTitleKey(String replacementVariablesTitleKey) {
this.replacementVariablesTitleKey = replacementVariablesTitleKey;
}
/**
* Set the messsage resources bundle to use for the title of the replacement
* variables popup and the descriptions of the replacement variables
* themselves
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -