• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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

 
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 67275
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pat Farrell
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Marshal
Posts: 67275
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 67275
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm actually surprised that the vanilla redirect works with that parameter. What exactly are you trying to redirect to?
 
Pat Farrell
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any ideas on how to debug this?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!