# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /Users/tstone/NetBeansProjects/stripes-1.5.5/1.5.x/stripes # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: resources/stripes.tld --- resources/stripes.tld Base (BASE) +++ resources/stripes.tld Locally Modified (Based On LOCAL) @@ -554,6 +554,36 @@ Tag sets a request scoped variable that provides an override to the + StripesFilter HtmlMode setting.

+ +

Stripes defaults to an "XHTML-compatible" empty tag syntax, e.g., + <img ... />. Deployers can override + the Stripes default by setting the Runtime Configuration of + Stripes.HtmlMode to "HTML".

+ +

Overriding the Stripes default provides a syntax more compatible with + HTML 4 and HTML 5 recommendations, e.g., <img ... >

+ +

This tag provides a fallback position for developers that may need to + generate views using an XHTML or HTML syntax when the main application is set + differently.

+ ]]> +
+ options + options + net.sourceforge.stripes.tag.HtmlOptionsTag + empty + + @htmlMode@ + htmlMode + true + true + +
+ + + Tag that generates an image input button for use in HTML forms, e.g:

<input name="foo" type="image" src="/app/foo.gif" alt="foo"/>
Index: src/net/sourceforge/stripes/config/Configuration.java --- src/net/sourceforge/stripes/config/Configuration.java Base (BASE) +++ src/net/sourceforge/stripes/config/Configuration.java Locally Modified (Based On LOCAL) @@ -85,6 +85,12 @@ /** Returns true if the Stripes application is running in debug mode. */ boolean isDebugMode(); + /** Set the HTML mode. */ + void setHtmlMode(String HtmlMode); + + /** Returns the Stripes application HTML output mode. */ + String getHtmlMode(); + /** * Returns an instance of ActionResolver that will be used by Stripes to lookup and resolve * ActionBeans. The instance should be cached by the Configuration since multiple entities Index: src/net/sourceforge/stripes/config/DefaultConfiguration.java --- src/net/sourceforge/stripes/config/DefaultConfiguration.java Base (BASE) +++ src/net/sourceforge/stripes/config/DefaultConfiguration.java Locally Modified (Based On LOCAL) @@ -81,6 +81,7 @@ private static final Log log = Log.getInstance(DefaultConfiguration.class); private boolean debugMode; + private String htmlMode; private BootstrapPropertyResolver resolver; private ActionResolver actionResolver; private ActionBeanPropertyBinder actionBeanPropertyBinder; @@ -115,6 +116,14 @@ this.debugMode = false; } + String htmlMode = initHtmlMode(); + if (htmlMode != null) { + this.htmlMode = htmlMode; + } + else { + this.htmlMode = "xhtml"; + } + this.actionResolver = initActionResolver(); if (this.actionResolver == null) { this.actionResolver = new NameBasedActionResolver(); @@ -252,6 +261,21 @@ return null; } + /** Set the HTML mode. */ + public void setHtmlMode(String htmlMode) { + this.htmlMode = htmlMode; + } + + /** Returns the Stripes application HTML format mode. */ + public String getHtmlMode() { + return htmlMode; + } + + /** Allows subclasses to initialize a non-default HTML mode value. */ + protected String initHtmlMode() { + return null; + } + /** * Returns an instance of {@link NameBasedActionResolver} unless a subclass has * overridden the default. Index: src/net/sourceforge/stripes/config/RuntimeConfiguration.java --- src/net/sourceforge/stripes/config/RuntimeConfiguration.java Base (BASE) +++ src/net/sourceforge/stripes/config/RuntimeConfiguration.java Locally Modified (Based On LOCAL) @@ -62,6 +62,9 @@ /** The Configuration Key for enabling debug mode. */ public static final String DEBUG_MODE = "Stripes.DebugMode"; + /** The Configuration Key for enabling HTML mode. */ + public static final String HTML_MODE = "Stripes.HtmlMode"; + /** The Configuration Key for looking up the name of the ActionResolver class. */ public static final String ACTION_RESOLVER = "ActionResolver.Class"; @@ -115,6 +118,16 @@ } } + /** Looks for a format value in config. */ + @Override protected String initHtmlMode() { + try { + return getBootstrapPropertyResolver().getProperty(HTML_MODE).toLowerCase(); + } + catch (Exception e) { + return null; + } + } + /** Looks for a class name in config and uses that to create the component. */ @Override protected ActionResolver initActionResolver() { return initializeComponent(ActionResolver.class, ACTION_RESOLVER); Index: src/net/sourceforge/stripes/tag/FormTag.java --- src/net/sourceforge/stripes/tag/FormTag.java Base (BASE) +++ src/net/sourceforge/stripes/tag/FormTag.java Locally Modified (Based On LOCAL) @@ -40,6 +40,7 @@ import java.util.Map; import java.util.Set; import java.util.List; +import javax.servlet.jsp.PageContext; /** *

Form tag for use with the Stripes framework. Supports all of the HTML attributes applicable @@ -222,12 +223,31 @@ *

  • The form close tag
  • * * + * Supports "HTML 4" self closing syntax at Stripes Filter configuration. + * + * Deployers should set Stripes.HtmlMode to html, e.g., + *
    +     * 
    +     *   Stripes.HtmlMode
    +     *   html
    +     * 
    +     * 
    + * This will result in an empty, or self-closing, tag format compatible with HTML 4 and HTML 5. + * + * The Stripes default is XHTML, e.g., <img ... />All of this is done in doEndTag to allow form elements to modify the form tag itself if * necessary. A prime example of this is the InputFileTag, which needs to ensure that the form * method is POST and the enctype is correct.

    */ @Override public int doEndTag() throws JspException { + String htmlMode = StripesFilter.getConfiguration().getHtmlMode(); + // Does the view override the RuntimeConfiguration? + if(pageContext.getAttribute("htmlMode", PageContext.REQUEST_SCOPE) != null) { + htmlMode = (String) pageContext.getAttribute("htmlMode", PageContext.REQUEST_SCOPE); + } + try { // Default the method to post if (getMethod() == null) { @@ -256,7 +276,11 @@ out.write("\" value=\""); HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest(); out.write(CryptoUtil.encrypt(request.getServletPath())); + if("html".equalsIgnoreCase(htmlMode)) { + out.write("\">"); + } else { out.write("\" />"); + } if (isWizard()) { writeWizardFields(); @@ -323,6 +347,12 @@ // Figure out what set of names to include Set namesToInclude = new HashSet(); + String htmlMode = StripesFilter.getConfiguration().getHtmlMode(); + // Does the view override the RuntimeConfiguration? + if(pageContext.getAttribute("htmlMode", PageContext.REQUEST_SCOPE) != null) { + htmlMode = (String) pageContext.getAttribute("htmlMode", PageContext.REQUEST_SCOPE); + } + if (isWizard()) { namesToInclude.addAll(this.fieldsPresent.keySet()); } @@ -344,8 +374,12 @@ out.write(StripesConstants.URL_KEY_FIELDS_PRESENT); out.write("\" value=\""); out.write(hiddenFieldValue); + if("html".equalsIgnoreCase(htmlMode)) { + out.write("\">"); + } else { out.write("\" />"); } + } /** * Fetches the ActionBean associated with the form if one is present. An ActionBean will not Index: src/net/sourceforge/stripes/tag/HtmlOptionsTag.java --- src/net/sourceforge/stripes/tag/HtmlOptionsTag.java Locally New +++ src/net/sourceforge/stripes/tag/HtmlOptionsTag.java Locally New @@ -0,0 +1,69 @@ +/* + * Copyright 2010 Timothy Stone. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * under the License. + */ + +package net.sourceforge.stripes.tag; + +import javax.servlet.jsp.JspException; + +/** + *

    Provides a tag to override the RuntimeConfiguration of the + * Stripes.HtmlMode.

    + *

    htmlMode accepts any string value, however any value not equal to + * html, case-insensitive, puts Stripes into its default mode of XHTML- + * compatible output.

    + *

    Examples of the tag's use then might be:

    + *
      + *
    • <s:options htmlMode="html" /> produces HTML4 and HTML5 form elements, + * e.g., <img src … >
    • + *
    • <s:options htmlMode="xhtml" /> produces XHTML-compatible form elements, + * e.g., <img src … />
    • + *
    • <s:options htmlMode="default" /> produces XHTML form elements
    • + *
    + *

    Typical use of the tag in context of a Stripes application follows:

    + *

    Deployer will set the application RuntimeConfiguration of + * Stripes.HtmlMode. A deployer choosing not to set this option, defaults + * the Stripes application to its XHTML-compatible format.

    + * Stripes.HtmlMode will set the default X/HTML output + * for the entire application. Individual views of the application may wish + * to alter the default or RuntimeConfiguration will provide this tag, at or near the beginning + * of the view, or JSP.

    + * + * @author tstone + * @since 1.5.5 + */ +public class HtmlOptionsTag extends StripesTagSupport { + + private String htmlMode; + + @Override + public int doStartTag() throws JspException { + return SKIP_BODY; + } + + @Override + public int doEndTag() throws JspException { + pageContext.getRequest().setAttribute("htmlMode", this.htmlMode); + return EVAL_PAGE; + } + + /** + * @param htmlMode the htmlMode to set + */ + public void setHtmlMode(String htmlMode) { + this.htmlMode = htmlMode; + } +} Index: src/net/sourceforge/stripes/tag/HtmlTagSupport.java --- src/net/sourceforge/stripes/tag/HtmlTagSupport.java Base (BASE) +++ src/net/sourceforge/stripes/tag/HtmlTagSupport.java Locally Modified (Based On LOCAL) @@ -14,6 +14,7 @@ */ package net.sourceforge.stripes.tag; +import net.sourceforge.stripes.controller.StripesFilter; import net.sourceforge.stripes.exception.StripesJspException; import net.sourceforge.stripes.util.Log; import net.sourceforge.stripes.util.HtmlUtil; @@ -25,6 +26,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; +import javax.servlet.jsp.PageContext; /** * Provides basic facilities for any tag that wishes to mimic a standard HTML/XHTML tag. Includes @@ -166,17 +168,41 @@ * Writes out a singleton tag (aka a bodiless tag or self-closing tag). Similar to * writeOpenTag except that instead of leaving the tag open, it closes the tag. * + * Supports "HTML 4" self closing syntax at Stripes Filter configuration. + * + * Deployers should set Stripes.HtmlMode to html, e.g., + *
    +     * 
    +     *   Stripes.HtmlMode
    +     *   html
    +     * 
    +     * 
    + * This will result in an empty, or self-closing, tag format compatible with HTML 4 and HTML 5. + * + * The Stripes default is XHTML, e.g., <img ... />"); + } else { writer.print(" />"); } + } catch (IOException ioe) { JspException jspe = new JspException("IOException encountered while writing singleton tag <" + tag + "/> to the JspWriter.", ioe); Index: src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java --- src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java Base (BASE) +++ src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java Locally Modified (Based On LOCAL) @@ -14,6 +14,7 @@ */ package net.sourceforge.stripes.tag; +import net.sourceforge.stripes.controller.StripesFilter; import net.sourceforge.stripes.exception.StripesJspException; import net.sourceforge.stripes.localization.LocalizationUtility; import net.sourceforge.stripes.util.bean.BeanUtil; @@ -24,11 +25,13 @@ import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; +import javax.servlet.jsp.tagext.Tag; import java.util.Collection; import java.util.Locale; import java.util.Collections; import java.util.List; import java.util.LinkedList; +import javax.servlet.jsp.PageContext; /** *

    Writes a set of {@literal } tags to the page based on the @@ -277,10 +280,30 @@ * Optionally sorts the assembled entries and then renders them into a series of * option tags using an instance of InputOptionTag to do the rendering work. * + * Supports "HTML 4" self closing syntax at Stripes Filter configuration. + * + * Deployers should set Stripes.HtmlMode to html, e.g., + *

    +     * 
    +     *   Stripes.HtmlMode
    +     *   html
    +     * 
    +     * 
    + * This will result in an empty, or self-closing, tag format compatible with HTML 4 and HTML 5. + * + * The Stripes default is XHTML, e.g., <img ... /> sortedEntries = new LinkedList(this.entries); if (this.sort != null) { @@ -314,7 +337,11 @@ JspWriter out = getPageContext().getOut(); out.write(""); + if("html".equalsIgnoreCase(htmlMode)) { + out.write("\">"); + } else { + out.write("\" />"); + } lastGroup = entry.group; }