This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JSF and the fly likes form address inverse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "form address inverse" Watch "form address inverse" New topic
Author

form address inverse

tuntun zaw
Greenhorn

Joined: Oct 23, 2007
Posts: 4
Address inverse
My welcome file is welcome.faces redirected by index.html. When browser load welcome.faces, address bar show like �http://localhost/logo/welcome.faces�.When click the command buttom after filling text box, browser load success.faces. But address bar show �http://localhost/logo/welcome.faces�. When click command buttom in success.faces, browser load welcome.faces. But address bar show �http://localhost/logo/success.faces�. At this time, when click the command buttom in welcome.faces without no change in text box, address bar change from �http://localhost/logo/success.faces� to �http://localhost/logo/welcome.faces�.But form have no change.What is wrong?
My web service directory is apache tomcat.

Give me correct flow and why?
My email address is tunzaw2008@gmail.com.

Here is my code.
web.xml.
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

welcome.jsp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<html>
<head>
<title>Hello Welcome</title>
</head>
<body>
<f:view>
<h:form id="inputname">

<p>
<hutputText value="Enter name:"/>
</p>


<h:inputText value="#{namebean.username}" required="true">

</h:inputText>

<h:commandButton value="Submit" action="success"/>


</h:form>
</f:view>
</body>
</html>

success.jsp
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<html>
<head>
<title>Successful</title>
</head>
<body>
<f:view>
<h:form id="Successful">

<p>
<hutputText value="Hi "/>
<hutputText value="#{namebean.username}"/>
</p>

<h:commandButton value="Submit" action="welcome"/>
</h:form>
</f:view>
</body>
</html>
namebean.java

package jsfclasses;

public class namebean{
private String username;
private String r;

public void setUsername(String name){
this.username=name;
}

public String getUsername(){
return username;
}

}

faces-config.xml

<navigation-rule>
<from-view-id>/welcome.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/success.jsp</to-view-id>
</navigation-case>
</navigation-rule>

<navigation-rule>
<from-view-id>/success.jsp</from-view-id>
<navigation-case>
<from-outcome>welcome</from-outcome>
<to-view-id>/welcome.jsp</to-view-id>
</navigation-case>
</navigation-rule>

<managed-bean>
<managed-bean-name>namebean</managed-bean-name>
<managed-bean-class>jsfclasses.namebean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>

</managed-bean>
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16091
    
  21

A lot of people don't like the fact that the displayed URL in a JSF application doesn't track the actual pages. All JSF cares about is that the displayed page contains enough hidden information to keep the conversation flowing.

Actually, this is mostly a problem when you try and bookmark a page, since the context won't be there if you jump direct. People have been working on this.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
GeeCON Prague 2014
 
subject: form address inverse