0

I am trying to implement HDIV to a spring 3.1 application.

I have added the dependencies in pom file and listener, filter in web.xml file.

I have done the configuration as shown and when I access the application then welcome page is loading but after that if I access any link from the screen then it is redirected to errorpage.

I get the error as "HDIV_PARAMETER_NOT_EXISTS"

What might be the problem?

How to send HDIV parameter in request. Do I need to modify the JSPs to send HDIV parameter in request?

web.xml:

     <listener>
    <listener-class>org.hdiv.listener.InitListener</listener-class>
    </listener>
<!-- HDIV Validator Filter -->
<filter>
    <filter-name>ValidatorFilter</filter-name>
    <filter-class>org.hdiv.filter.ValidatorFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>ValidatorFilter</filter-name>
    <!-- Spring MVC Servlet name-->
    <servlet-name>mvc-dispatcher</servlet-name>
</filter-mapping>


    <jsp-config>
         <taglib>
        <taglib-uri>http://www.springframework.org/tags/form</taglib-uri>
        <taglib-location>/WEB-INF/lib/spring-form.tld</taglib-location>
        </taglib>
        <taglib>
              <taglib-uri>http://www.springframework.org/tags</taglib-uri>
              <taglib-location>/WEB-INF/lib/spring.tld</taglib-location>
        </taglib>
         <taglib>
          <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
               <taglib-location>/WEB-INF/lib/hdiv-c.tld</taglib-location>
    </taglib>
</jsp-config>

pom.xml:

<dependency>
          <groupId>org.hdiv</groupId>
          <artifactId>hdiv-core</artifactId>
      <version>${org.hdiv-version}</version>
</dependency>
<dependency>
    <groupId>org.hdiv</groupId>
    <artifactId>hdiv-config</artifactId>
    <version>${org.hdiv-version}</version>
</dependency>
<dependency>
    <groupId>org.hdiv</groupId>
    <artifactId>hdiv-spring-mvc</artifactId>
    <version>${org.hdiv-version}</version>
    </dependency>
<dependency>
    <groupId>org.hdiv</groupId>
    <artifactId>hdiv-jstl-taglibs-1.2</artifactId>
    <version>${org.hdiv-version}</version>
</dependency>

configuration:

<hdiv:config excludedExtensions="css,png,gif,jpeg,jpg,js" errorPage="/errorPage.jsp">
<hdiv:startPages>/,/index.htm</hdiv:startPages>
</hdiv:config> 

<!-- Accepted pattern within the application for all editable parameters (generated from textbox and textarea) -->   
<hdiv:validation id="safeText">         
<hdiv:acceptedPattern><![CDATA[^[a-zA-Z0-9@.-_]*$]]></hdiv:acceptedPattern>     
</hdiv:validation>       
<!-- Finally, it's necessary to define editable data validation for the application -->    
<hdiv:editableValidations>         
<hdiv:validationRule url="/.*">safeText</hdiv:validationRule>     
</hdiv:editableValidations>

Index.jsp:

        <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <html>
      <head>
      <title>Freight Management Tool</title>
      </head>
      <body  topmargin="0" leftmargin="0" >


    <div id="header">
        <%@include file="header.jspf"%>  
    </div> 
    <div id="content"> </div>
        <table width="100%" cellpadding="0" cellspacing="0" border="0">
            <tr class="topHeading">
                <td>
                <% if (request.isUserInRole("FMT_ADMIN")) { %>
                    <spring:message code = "index.admin"/>
                <% } if (request.isUserInRole("FMT_NM")) { %>
                    <spring:message code = "index.network.mngt"/>
                <% } if (request.isUserInRole("FMT_RM")) { %>
                    <spring:message code = "index.revenue.mngt"/>
                <% } if (request.isUserInRole("FMT_SALES")) { %>
                    <spring:message code = "index.sales"/>
                <% } %>
                </td>
                <td></td>
            </tr>
        </table>
        <table width="100%" cellpadding="0" cellspacing="0" border="0">
            <br/>
            <% if (!request.isUserInRole("FMT_SALES")) { %>
            <tr>
                <td width="2%"></td>
                <td width="15%" class="blackHeading"><spring:message code = "index.welcome"/> <h1><a href="/cargoalflights/SearchCargoalFlightMaster.htm"><spring:message code = "index.cargoal.search"/></a></h1></td>
                <td width="63%"></td>
            </tr>
            <% } else {%>
            <tr>
                <td width="2%"></td>
                <td width="15%" class="blackHeading"><spring:message code = "index.welcome"/> <h1><a href="/datedflight/DatedFlightSearch.htm"><spring:message code = "index.dated.flight.search"/></a></h1></td>
                <td width="63%"></td>
            </tr>
            <% } %>

        </table>

  </body>
</html>

DatedFlightController.java:

@RequestMapping("/datedflight/DatedFlightSearch.htm")
public ModelAndView datedFlightSearchScreen() {
return new ModelAndView("datedFlightSearch", "datedFlightDTO",
            datedFlightDTO);
}
Ralph
  • 118,862
  • 56
  • 287
  • 383
user2369634
  • 897
  • 3
  • 9
  • 17
  • Could you please post the code (part) of the jsp page that contains the link that gets redirected to the error page. – Ralph Mar 18 '14 at 08:48
  • @Ralph: Please find the code above. – user2369634 Mar 18 '14 at 10:13
  • I cant find any link or form in this jsp. - I asked for the page (A) that contains the link to the other page (B) that does not get displayed. Page (A) is what I asked for. – Ralph Mar 18 '14 at 12:29
  • From index.jsp when the datedflight search link is clicked it will be redirected to controller method datedFlightSearchScreen() and loads datedFlightSearch.jsp. Now the screen datedFlightSearch.jsp is not loading because of the error – user2369634 Mar 18 '14 at 12:51
  • I would expect, that you somehow need to involve some HDIV funktionalaty in the cration of the link url. – Ralph Mar 18 '14 at 16:38

1 Answers1

0

You have to use JSTL or Spring tags to create the URLs:

<c:url value="/datedflight/DatedFlightSearch.htm">

or

<spring:url value="/datedflight/DatedFlightSearch.htm">

Otherwise, HDIV can't include states identification as a parameter.

gillarramendi
  • 271
  • 1
  • 8
  • Even after adding the spring:url the same is occurred. request.getParameter(hdivParameter) is returning Null in the restoreState(HttpServletRequest request, String target) method of ValidatorHelperRequest class – user2369634 Apr 15 '14 at 13:01