});
cmdPageBack.setParameter(outListName + "Page", String.valueOf(currentPage - 1));
cmdPageBack.setLabel("$back");
outList.setAttribute("cmdPageBack", cmdPageBack);
Output outPrevPages = response.createOutput("prevPages");
outList.setAttribute("prevPages", outPrevPages);
int firstPrevPage = Math.max(minPage, currentPage - context.getNumPrevPages());
for (int i = currentPage - 1; i >= firstPrevPage; --i)
{
Command cmdPage = createPageCommand(request, response, listing, "cmdPage", new String[]
{
"~listSort"
});
cmdPage.setParameter(outListName + "Page", String.valueOf(currentPage - i - 1 + firstPrevPage));
cmdPage.setLabel(String.valueOf(currentPage - i - 1 + firstPrevPage));
outPrevPages.add(cmdPage);
}
}
if (currentPage < maxPage)
{
Command cmdPageEnd = createPageCommand(request, response, listing, "cmdPageEnd", new String[]
{
"~listSort"
});
cmdPageEnd.setParameter(outListName + "Page", String.valueOf(maxPage));
cmdPageEnd.setLabel("$end");
outList.setAttribute("cmdPageEnd", cmdPageEnd);
Command cmdPageNext = createPageCommand(request, response, listing, "cmdPageNext", new String[]
{
"~listSort"
});
cmdPageNext.setParameter(outListName + "Page", String.valueOf(currentPage + 1));
cmdPageNext.setLabel("$next");
outList.setAttribute("cmdPageNext", cmdPageNext);
Output outNextPages = response.createOutput("nextPages");
outList.setAttribute("nextPages", outNextPages);
int lastNextPage = Math.min(maxPage, currentPage + context.getNumNextPages());
for (int i = currentPage + 1; i <= lastNextPage; ++i)
{
Command cmdPage = createPageCommand(request, response, listing, "page", new String[]
{
"~listSort"
});
cmdPage.setParameter(outListName + "Page", String.valueOf(i));
cmdPage.setLabel(String.valueOf(i));
outNextPages.add(cmdPage);
}
}
if (listing.getListCommands() != null)
{
Output outCommands = response.createOutput("commands");
outList.setAttribute("commands", outCommands);
for (Iterator i = listing.getListCommands().iterator(); i.hasNext();)
{
CommandInfo descriptor = (CommandInfo) i.next();
Command command = descriptor.createCommand(request, response, context);
outCommands.add(command);
}
}
if (listing.getItemCommands() != null)
{
Output outItemCommands = response.createOutput("itemCommands");
CommandInfo viewCmd = listing.getCommand(ListingDescriptor.COMMAND_VIEW);
if (viewCmd != null && viewCmd.checkPermission(request))
{
Command cmd = viewCmd.createCommand(request, response, context);
outItemCommands.add(cmd);
}
outItemCommands.setAttribute("label", listing.getItemCommands().getLabel());
outList.setAttribute("itemCommands", outItemCommands);
for (Iterator i = listing.getItemCommands().iterator(); i.hasNext();)
{
CommandInfo descriptor = (CommandInfo) i.next();
if (viewCmd == null || ! descriptor.getName().equals(viewCmd.getName()))
{
Command command = descriptor.createCommand(request, response, context);
outItemCommands.add(command);
}
}
Command cmdExecute;
if (listing.getCommand(ListingDescriptor.COMMAND_EXECUTE) == null)