Methods Summary |
---|
public int | doStartTag()Take the provided search parameters, translate them into a search
against the person database. Populate a page variable with a
collection of the people found, represented as Person beans.
mLog.info("doStartTag invoked");
// List of people found
Person[] people = new Person[0];
ArrayList pList = new ArrayList();
String error = null;
// Convert the tag's attributes into a set of SearchArgs
SearchArg[] sargs = new SearchArg[3];
sargs[0] = new SearchArg();
sargs[0].setName(PersonDAO.FIRST_NAME);
sargs[0].setValue(this.getFirstNamePattern());
sargs[1] = new SearchArg();
sargs[1].setName(PersonDAO.LAST_NAME);
sargs[1].setValue(this.getLastNamePattern());
sargs[2] = new SearchArg();
sargs[2].setName(PersonDAO.EMAIL);
sargs[2].setValue(this.getEmailPattern());
// Get the PeopleFinder EJB home
try {
Context ctx = new InitialContext();
Object ref = ctx.lookup("ejb/ant-PeopleFinderLocal");
PeopleFinderLocalHome home =
(PeopleFinderLocalHome)PortableRemoteObject.narrow(ref, PeopleFinderLocalHome.class);
PeopleFinderLocal finder = home.create();
people = finder.findPeople(sargs);
// Add the people to our list
for (int i = 0; i < people.length; i++) {
pList.add(people[i]);
}
}
catch (NamingException ne) {
error = "Failed to locate/access EJB component: " + ne.getMessage();
mLog.severe(error);
}
catch (CreateException ce) {
error = "Failed to create EJB component: " + ce.getMessage();
mLog.severe(error);
}
catch (InvalidSearchException ise) {
error = "Search parameters were invalid: " + ise.getMessage();
mLog.severe(error);
}
catch (PersistenceException pe) {
error = "Persistence error during search: " + pe.getMessage();
mLog.severe(error);
}
// Set the page variable (if the search failed, it will be empty)
this.pageContext.setAttribute(getVarName(), pList,
PageContext.SESSION_SCOPE);
// Set the error page variable if there is an error.
if (error != null) {
this.pageContext.setAttribute(getVarName() + "-error", error,
PageContext.REQUEST_SCOPE);
}
return Tag.SKIP_BODY;
|
public java.lang.String | getEmailPattern()Get the search pattern for email
return mEmailPattern;
|
public java.lang.String | getFirstNamePattern()Get the search pattern for first name
return mFirstNamePattern;
|
public java.lang.String | getLastNamePattern()Get the search pattern for last name
return mLastNamePattern;
|
public java.lang.String | getVarName()Get the name of the page variable for the results
return mVarName;
|
public boolean | hasEmailPattern()Predicate, to detemine whether an email pattern has been set
return (this.getEmailPattern() != null &&
this.getEmailPattern().length() > 0);
|
public boolean | hasFirstNamePattern()Predicate, to detemine whether a first name pattern has been set
return (this.getFirstNamePattern() != null &&
this.getFirstNamePattern().length() > 0);
|
public boolean | hasLastNamePattern()Predicate, to detemine whether a last name pattern has been set
return (this.getLastNamePattern() != null &&
this.getLastNamePattern().length() > 0);
|
public void | setEmailPattern(java.lang.String mEmailPattern)Set the search pattern for email
this.mEmailPattern = mEmailPattern;
|
public void | setFirstNamePattern(java.lang.String mFirstNamePattern)Set the search pattern for first name
this.mFirstNamePattern = mFirstNamePattern;
|
public void | setLastNamePattern(java.lang.String mLastNamePattern)Set the search pattern for last name
this.mLastNamePattern = mLastNamePattern;
|
public void | setVarName(java.lang.String mVarName)Set the name of the page variable for the results
this.mVarName = mVarName;
|