// look for outer iterate tag
IterateTag iterateTag = (IterateTag) findAncestorWithClass(this, IterateTag.class);
if (iterateTag == null) {
// This tag should only be nested in an iterate tag
// If it's not, throw exception
JspException e = new JspException(messages.getMessage("indexed.noEnclosingIterate"));
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
// calculate index, and add as a parameter
if (params == null) {
params = new HashMap(); // create new HashMap if no other params
}
if (indexId != null) {
params.put(indexId, Integer.toString(iterateTag.getIndex()));
} else {
params.put("index", Integer.toString(iterateTag.getIndex()));
}
}
// get the pager object
Pager pager = (Pager) TagUtils.getInstance().lookup(pageContext, pagerName, pagerProperty, scope);
if (pager != null) {
if (params == null) {
params = new HashMap(); // create new HashMap if no other params
}
String name = pager.getModel().getId() + "." + pager.getModel().getColumnName(columnIndex);
// NOTE - These are now stored in the session anyway - BPS
params.put("pageSize", String.valueOf(pager.getPageSize()));
params.put("startRow", String.valueOf(pager.getStartRow()));
params.put("sortName", name);
params.put("sortReverse", name.equals(pager.getModel().getId() + "." + pager.getSortName()) ? String.valueOf(!pager.getSortReverse()) : "false");
}
if (subForm != null)
params.put("subForm", subForm);
if(attributesName != null) {
StringTokenizer t = new StringTokenizer(attributesProperties, ",");
while (t.hasMoreTokens()) {
String attr = t.nextToken();
try {
params.put(attr, TagUtils.getInstance().lookup(pageContext, attributesName, attr, scope).toString());
} catch (Exception e) {
}
}
}
String newPage = page;
FormTag formTag = (FormTag)CoreUtil.getParentTagOfClass(FormTag.class, this);
if(forward == null && newPage == null && action == null && href == null &&
formTag != null) {
newPage = formTag.getAction();
}
String url = null;
try {
url = TagUtils.getInstance().computeURLWithCharEncoding(pageContext, forward, href, newPage, action, module, params,
anchor, false, useLocalEncoding);
} catch (MalformedURLException e) {
TagUtils.getInstance().saveException(pageContext, e);
throw new JspException(messages.getMessage("rewrite.url", e.toString()));
}
return (url);
}