Skip to content

Commit

Permalink
ESPD-124 #16 bugfix for empty list of representatives
Browse files Browse the repository at this point in the history
  • Loading branch information
dg-grow-alexey-lukashov committed Aug 30, 2016
1 parent 0ade3e5 commit f8109a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

Expand Down Expand Up @@ -89,11 +87,7 @@ class EspdController {

@ModelAttribute("espd")
public EspdDocument newDocument() {
EspdDocument espd = new EspdDocument();
espd.setEconomicOperator(new EconomicOperatorImpl());
espd.getEconomicOperator().setRepresentatives(new ArrayList<EconomicOperatorRepresentative>());
espd.getEconomicOperator().getRepresentatives().add(new EconomicOperatorRepresentative());
return espd;
return new EspdDocument();
}

@RequestMapping("/")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<%@page import="java.util.ArrayList"%>
<%@page import="eu.europa.ec.grow.espd.domain.EconomicOperatorImpl"%>
<%@page import="eu.europa.ec.grow.espd.domain.EconomicOperatorRepresentative"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="eu.europa.ec.grow.espd.domain.EspdDocument"%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
Expand Down Expand Up @@ -70,6 +76,20 @@
<tiles:putAttribute name="flow" value="${flow}"/>
<tiles:putAttribute name="procedure" value="true"/>
</tiles:insertDefinition>

<%
// Add at least one EconomicOperatorRepresentative to be sure user will see it in form
EspdDocument espd = (EspdDocument)request.getAttribute("espd");
if (espd != null) {
if (espd.getEconomicOperator() == null) {
espd.setEconomicOperator(new EconomicOperatorImpl());
}
if (CollectionUtils.isEmpty(espd.getEconomicOperator().getRepresentatives())) {
espd.getEconomicOperator().setRepresentatives(new ArrayList<EconomicOperatorRepresentative>());
espd.getEconomicOperator().getRepresentatives().add(new EconomicOperatorRepresentative());
}
}
%>

<%@ include file="/WEB-INF/views/wizard/procedureForm.jsp" %>

Expand Down

0 comments on commit f8109a0

Please sign in to comment.