Skip to content

Instantly share code, notes, and snippets.

@mhautman
Created April 25, 2016 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhautman/e178fdcca46331e1f4932b1cd7074de7 to your computer and use it in GitHub Desktop.
Save mhautman/e178fdcca46331e1f4932b1cd7074de7 to your computer and use it in GitHub Desktop.
public class SearchStreet {
private static final Logger LOGGER = LoggerFactory.getLogger(SearchStreet.class);
@Inject
private AddressService addressService;
@Property
private String streetName;
@Property
private String zipCode;
@Property
private String municipalityCode;
@Property
private Street street;
@Property
private Set<Street> streets;
Object onSuccess() {
LOGGER.debug(String.format("Called SearchStreet with following parameters: %s %s %s", streetName, zipCode, municipalityCode));
Set<Street> streets = new HashSet<Street>();
if (zipCode != null && !zipCode.equals("")) {
List<Street> streetsByZip = addressService.getStreetsByZip(zipCode);
if (streetsByZip != null || !streetsByZip.isEmpty()) {
streets.addAll(streetsByZip);
}
}
if (municipalityCode != null && !municipalityCode.equals("")) {
List<Street> streetsByMunicipality = addressService.getStreetsByMunicipality(municipalityCode);
if (streetsByMunicipality != null || !streetsByMunicipality.isEmpty()) {
streets.addAll(streetsByMunicipality);
}
}
this.streets = streets;
return this;
}
}
<t:form>
<t:label for="streetName"/>:
<t:textfield t:id="streetName" />
<br/>
<t:label for="zipCode"/>:
<t:textfield t:id="zipCode" validate="regexp"/>
<br/>
<t:label for="municipalityCode"/>:
<t:textfield t:id="municipalityCode" validate="regexp"/>
<br/>
<t:submit t:id="search" value="Search"/>
<br/>
<t:grid source="streets" row="street">
</t:grid>
</t:form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment