0

I'm having trouble trying to implement form:select in HDIV. Here's my code in the JSP which renders the selector and options:

<form:form
 modelAttribute="staffPosition" 
 method="post"
 action="${contextPath}/project/assign/staff">
 <td>
  <form:select class="form-control" path="staffID">
   <c:forEach items="${staffList}" var="staff">
    <c:set var="staffName" value="${staff.prefix} ${staff.firstName} ${staff.middleName} ${staff.lastName} ${staff.suffix}"/>
    <form:option value="${staff.id}" label="${staffName}"/>
   </c:forEach>
  </form:select>
 </td>
 <td>
  &nbsp;
 </td>
 <td>
  <form:input placeholder="Example: Project Manager, Leader, etc..."
   type="text"
   class="form-control"
   path="position"/>
 </td>
 <td>
  &nbsp;
 </td>
 <td>
  <button class="btn btn-default btn-flat btn-sm">Assign</button>
 </td>
</form:form>

After I click assign and initiate the action, the request would arrive in the Controller with the correct ID of the selected form:option.

public String assignStaff(
 @ModelAttribute(ATTR_STAFF_POSITION) StaffAssignmentBean staffAssignment) {

However, when I inspected the console, there was an error: INVALID_CONFIDENTIAL_VALUE;/pmsys/project/assign/staff;staffID;27;[27, 28, 29, 30, 31, 32, 41];127.0.0.1;127.0.0.1;root

When I tried to trace the line of code which spits out the error: org.hdiv.filter.ValidatorHelperRequest:948

There was an inconsistency with the originalValue and the parameter value when this condition was evaluated: if (!m.matches() || (Integer.valueOf(value).intValue() >= stateValues.size())) {

originalValue = [27, 28, 29, 30, 31, 32, 41]

value = 27 (This is the ID number of the form:option which I selected in the JSP)

Does anyone have any solution to this problem? Could this be a bug in HDIV?

Note: This problem does not occur if I do not have a <c:forEach inside <form:select.

UPDATE: This is my hdiv configuration:

<!-- *********************************************************** -->
 <!-- *********************************************************** -->
 <!-- HDIV ****************************************************** -->
 <!-- *********************************************************** -->
 <!-- *********************************************************** -->
 <!-- HDIV Config -->
 <beans:bean id="hdivEditableValidator" class="org.hdiv.web.validator.EditableParameterValidator"/>
 <mvc:annotation-driven validator="hdivEditableValidator"/>
 
 <!-- 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>
 
 <hdiv:editableValidations>
  <hdiv:validationRule url=".*" enableDefaults="false">safeText</hdiv:validationRule>
 </hdiv:editableValidations>    
 
 <hdiv:config
  debugMode="true"
  errorPage="/fix"
  excludedExtensions="css,png,gif,jpeg,jpg,js,woff,woff2,map"
  randomName="true"
  strategy="cipher">
  <hdiv:sessionExpired loginPage="/auth/login" homePage="/"/>
  
  <!-- Controller calls that do not have validation -->
  <hdiv:startPages>/</hdiv:startPages>
  <hdiv:startPages method="get">/auth/denied,/fix,/,/auth/login,/auth/logout,/dashboard/,/image/display/project/profile/,/image/display/staff/profile/</hdiv:startPages>
  <hdiv:startPages method="post">/j_spring_security_check</hdiv:startPages>
 </hdiv:config>

The WEB.xML

 <!-- Replace JSTL tld with HDIV tld-->
 <jsp-config>
     <taglib>
         <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
         <taglib-location>/WEB-INF/tlds/hdiv-c.tld</taglib-location>
     </taglib>
 </jsp-config>
 
 <!-- HDIV Listener -->
 <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>
     <servlet-name>appServlet</servlet-name>
 </filter-mapping>

and VERSIONS

<hdiv-version>2.1.9</hdiv-version>

<org.springframework>4.1.6.RELEASE</org.springframework>

Vic Cebedo
  • 169
  • 1
  • 2
  • 7
  • You have Confidentiality activated (it is by default) so the value should be a relative number (0, 1, 2, 3...) and not the real value (27). Please share your config, hdiv-config.xml, filter conf in web.xml, hdiv, Spring version number... – gillarramendi Apr 18 '15 at 09:21
  • Hi @gillarramendi Thank you for the interest in solving my problem. I've already updated the post above for more details. Thanks! – Vic Cebedo Apr 20 '15 at 00:25
  • For future readers, follow the issue here: https://github.com/hdiv/hdiv/issues/77 – gillarramendi Apr 23 '15 at 09:46

0 Answers0