aspose file tools*
The moose likes JSF and the fly likes providing navigation without clicking a button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "providing navigation without clicking a button" Watch "providing navigation without clicking a button" New topic
Author

providing navigation without clicking a button

Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
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 ...............!!
Ram Chhabra
Ranch Hand

Joined: Jan 07, 2008
Posts: 48
For submitting form/page, you need to perform some action, you want to submit form at which point.
Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
Could you please be more specific???

My problem is - I want to launch navigation at a point from a function with void return type
Kaustabh Singha Roy
Ranch Hand

Joined: Oct 04, 2005
Posts: 43
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

Joined: Oct 14, 2007
Posts: 75
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.
Anil Sadineni
Greenhorn

Joined: Feb 06, 2001
Posts: 20
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

Joined: Oct 14, 2007
Posts: 75
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.
Bob Good
Ranch Hand

Joined: Jan 09, 2008
Posts: 86
Here is some code to navigate:

Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
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

Joined: Oct 14, 2007
Posts: 75
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

Joined: Jan 09, 2008
Posts: 86
The above has worked for me before...however, try this instead:

[ January 30, 2008: Message edited by: Bob Good ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16070
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Bob Good
Ranch Hand

Joined: Jan 09, 2008
Posts: 86
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: providing navigation without clicking a button