aspose file tools
The moose likes JSF and the fly likes window.location problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "window.location problem" Watch "window.location problem" New topic
Author

window.location problem

Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
I have a simple form in which if I click one button, I am supposed to go to other web page. I have used javascript function to this. I could do this with a normal html button where my page is not redirected if I use jsf command button. Why such discrepency? window.open is working where as window.location.href is nto working. Please let me know.
Anil Sadineni
Greenhorn

Joined: Feb 06, 2001
Posts: 20
Hi,

Can you post the code on what you trying to do?

Anil.
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<script type="text/javascript">
function function2() {
window.location.href = "http://www.mozilla.org";


}
</script>


<f:view>
<html>

<body>
<form id="myForm">
<h:panelGrid>
<h:commandButton value="checkStatus"
onclick
="function2()" />
</h:panelGrid>

</form>

</body>
</html>
</f:view>
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
This function works perfectly fine when I tried testing like below:


Why it is not working when i use onclick as below:


Anything wrong in using onclick from a JSF commandButton?
venkata swamymora
Ranch Hand

Joined: Aug 06, 2007
Posts: 33
Hi

You can use


or

[code]
window.location='yourPage.faces';
[code]

try this one.It will solve your problem

venkat
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
Thanks Venkat. I tried both, they are not working for me.
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
Script should be declared within the HEAD tag within the HTML tag

[code]
<html>
<head>
<script type="text/javascript">
function function2() {
window.location.href = "http://www.mozilla.org";


}
</script>
</head>
<body>
....
</body>
</html>


MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
yes, I have placed my javascript function within html head tag. STill wondering why it is nto working.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: window.location problem
 
Similar Threads
Cache and Session Management
Redirecting or Forwarding to another Portlet with Params
Back button disable not working
facing problem in cancel button functionality.
about using <META HTTP-EQUIV="pragma" CONTENT="no-cache">