Search in sources :

Example 1 with PageCommand

use of org.apache.wiki.ui.PageCommand in project jspwiki by apache.

the class WikiContext method updateCommand.

/**
 * Protected method that updates the internally cached Command.
 * Will always be called when the page name, request context, or variable
 * changes.
 * @param requestContext the desired request context
 * @since 2.4
 */
protected void updateCommand(String requestContext) {
    if (requestContext == null) {
        m_command = PageCommand.NONE;
    } else {
        CommandResolver resolver = m_engine.getCommandResolver();
        m_command = resolver.findCommand(m_request, requestContext);
    }
    if (m_command instanceof PageCommand && m_page != null) {
        m_command = m_command.targetedCommand(m_page);
    }
}
Also used : PageCommand(org.apache.wiki.ui.PageCommand) CommandResolver(org.apache.wiki.ui.CommandResolver)

Example 2 with PageCommand

use of org.apache.wiki.ui.PageCommand in project jspwiki by apache.

the class WikiContext method findCommand.

/**
 * Looks up and returns a PageCommand based on a supplied WikiPage and HTTP
 * request. First, the appropriate Command is obtained by examining the HTTP
 * request; the default is {@link PageCommand#VIEW}. If the Command is a
 * PageCommand (and it should be, in most cases), a targeted Command is
 * created using the (non-<code>null</code>) WikiPage as target.
 * @param engine the wiki engine
 * @param request the HTTP request
 * @param page the wiki page
 * @return the correct command
 */
protected static Command findCommand(WikiEngine engine, HttpServletRequest request, WikiPage page) {
    String defaultContext = PageCommand.VIEW.getRequestContext();
    Command command = engine.getCommandResolver().findCommand(request, defaultContext);
    if (command instanceof PageCommand && page != null) {
        command = command.targetedCommand(page);
    }
    return command;
}
Also used : Command(org.apache.wiki.ui.Command) GroupCommand(org.apache.wiki.ui.GroupCommand) PageCommand(org.apache.wiki.ui.PageCommand) WikiCommand(org.apache.wiki.ui.WikiCommand) PageCommand(org.apache.wiki.ui.PageCommand)

Aggregations

PageCommand (org.apache.wiki.ui.PageCommand)2 Command (org.apache.wiki.ui.Command)1 CommandResolver (org.apache.wiki.ui.CommandResolver)1 GroupCommand (org.apache.wiki.ui.GroupCommand)1 WikiCommand (org.apache.wiki.ui.WikiCommand)1