1 25 26 package net.killingar.forum.actions.area; 27 28 import net.killingar.forum.internal.Area; 29 import net.killingar.forum.internal.IDItemImpl; 30 import net.killingar.forum.internal.Message; 31 import net.killingar.forum.internal.managers.AreaManager; 32 33 import java.util.ArrayList ; 34 import java.util.List ; 35 36 public class Search extends ActionAreaSupport 37 { 38 AreaManager areamgr; 39 List messages; 40 long areaID = -1; 41 Area area; 42 boolean subject = true; 43 boolean body = true; 44 String search; 45 46 public Area getArea() { return area; } 47 public boolean getBody() { return body; } 48 public List getMessages() { return messages; } 49 public String getSearch() { return search; } 50 public boolean getSubject() { return subject; } 51 52 public void setAreaID(String s) { areaID = Long.parseLong(s); } 53 public void setBody(boolean flag) { body = flag; } 54 public void setSearch(String s) { search = s; } 55 public void setSubject(boolean flag) { subject = flag; } 56 57 protected String doExecute() 58 { 59 try 60 { 61 if (search == null) 62 return "input"; 63 Message msgs[] = areamgr.search(search, ((IDItemImpl)(area)).ID, subject, body); 64 messages = new ArrayList (msgs.length); 65 for (int i = 0; i < msgs.length; i++) 66 messages.add(new MessageData(manager, msgs[i], false, false)); 67 68 return SUCCESS; 69 } 70 catch (Exception exception) 71 { 72 addErrorMessage("displaying search area page failed, exception thrown (" + exception.toString() + ")"); 73 exception.printStackTrace(); 74 return ERROR; 75 } 76 } 77 78 protected void doValidation() 79 { 80 if (areaID == -1) 81 addErrorMessage("no area specified"); 82 83 try 84 { 85 areamgr = (AreaManager)manager.getManager(AreaManager.class.getName()); 86 area = areamgr.getArea(areaID); 87 } 88 catch (Exception exception) 89 { 90 addErrorMessage("error getting area manager or area (" + exception.getMessage() + ")"); 91 exception.printStackTrace(); 92 } 93 if (area == null) 94 addErrorMessage("invalid area ID specified"); 95 } 96 } 97 | Popular Tags |