/** This generates the HTML for the tag.
* @param out The JspWriter object.
* @param bodyContent The BodyContent object.
* @throws IOException if any I/O error occurs.
*/
public void writeTagBodyContent(JspWriter out, BodyContent bodyContent) throws IOException {
// clear the body content for the next time through.
bodyContent.clearBody();
// get the model
TableModel model = null;
try {
model = (TableModel) TagHelper.getModel(pageContext, getField(), TAG_NAME);
} catch (ClassCastException e) {
String str = "Wrong WidgetModel for " + TAG_NAME + " on field " + getField();
log.error(str, e);
throw new JspWriteRuntimeException(str, e);
}
if (model != null) {
// write out the html
String idPrefix = getHtmlIdPrefix();
out.println( getHtml(idPrefix, model));
}
}
java类javax.servlet.jsp.JspWriter的实例源码
TableTag.java 文件源码
项目:jaffa-framework
阅读 33
收藏 0
点赞 0
评论 0
PageContextImpl.java 文件源码
项目:lams
阅读 29
收藏 0
点赞 0
评论 0
public JspWriter pushBody(Writer writer) {
depth++;
if (depth >= outs.length) {
BodyContentImpl[] newOuts = new BodyContentImpl[depth + 1];
for (int i = 0; i < outs.length; i++) {
newOuts[i] = outs[i];
}
newOuts[depth] = new BodyContentImpl(out);
outs = newOuts;
}
outs[depth].setWriter(writer);
out = outs[depth];
// Update the value of the "out" attribute in the page scope
// attribute namespace of this PageContext
setAttribute(OUT, out);
return outs[depth];
}
TagUtils.java 文件源码
项目:lams
阅读 49
收藏 0
点赞 0
评论 0
/**
* Write the specified text as the response to the writer associated with
* the body content for the tag within which we are currently nested.
*
* @param pageContext The PageContext object for this page
* @param text The text to be written
*
* @exception JspException if an input/output error occurs (already saved)
*/
public void writePrevious(PageContext pageContext, String text)
throws JspException {
JspWriter writer = pageContext.getOut();
if (writer instanceof BodyContent) {
writer = ((BodyContent) writer).getEnclosingWriter();
}
try {
writer.print(text);
} catch (IOException e) {
TagUtils.getInstance().saveException(pageContext, e);
throw new JspException
(messages.getMessage("write.io", e.toString()));
}
}
BaseTag.java 文件源码
项目:lams
阅读 33
收藏 0
点赞 0
评论 0
/**
* Process the start of this tag.
*
* @exception JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
String serverName = (this.server == null) ? request.getServerName() : this.server;
String baseTag =
renderBaseElement(
request.getScheme(),
serverName,
request.getServerPort(),
request.getRequestURI());
JspWriter out = pageContext.getOut();
try {
out.write(baseTag);
} catch (IOException e) {
pageContext.setAttribute(Globals.EXCEPTION_KEY, e, PageContext.REQUEST_SCOPE);
throw new JspException(messages.getMessage("common.io", e.toString()));
}
return EVAL_BODY_INCLUDE;
}
FormTag.java 文件源码
项目:jaffa-framework
阅读 27
收藏 0
点赞 0
评论 0
/** This concludes the html of the Form tag.
* @throws JspException if any error occurs.
* @return EVAL_PAGE if the JSP engine should continue evaluating the JSP page, otherwise return SKIP_PAGE.
*/
public int doEndTag() throws JspException {
// Note: popping the nested component stack here causes runtime problems.
try {
JspWriter writer = pageContext.getOut();
doEndTagExt1(writer);
int i = super.doEndTag();
doEndTagExt2(writer);
return i;
} catch (IOException e) {
throw new JspException("error in FormTag: " + e);
} finally {
// Remove from stack
CustomTag.popParent(this,pageContext);
}
}
FinderMetaDataHelper.java 文件源码
项目:jaffa-framework
阅读 26
收藏 0
点赞 0
评论 0
/** Looks up the request stream for input parameters and then generates appropriate metaData. */
public static void perform(HttpServletRequest request, JspWriter out, ServletContext servletContext) throws Exception {
// Create a parameter Map from the input request
Map<String, String> parameters = getParameters(request);
if (log.isDebugEnabled())
log.debug("Input: " + parameters);
// Error out if parameters are not passed
if (parameters == null) {
String m = "MetaData cannot be generated since parameters have not been passed";
log.error(m);
throw new IllegalArgumentException(m);
}
// Obtain metaData
String metaData = c_enableCaching ? obtainMetaData(parameters, servletContext) : generateMetaData(parameters, servletContext);
out.print(metaData);
}
SampleTag.java 文件源码
项目:parabuild-ci
阅读 36
收藏 0
点赞 0
评论 0
/**
* Does two things:
* <ul>
* <li>Stops the page if the corresponding attribute has been set</li>
* <li>Prints a message another tag encloses this one.</li>
* </ul>
*/
public int doEndTag() throws JspTagException
{
//get the parent if any
Tag parent = this.getParent();
if (parent != null) {
try {
JspWriter out = this.pageContext.getOut();
out.println("This tag has a parent. <BR>");
} catch (IOException e) {
throw new JspTagException(e.getMessage());
}
}
if (this.stopPage) {
return Tag.SKIP_PAGE;
}
return Tag.EVAL_PAGE;
}
JspRuntimeLibrary.java 文件源码
项目:apache-tomcat-7.0.73-with-comment
阅读 34
收藏 0
点赞 0
评论 0
/**
* Perform a RequestDispatcher.include() operation, with optional flushing
* of the response beforehand.
*
* @param request The servlet request we are processing
* @param response The servlet response we are processing
* @param relativePath The relative path of the resource to be included
* @param out The Writer to whom we are currently writing
* @param flush Should we flush before the include is processed?
*
* @exception IOException if thrown by the included servlet
* @exception ServletException if thrown by the included servlet
*/
public static void include(ServletRequest request,
ServletResponse response,
String relativePath,
JspWriter out,
boolean flush)
throws IOException, ServletException {
if (flush && !(out instanceof BodyContent))
out.flush();
// FIXME - It is tempting to use request.getRequestDispatcher() to
// resolve a relative path directly, but Catalina currently does not
// take into account whether the caller is inside a RequestDispatcher
// include or not. Whether Catalina *should* take that into account
// is a spec issue currently under review. In the mean time,
// replicate Jasper's previous behavior
String resourcePath = getContextRelativePath(request, relativePath);
RequestDispatcher rd = request.getRequestDispatcher(resourcePath);
rd.include(request,
new ServletResponseWrapperInclude(response, out));
}
GridTag.java 文件源码
项目:jaffa-framework
阅读 27
收藏 0
点赞 0
评论 0
/** This generates the HTML for the tag.
* @param out The JspWriter object.
* @param bodyContent The BodyContent object.
* @throws IOException if any I/O error occurs.
*/
public void writeTagBodyContent(JspWriter out, BodyContent bodyContent) throws IOException {
if (isFirstPass())
// Write the main table tag, the table column headings, and start the table body
out.println( getInitialHtml() );
// Write out the start and end of the rows.
out.println( getRowStartHtml() );
if (m_hasRows)
out.println( processRow());
out.println( getRowEndingHtml() );
// clear the body content for the next time through.
bodyContent.clearBody();
// Increment the RowNo
++m_rowNo;
//Reset the column counters
m_currColumnNo = 0;
m_currColName = null;
}
ValuesTag.java 文件源码
项目:apache-tomcat-7.0.73-with-comment
阅读 30
收藏 0
点赞 0
评论 0
@Override
public int doEndTag() throws JspException {
JspWriter out = pageContext.getOut();
try {
if (!"-1".equals(objectValue)) {
out.print(objectValue);
} else if (!"-1".equals(stringValue)) {
out.print(stringValue);
} else if (longValue != -1) {
out.print(longValue);
} else if (doubleValue != -1) {
out.print(doubleValue);
} else {
out.print("-1");
}
} catch (IOException ex) {
throw new JspTagException("IOException: " + ex.toString(), ex);
}
return super.doEndTag();
}
AvatarTag.java 文件源码
项目:JuniperBotJ
阅读 27
收藏 0
点赞 0
评论 0
@Override
protected int doStartTagInternal() throws Exception {
try {
String avatarUrl;
String id = userId;
String avatar = this.avatar;
if (current || id == null) {
DiscordUserDetails details = SecurityUtils.getCurrentUser();
if (details != null) {
id = details.getId();
avatar = details.getAvatar();
}
}
avatarUrl = AvatarType.USER.getUrl(id, avatar);
JspWriter out = pageContext.getOut();
out.write(avatarUrl);
} catch (Exception ex) {
throw new JspException(ex);
}
return SKIP_BODY;
}
CommandTag.java 文件源码
项目:JuniperBotJ
阅读 27
收藏 0
点赞 0
评论 0
@Override
protected int doStartTagInternal() throws Exception {
try {
String result = code;
Long serverId = (Long) pageContext.getRequest().getAttribute("serverId");
if (serverId != null) {
Locale locale = (Locale) pageContext.getAttribute(LOCALE_ATTR);
ApplicationContext context = getRequestContext().getWebApplicationContext();
if (locale == null) {
ContextService contextService = context.getBean(ContextService.class);
locale = contextService.getLocale(serverId);
pageContext.setAttribute(LOCALE_ATTR, locale);
}
result = context.getMessage(code, null, locale);
}
if (StringUtils.isNotEmpty(var)) {
pageContext.setAttribute(var, result);
} else {
JspWriter out = pageContext.getOut();
out.write(result);
}
} catch (Exception ex) {
throw new JspException(ex);
}
return SKIP_BODY;
}
FunctionGuardTag.java 文件源码
项目:jaffa-framework
阅读 23
收藏 0
点赞 0
评论 0
/** .//GEN-BEGIN:doAfterbody
*
*
* This method is called after the JSP engine processes the body content of the tag.
* @return EVAL_BODY_AGAIN if the JSP engine should evaluate the tag body again, otherwise return SKIP_BODY.
* This method is automatically generated. Do not modify this method.
* Instead, modify the methods that this method calls.
* @throws JspException
* @throws JspException */
public int doAfterBody() throws JspException, JspException {
try {
//
// This code is generated for tags whose bodyContent is "JSP"
//
JspWriter out = getPreviousOut();
BodyContent bodyContent = getBodyContent();
writeTagBodyContent(out, bodyContent);
} catch (Exception ex) {
throw new JspException("error in FunctionGuardTag: " + ex);
}
if (theBodyShouldBeEvaluatedAgain()) {
return EVAL_BODY_AGAIN;
} else {
return SKIP_BODY;
}
}
ComponentGuardTag.java 文件源码
项目:jaffa-framework
阅读 23
收藏 0
点赞 0
评论 0
/** .//GEN-BEGIN:doAfterbody
*
*
* This method is called after the JSP engine processes the body content of the tag.
* @return EVAL_BODY_AGAIN if the JSP engine should evaluate the tag body again, otherwise return SKIP_BODY.
* This method is automatically generated. Do not modify this method.
* Instead, modify the methods that this method calls.
* @throws JspException */
public int doAfterBody() throws JspException {
try {
//
// This code is generated for tags whose bodyContent is "JSP"
//
JspWriter out = getPreviousOut();
BodyContent bodyContent = getBodyContent();
writeTagBodyContent(out, bodyContent);
} catch (Exception ex) {
throw new JspException("error in ComponentGuardTag: " + ex);
}
if (theBodyShouldBeEvaluatedAgain()) {
return EVAL_BODY_AGAIN;
} else {
return SKIP_BODY;
}
}
CalendarTag.java 文件源码
项目:jaffa-framework
阅读 28
收藏 0
点赞 0
评论 0
/** The HTML is generated in this end tag, assuming the underlying field
* is not read-only or hidden
*/
public void otherDoEndTagOperations() throws JspException {
super.otherDoEndTagOperations();
if (getPropertyRuleIntrospector() == null ||
(getPropertyRuleIntrospector() != null && !getPropertyRuleIntrospector().isHidden() && !getPropertyRuleIntrospector().isReadOnly() ) ) {
try {
JspWriter out = pageContext.getOut();
out.println( getHtml() );
} catch (IOException e) {
String str = "Exception in writing the " + TAG_NAME;
log.error(str, e);
throw new JspWriteRuntimeException(str, e);
}
} else {
log.debug(TAG_NAME + " Not displayed as field " + getField() + " is hidden or read-only");
}
}
PagerTag.java 文件源码
项目:opencron
阅读 31
收藏 0
点赞 0
评论 0
private void wrapSpan(JspWriter out, String title, int status) throws IOException {
if (status == 1) {
out.append("<li class='active'>");
} else if (status == -1) {
out.append("<li class='disabled'>");
} else {
out.append("<li>");
}
out.append("<a href='javascript:void(0);'>");
out.append(title);
out.append("</a></li>");
}
Out.java 文件源码
项目:tomcat7
阅读 25
收藏 0
点赞 0
评论 0
public static boolean output(JspWriter out, Object input, String value,
String defaultValue, boolean escapeXml) throws IOException {
if (input instanceof Reader) {
char[] buffer = new char[8096];
int read = 0;
while (read != -1) {
read = ((Reader) input).read(buffer);
if (read != -1) {
if (escapeXml) {
String escaped = Util.escapeXml(buffer, read);
if (escaped == null) {
out.write(buffer, 0, read);
} else {
out.print(escaped);
}
} else {
out.write(buffer, 0, read);
}
}
}
return true;
} else {
String v = value != null ? value : defaultValue;
if (v != null) {
if(escapeXml){
v = Util.escapeXml(v);
}
out.write(v);
return true;
} else {
return false;
}
}
}
BodyContentImpl.java 文件源码
项目:tomcat7
阅读 29
收藏 0
点赞 0
评论 0
/**
* Constructor.
*/
public BodyContentImpl(JspWriter enclosingWriter) {
super(enclosingWriter);
cb = new char[Constants.DEFAULT_TAG_BUFFER_SIZE];
bufferSize = cb.length;
nextChar = 0;
closed = false;
}
FormTag.java 文件源码
项目:jaffa-framework
阅读 33
收藏 0
点赞 0
评论 0
/** This method will write out the hidden-fields */
private void doEndTagExt1(JspWriter writer) throws IOException {
Object formObj = pageContext.findAttribute(getBeanName());
if(formObj != null && formObj instanceof FormBase) {
FormBase f = (FormBase) formObj;
StringBuffer buf = new StringBuffer();
buf.append("<input type='hidden' name='" + PARAMETER_COMPONENT_ID + "' value='" + (f.getComponent()==null ? "" : f.getComponent().getComponentId() ) + "'>\n");
buf.append("<input type='hidden' name='" + PARAMETER_EVENT_ID + "' value=''>\n");
buf.append("<input type='hidden' id='" + PARAMETER_DATESTAMP_ID + "' value='" + m_dateTime.timeInMillis() + "'>\n");
// buf.append("<input type=\"hidden\" name=\"" + PARAMETER_TOKEN_ID + "\" value=\"" +
// (UserSession.getUserSession((HttpServletRequest) pageContext.getRequest()).getCurrentToken()) + "\">\n");
buf.append("</span>");
writer.println(buf.toString());
}
}
CustomTag.java 文件源码
项目:jaffa-framework
阅读 33
收藏 0
点赞 0
评论 0
/** .
* This method is called after the JSP engine processes the body content of the tag.
* @return EVAL_BODY_AGAIN if the JSP engine should evaluate the tag body again, otherwise return SKIP_BODY.
* This method is automatically generated. Do not modify this method.
* Instead, modify the methods that this method calls.
*/
public int doAfterBody() throws JspException {
if (log.isDebugEnabled())
log.debug(this.NAME+".doAfterBody: START. pageContext="+pageContext+ ", BodyContent="+getBodyContent() );
if(IBodyTag.class.isInstance(this)) {
// We should output the body content
BodyContent bodyContent = getBodyContent();
if (log.isDebugEnabled())
log.debug(this.NAME+".doAfterBody: Got Body Size = " +
(bodyContent.getString() == null ? "null" : ""+bodyContent.getString().length()));
try {
JspWriter out = getPreviousOut();
writeTagBodyContent(out, bodyContent);
} catch (IOException ex) {
log.error(this.NAME + ".doAfterBody(): Error on "+this, ex);
throw new JspException("Error in " + this.NAME + ".doAfterBody() on "+this);
}
}
if (theBodyShouldBeEvaluatedAgain()) {
return EVAL_BODY_AGAIN;
} else {
return SKIP_BODY;
}
}
EchoAttributesTag.java 文件源码
项目:tomcat7
阅读 28
收藏 0
点赞 0
评论 0
public void doTag() throws JspException, IOException {
JspWriter out = getJspContext().getOut();
for( int i = 0; i < keys.size(); i++ ) {
String key = (String)keys.get( i );
Object value = values.get( i );
out.println( "<li>" + key + " = " + value + "</li>" );
}
}
TestPageContextImpl.java 文件源码
项目:tomcat7
阅读 35
收藏 0
点赞 0
评论 0
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
PageContext pageContext = JspFactory.getDefaultFactory().getPageContext(
this, req, resp, null, false, JspWriter.DEFAULT_BUFFER, true);
JspWriter out = pageContext.getOut();
if (Constants.DEFAULT_BUFFER_SIZE == out.getBufferSize()) {
resp.getWriter().println("OK");
} else {
resp.getWriter().println("FAIL");
}
}
PageContextImpl.java 文件源码
项目:lams
阅读 32
收藏 0
点赞 0
评论 0
public JspWriter popBody() {
depth--;
if (depth >= 0) {
out = outs[depth];
} else {
out = baseOut;
}
// Update the value of the "out" attribute in the page scope
// attribute namespace of this PageContext
setAttribute(OUT, out);
return out;
}
BodyContentImpl.java 文件源码
项目:lazycat
阅读 39
收藏 0
点赞 0
评论 0
/**
* Constructor.
*/
public BodyContentImpl(JspWriter enclosingWriter) {
super(enclosingWriter);
cb = new char[Constants.DEFAULT_TAG_BUFFER_SIZE];
bufferSize = cb.length;
nextChar = 0;
closed = false;
}
JavascriptValidatorTag.java 文件源码
项目:lams
阅读 27
收藏 0
点赞 0
评论 0
/**
* Render the JavaScript for to perform validations based on the form name.
*
* @exception JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException {
JspWriter writer = pageContext.getOut();
try {
writer.print(this.renderJavascript());
} catch (IOException e) {
throw new JspException(e.getMessage());
}
return EVAL_BODY_TAG;
}
FormTag.java 文件源码
项目:lams
阅读 32
收藏 0
点赞 0
评论 0
/**
* Render the end of this form.
*
* @exception JspException if a JSP exception has occurred
*/
public int doEndTag() throws JspException {
// Remove the page scope attributes we created
pageContext.removeAttribute(Constants.BEAN_KEY, PageContext.REQUEST_SCOPE);
pageContext.removeAttribute(Constants.FORM_KEY, PageContext.REQUEST_SCOPE);
// Render a tag representing the end of our current form
StringBuffer results = new StringBuffer("</form>");
// Render JavaScript to set the input focus if required
if (this.focus != null) {
results.append(this.renderFocusJavascript());
}
// Print this value to our output writer
JspWriter writer = pageContext.getOut();
try {
writer.print(results.toString());
} catch (IOException e) {
throw new JspException(messages.getMessage("common.io", e.toString()));
}
// Continue processing this page
return (EVAL_PAGE);
}
PortraitTag.java 文件源码
项目:lams
阅读 33
收藏 0
点赞 0
评论 0
@Override
public int doEndTag() throws JspException {
String serverURL = Configuration.get(ConfigurationKeys.SERVER_URL);
serverURL = serverURL == null ? null : serverURL.trim();
try {
if (userId != null && userId.length() > 0) {
String code = null;
HashMap<String, String> cache = getPortraitCache();
code = cache.get(userId);
if (code == null) {
Integer userIdInt = Integer.decode(userId);
User user = (User) getUserManagementService().findById(User.class, userIdInt);
boolean isHover = (hover != null ? Boolean.valueOf(hover) : false);
if ( isHover ) {
code = buildHoverUrl(user);
} else {
code = buildDivUrl(user);
}
cache.put(userId, code);
}
JspWriter writer = pageContext.getOut();
writer.print(code);
}
} catch (NumberFormatException nfe) {
PortraitTag.log.error("PortraitId unable to write out portrait details as userId is invalid. " + userId,
nfe);
} catch (IOException ioe) {
PortraitTag.log.error(
"PortraitId unable to write out portrait details due to IOException. UserId is " + userId, ioe);
} catch (Exception e) {
PortraitTag.log.error(
"PortraitId unable to write out portrait details due to an exception. UserId is " + userId, e);
}
return Tag.SKIP_BODY;
}
HtmlTag.java 文件源码
项目:lams
阅读 30
收藏 0
点赞 0
评论 0
private void writeString(String output) {
try {
JspWriter writer = pageContext.getOut();
writer.println(output);
} catch (IOException e) {
log.error("HTML tag unable to write out HTML details due to IOException.", e);
// don't throw a JSPException as we want the system to still function, well, best
// the page can without the html tag!
}
}
ConfigurationTag.java 文件源码
项目:lams
阅读 28
收藏 0
点赞 0
评论 0
@Override
public int doStartTag() throws JspException {
JspWriter writer = pageContext.getOut();
try {
writer.print(Configuration.get(getKey()));
} catch (IOException e) {
log.error("Error in configuration tag", e);
throw new JspException(e);
}
return SKIP_BODY;
}
FormTag.java 文件源码
项目:jaffa-framework
阅读 29
收藏 0
点赞 0
评论 0
/** This method will write out all the header-info for the widgets in the form */
private void doEndTagExt2(JspWriter writer) throws IOException {
// Display guarded page section
writer.println(determineGuardedHtml());
// Write out and footer code needed by the widgets
for (Iterator iter=m_footerCache.keySet().iterator(); iter.hasNext(); ) {
Object key = iter.next();
Object javaScript = m_footerCache.get(key);
if(javaScript!=null) {
writer.println(javaScript);
if(log.isDebugEnabled())
log.debug("Write Footer Code For Widget " + key + "\n" + javaScript);
}
}
}