Skip to content

Commit

Permalink
Fix search typo #1131
Browse files Browse the repository at this point in the history
  • Loading branch information
syntrydy authored and yurem committed Aug 23, 2018
1 parent d0cc1de commit 5e815a7
Showing 1 changed file with 13 additions and 8 deletions.
Expand Up @@ -13,8 +13,6 @@
import javax.faces.application.FacesMessage;
import javax.inject.Inject;
import javax.inject.Named;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.gluu.jsf2.message.FacesMessages;
import org.gluu.jsf2.service.ConversationService;
Expand Down Expand Up @@ -46,36 +44,43 @@ public class SearchPersonAction implements Serializable {
@Inject
private ConversationService conversationService;

@NotNull
@Size(min = 2, max = 30, message = "Length of search string should be between 2 and 30")
private String searchPattern;

private String oldSearchPattern;

private boolean firstLaunch = false;

private List<GluuCustomPerson> personList;

@Inject
private IPersonService personService;

public String start() {
firstLaunch = true;
return search();
}

public String search() {
if (!firstLaunch && (this.searchPattern.isEmpty() || this.searchPattern.length() < 2)) {
firstLaunch = false;
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Length of search string should be between 2 and 30");
return OxTrustConstants.RESULT_SUCCESS;
}
if (Util.equals(this.oldSearchPattern, this.searchPattern)) {
firstLaunch = false;
return OxTrustConstants.RESULT_SUCCESS;
}

try {
this.personList = personService.searchPersons(this.searchPattern);
this.oldSearchPattern = this.searchPattern;
this.searchPattern="";
this.searchPattern = "";
firstLaunch = false;
} catch (Exception ex) {
log.error("Failed to find persons", ex);

facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to find persons");
conversationService.endConversation();

firstLaunch = false;
return OxTrustConstants.RESULT_FAILURE;
}

Expand Down

0 comments on commit 5e815a7

Please sign in to comment.