Skip to content

Commit

Permalink
Workaround for "Jackson can't handle generic list" issue!
Browse files Browse the repository at this point in the history
  • Loading branch information
azzazzel committed Mar 15, 2015
1 parent 426312a commit 7f2316d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
16 changes: 16 additions & 0 deletions dukes-domain-model/src/main/java/com/forest/model/ProductList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.forest.model;

import java.util.LinkedList;
import java.util.List;

public class ProductList extends LinkedList<Product> {


private static final long serialVersionUID = 5038778844017547797L;

public static ProductList fromList (List<Product> list) {
ProductList result = new ProductList();
result.addAll(list);
return result;
}
}
3 changes: 2 additions & 1 deletion portlet/catalog-portlet/src/main/resources/view.jsp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

<%@page import="com.forest.model.ProductList"%>
<%@ include file="/init.jsp" %>

<%
ProductManager pm = (ProductManager)request.getAttribute("productManager");
List<Product> products = pm.getAll();
ProductList products = pm.getAsProductList();
%>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

import com.forest.model.Product;
import com.forest.model.ProductList;
import com.forest.usecase.catalog.persistence.ProductPersistence;

public abstract class AbstractBaseProductManager implements ProductManager {
Expand Down Expand Up @@ -74,4 +75,7 @@ public List<Product> getAllInRange (int... range) {
return getProductPersistence().findRange(range);
}

public ProductList getAsProductList () {
return ProductList.fromList(getAll());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

import com.forest.model.Product;
import com.forest.model.ProductList;

public interface ProductManager {

Expand All @@ -22,5 +23,7 @@ public abstract List<Product> getProductsInCategory(int categoryId,
public abstract List<Product> getAll();

public abstract List<Product> getAllInRange(int... range);

public ProductList getAsProductList ();

}

0 comments on commit 7f2316d

Please sign in to comment.