File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Java Products and Servers and the fly likes FrontMan dispatch to do a GET on a page/command? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "FrontMan dispatch to do a GET on a page/command?" Watch "FrontMan dispatch to do a GET on a page/command?" New topic
Author

FrontMan dispatch to do a GET on a page/command?

Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4655
    
    5

OK, I now know that I don't grok the difference between "forwardToView" and "forwardToCommand" and how that ties into the GET or POST commands.
I've read Bear's javadocs, and the JEE javadocs, and I don't get it.

I've got a nice Bean that declares:

@FrontmanCommand("avatarload")

at the end of its execute() function, I want to cause a GET on the page foo.jsp.
Neither forwardToCommand() nor forwardToView() does what I want, and I don't see how the redirectTo* would do better.

Enlightenment? or pointeres? greatly appreciated.

Thanks
Pat
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61203
    
  66

What you want is the redirect. A forward simply forwards the current request to another resource. A redirect mandates that the browser issue another request -- your GET.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4655
    
    5

Bear Bibeault wrote:What you want is the redirect.


This seems to partly be the answer. From the FrontMan javadocs, it appears that
ctx.redirectToView("foo");
and
ctx.redirect("foo");
are the same, with the former just a conveniece wrapper to the latter. But I get different results.
Specifically, the latter works great. The first version throws an exception:

StandardWrapperValve[CommandBroker]: PWC1406: Servlet.service() for servlet CommandBroker threw exception
org.bibeault.frontman.ViewNotFoundException: View with name of foo not found
at org.bibeault.frontman.CommandBroker.findViewPath(CommandBroker.java:341)
at org.bibeault.frontman.CommandContextImplementation.makeViewURL(CommandContextImplementation.java:363)


So they clearly are not the same. What's the real difference? Why does one work and the other complain?

Thanks
Pat

p.s. there is a typo in the javadocs for "JavascriptStringEncoder"
it says "sue" when it should say "use"
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61203
    
  66

redirect() redirects to the URl that you pass to it.

redirectToView() constructs a URL to the specified view (as a convenience) and then redirects to it. In your example, it will construct a redirect to foo.jsp in the folder that you specified as the views root in the init config.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4655
    
    5

I'm not getting this.

ctx.redirectToView("foo");

fails terribly

and
ctx.redirect("foo");

works perfectly. No need to move the foo.jsp file, or change anything.

I would expect them both to fail or both to work. But I'm not seeing this.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61203
    
  66

I'm actually surprised that the vanilla redirect works with that parameter. What exactly are you trying to redirect to?
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4655
    
    5

Bear Bibeault wrote:I'm actually surprised that the vanilla redirect works with that parameter. What exactly are you trying to redirect to?


a simple JSP. I was using forwardToView, but it wasn't doing the GET, which led me to the initial posting in this thread.
It worked at one level using forwardToView, but was just finishing the initial request GET/POST. and I really want a new request.

Actually, I really would rather not clank out to the browser, but if that's what it takes, OK.

Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4655
    
    5

Any ideas on how to debug this?
 
wood burning stoves
 
subject: FrontMan dispatch to do a GET on a page/command?