} else if (st != null) { ZMailbox mailbox = getMailbox(); ZTag tag = mailbox.getTagById(st);
} else if (sti != null) { ZTag tag = mailbox.getTagById(sti);
    private void determineQuery(PageContext pageContext, SearchContext result, ServletRequest req) throws JspException {        String sq = req.getParameter(QP_SEARCH_QUERY);        String sf = req.getParameter(QP_SEARCH_FOLDER_ID);        String st = req.getParameter(QP_SEARCH_TAG_ID);        result.setSq(sq);        result.setSfi(sf);        result.setSti(st);        if (mTypes == null) {            if (mDefault.equals(TYPE_CONTACTS)) {                mTypes = ZSearchParams.TYPE_CONTACT;            } else {                mTypes = ZSearchParams.TYPE_CONVERSATION; // TODO: from pref, or based on view?            }        }        if (mSortBy == null) {            if (mDefault.equals(TYPE_CONTACTS)) {                mSortBy = ZMailbox.SearchSortBy.nameAsc;            } else {                mSortBy = ZMailbox.SearchSortBy.dateDesc;            }        }        // default to inbox/contacts        if (sq == null && st == null && sf == null) {            if (mDefault.equals(TYPE_CONTACTS)) {                sf = ZFolder.ID_CONTACTS;            } else {                sf = ZFolder.ID_INBOX;            }        }        if (sq != null) {            result.setTitle(sq);            result.setBackTo(LocaleSupport.getLocalizedMessage(pageContext, "backToSearch"));            result.setQuery(sq);            result.setShowMatches(true);            return;        } else if (sf != null) {            ZMailbox mailbox = getMailbox();            ZFolder folder = mailbox.getFolderById(sf);            if (folder != null) {                if (folder instanceof ZSearchFolder) {                    result.setQuery(((ZSearchFolder)folder).getQuery());                    result.setShowMatches(true);                    result.setBackTo(LocaleSupport.getLocalizedMessage(pageContext, "backToSearchFolder", new Object[] {folder.getName()}));                } else {                    result.setQuery("in:\"" + folder.getRootRelativePath() + "\"");                    result.setBackTo(LocaleSupport.getLocalizedMessage(pageContext, "backToFolder", new Object[] {folder.getName()}));                }                result.setFolder(new ZFolderBean(folder));                result.setTitle(folder.getName());                result.setSelectedId(folder.getId());                return;            }        } else if (st != null) {            ZMailbox mailbox = getMailbox();            ZTag tag = mailbox.getTagById(st);            if (tag != null) {                result.setQuery("tag:\"" + tag.getName() + "\"");                result.setTitle(tag.getName());                result.setBackTo(LocaleSupport.getLocalizedMessage(pageContext, "backToTag", new Object[] {tag.getName()}));                                                    result.setSelectedId(tag.getId());                result.setTag(new ZTagBean(tag));                                result.setShowMatches(true);                return;            }        }        throw new JspTagException("unable to determine query");    }