Re: how to get command name from Controller context?
Dan Finkelstein <[email protected]> Tue, 20 Dec 2005 16:22:48 -0800
| Newsgroups | gmane.comp.web.maverick.general |
|---|---|
| Message-ID | <[email protected]> |
here's what I use... I hope this helps,
Dan
/**
* retrieve the maverick command
*/
public String getCommand()
{
// - this technique was taken from Maverick's
Dispatcher.extractCommandName()
HttpServletRequest req = getCtx().getRequest();
String path =
(String)req.getAttribute("javax.servlet.include.servlet_path");
if(path == null)
path = req.getServletPath();
int firstChar = 0;
if(path.startsWith("/")) {
firstChar = 1;
}
int period = path.lastIndexOf(".");
String command = null;
if(period > 0) {
command = path.substring(firstChar, period);
}
return command;
}
At 01:32 PM 12/16/2005, uone wrote:
>How to get command name from Controller instance context?
>I'm looking for easy way to get command name.
>Of course I can parse url query from request, or find proper command
>programatically in maverick.xml using controller class name, but I think
>there is more elegant solution.
>Command calls controller, contexts are passed but I can't see any simple
>way to get command name from Controller instance.
>
>uone
>
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
>for problems? Stop! Download the new AJAX search engine that makes
>searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
>http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
>[INVALID FOOTER]
>
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
[INVALID FOOTER]