Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 1.1.0.M1
    • Component/s: @ CORE
    • Labels:
      None

      Description

      Editing web.xml could be simplified, as suggested in the above forum post. Maybe something like:

      WebXMLBuilder.addFilter(webXml).setName(param).set Class(param)

      This would seem to resolve a number of hickups we encountered during development of add-ons to date like filter/filter-mapping ordering semantics etc.

      It might be better to put this into a metadata object instead of provide a builder. It's also appropriate to review the web.xml fragmentation capabilities being considered in Servlet Spec 3 if building a metadata object.

        Issue Links

          Activity

          Hide
          Ben Alex added a comment -

          Assigned to Stefan so we can capture requirements, assess time required and consider which future release is realistic.

          Show
          Ben Alex added a comment - Assigned to Stefan so we can capture requirements, assess time required and consider which future release is realistic.
          Hide
          Murilo Rodrigues added a comment -

          +1 on this one.

          I´m starting to write my first add-on and needed to write functions like this one:

          private void addContextParam(Document webXml, String paramName, String paramValue) {

          Element root = webXml.getDocumentElement();

          if (null != XmlUtils.findFirstElement("/web-app/context-param[param-name='" + paramName + "']", root))

          { //context-param already exists, nothing to do return; }

          Element lastContextParam = XmlUtils.findRequiredElement("/web-app/context-param[last()]", root);

          Element contextParamElement = webXml.createElement("context-param");
          Element paramNameElement = webXml.createElement("param-name");
          paramNameElement.setTextContent(paramName);
          contextParamElement.appendChild(paramNameElement);
          Element paramValueElement = webXml.createElement("param-value");
          paramValueElement.setTextContent(paramValue);
          contextParamElement.appendChild(paramValueElement);

          root.insertBefore(contextParamElement, lastContextParam.getNextSibling());
          }

          Show
          Murilo Rodrigues added a comment - +1 on this one. I´m starting to write my first add-on and needed to write functions like this one: private void addContextParam(Document webXml, String paramName, String paramValue) { Element root = webXml.getDocumentElement(); if (null != XmlUtils.findFirstElement("/web-app/context-param [param-name='" + paramName + "'] ", root)) { //context-param already exists, nothing to do return; } Element lastContextParam = XmlUtils.findRequiredElement("/web-app/context-param [last()] ", root); Element contextParamElement = webXml.createElement("context-param"); Element paramNameElement = webXml.createElement("param-name"); paramNameElement.setTextContent(paramName); contextParamElement.appendChild(paramNameElement); Element paramValueElement = webXml.createElement("param-value"); paramValueElement.setTextContent(paramValue); contextParamElement.appendChild(paramValueElement); root.insertBefore(contextParamElement, lastContextParam.getNextSibling()); }
          Hide
          Stefan Schmidt added a comment -

          Introduced WebXmlUtils class which provides convenient access to manage most contents of a Roo web.xml file.

          As an example:

          WebXmlUtils.addContextParam(new WebXmlUtils.WebXmlParam("defaultHtmlEscape", "true"), webXml, "Enable escaping of form submission contents");
          WebXmlUtils.addFilter("CharacterEncodingFilter", "org.springframework.web.filter.CharacterEncodingFilter", "/*", webXml, null, new WebXmlUtils.WebXmlParam("encoding", "UTF-8"), new WebXmlUtils.WebXmlParam("forceEncoding", "true"));
          WebXmlUtils.addListener("org.springframework.web.context.ContextLoaderListener", webXml, "Creates the Spring Container shared by all Servlets and Filters");
          WebXmlUtils.addServlet(projectMetadata.getProjectName(), "org.springframework.web.servlet.DispatcherServlet", "/app/*", new Integer(1), webXml, "Handles Spring requests", new WebXmlUtils.WebXmlParam("contextConfigLocation", "/WEB-INF/spring/webmvc-config.xml"));
          WebXmlUtils.setSessionTimeout(new Integer(10), webXml, null);
          WebXmlUtils.addWelcomeFile("index", webXml, null);
          WebXmlUtils.addExceptionType("java.lang.Exception", "/app/uncaughtException", webXml, null);
          WebXmlUtils.addErrorCode(new Integer(404), "/app/resourceNotFound", webXml, null);
          
          Show
          Stefan Schmidt added a comment - Introduced WebXmlUtils class which provides convenient access to manage most contents of a Roo web.xml file. As an example: WebXmlUtils.addContextParam( new WebXmlUtils.WebXmlParam( "defaultHtmlEscape" , " true " ), webXml, "Enable escaping of form submission contents" ); WebXmlUtils.addFilter( "CharacterEncodingFilter" , "org.springframework.web.filter.CharacterEncodingFilter" , "/*" , webXml, null , new WebXmlUtils.WebXmlParam( "encoding" , "UTF-8" ), new WebXmlUtils.WebXmlParam( "forceEncoding" , " true " )); WebXmlUtils.addListener( "org.springframework.web.context.ContextLoaderListener" , webXml, "Creates the Spring Container shared by all Servlets and Filters" ); WebXmlUtils.addServlet(projectMetadata.getProjectName(), "org.springframework.web.servlet.DispatcherServlet" , "/app/*" , new Integer (1), webXml, "Handles Spring requests" , new WebXmlUtils.WebXmlParam( "contextConfigLocation" , "/WEB-INF/spring/webmvc-config.xml" )); WebXmlUtils.setSessionTimeout( new Integer (10), webXml, null ); WebXmlUtils.addWelcomeFile( "index" , webXml, null ); WebXmlUtils.addExceptionType( "java.lang.Exception" , "/app/uncaughtException" , webXml, null ); WebXmlUtils.addErrorCode( new Integer (404), "/app/resourceNotFound" , webXml, null );
          Hide
          Stefan Schmidt added a comment -

          Minor correction in servlet definition (rev d0eaa491e356af8c2a5247abb771a5ad5b4056d5).

          Show
          Stefan Schmidt added a comment - Minor correction in servlet definition (rev d0eaa491e356af8c2a5247abb771a5ad5b4056d5).

            People

            • Assignee:
              Stefan Schmidt
              Reporter:
              Ben Alex
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: