1 package ru
.rentdom
.components
;
3 import java
.text
.DecimalFormat
;
4 import java
.text
.DecimalFormatSymbols
;
7 import org
.apache
.tapestry5
.annotations
.Parameter
;
8 import org
.apache
.tapestry5
.annotations
.Property
;
9 import org
.apache
.tapestry5
.ioc
.Messages
;
10 import org
.apache
.tapestry5
.ioc
.annotations
.Inject
;
12 import ru
.rentdom
.entities
.housing
.Housing
;
13 import ru
.rentdom
.services
.coords
.CoordsService
;
15 public class HousingList
{
16 private DecimalFormat priceFormat
=null;
18 @Parameter(required
=true, allowNull
=false)
19 @Property(write
=false)
20 private List
<Housing
> housings
;
23 private Housing housing
;
26 private CoordsService coordsService
;
29 private Messages messages
;
31 public boolean isEmptyList()
33 return housings
.size()==0;
36 public DecimalFormat
getPriceFormat()
38 if (priceFormat
==null)
40 DecimalFormatSymbols dfs
=new DecimalFormatSymbols();
41 dfs
.setGroupingSeparator(' ');
42 priceFormat
= new DecimalFormat("###,###", dfs
);
47 public String
getPrice()
49 return getPriceFormat().format(housing
.getPrice())+" "+housing
.getCurrency();
52 public String
getMetroOrDistrict()
54 if (coordsService
.hasMetro(housing
.getTown()))
55 return messages
.format("metro", housing
.getMetroStation().getName());
57 return messages
.format("distrinc", housing
.getDistrict().getName());