• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

providing navigation without clicking a button

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In my project I have now come across a fuctionality
where I need to provide navigation without actually pressing a button.

I need to trigger a new ActionEvent object. But I don't know the code to provide page navigation without pressing the button.

Pls help ...............!!
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For submitting form/page, you need to perform some action, you want to submit form at which point.
 
Dushyant Agarwal
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please be more specific???

My problem is - I want to launch navigation at a point from a function with void return type
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can fire a tequest to a url from your JS function. There are some points ...

1. If your present page is test.faces then submit to the same url, ie. /root_path/.../test.faces
2. JSF uses some hidden fields to keep track from which view the request is coming from and uses this to decide the next navigation. You need to read these hidden fields and other form item parameters to the request url.

Happy success.
 
Dushyant Agarwal
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You might as well want to know that I am not intended to use javaScript (js- satnds for JavaScript... right??) in provididng this navigation.
I have Already acquired navigation using JavaScript. But Iam looking for a solution without JavaScript.

The reason behind this is that JavaScript does not behave Uniformly on all type of browsers.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dushyant Agarwal:
Hi,
You might as well want to know that I am not intended to use javaScript (js- satnds for JavaScript... right??) in provididng this navigation.
I have Already acquired navigation using JavaScript. But Iam looking for a solution without JavaScript.

The reason behind this is that JavaScript does not behave Uniformly on all type of browsers.



Hi,

I don't see any problem working with javascript. for that matter JSF completely uses javascript to send meta info to server for actions/events. Isn't it?

Anil.
 
Dushyant Agarwal
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for the reply.
However, I myself have never encountered any problem using JavaScript in JSF.
But my tech support has that mindset. They give me the same reason (that I have given here for not using javascript) when I ask them the question. And it wants me to avoid java script as far as possible. And stick to JSF all the way.
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is some code to navigate:

 
Dushyant Agarwal
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks fro the reply.

However I have already tried out this procedure but it was not able to provide navigation. As well as no exception came along.

Please let me know of any other suggestion!!
 
Dushyant Agarwal
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks fro the reply.

However I have already tried out this procedure but it was not able to provide navigation. As well as no exception came along.

Please let me know of any other suggestion!!
 
Bob Good
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The above has worked for me before...however, try this instead:

[ January 30, 2008: Message edited by: Bob Good ]
 
Saloon Keeper
Posts: 27489
195
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, let's make one thing perfectly clear. a JSF web application runs via HTTP. HTTP is a Request/Response protocol. A server cannot initiate actions nor can server applications. They can only react to requests. No request, no response. So something has to "click the button", even for AJAX apps. All AJAX is is an HTTP request embedded within a displayed page.

So, to remove any doubt: ANY JSF code running in a backing bean is doing so because someone made a request. That request may or may not have included an action request, but it was a request nevertheless. An since there's no particular penalty for action requests, you might as well use an action request anyway.

Now whether or not you use a "button" object is somewhat optional - JSF has 2 core action elements: commandLink and commandButton. The commandLink element renders as a hyperlink and the commandButton renders as a pushbutton. Unless, of course, you get creative with CSS, in which case it's largely up to you what it's going to look like.

I'd say that the #1 problem people have designing webapps is in understanding that they're not full-bore client/server systems, and it doesn't help that people carelessly throw around the term "MVC". True MVC is impossible over HTTP, since it requires the controller to be able to asynchronously post model updates to the client, and HTTP can only update when it's responding to requests.

Struts made the distinction by using the term "Model 2" architecture, but JSF usually just calls it MVC. And to make things worse, JSF is about as close to true MVC as HTTP can get, so that just makes it more confusing.
 
Bob Good
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well he must already be in server side code because he says


My problem is - I want to launch navigation at a point from a function with void return type


So since he is in a function with a void return type, must be in action listener ot value change listener or something (perhaps with immediate property)...These will make function call to server side code with void return value, unlike action methods which return a String indicating where to navigate to (in the standard fashion).

Here is real tested code that reacts to a value change listener on a checkbox with immediate property and successfully navigates to a new page:



So we have navigation from a function with a void return parameter reacting to a checkbox changing.
 
The only thing that kept the leeches off of me was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic