Cześć,
Nigdy wcześniej nie miałem do czynienia z apkami webowymi, czytam właśnie książkę "Java EE 6 przewodnik". Pobrałem NetBeans + GlassFish i zrobiłem prosty request -> response :
strona newjsf.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Testowa strona</title>
</h:head>
<h:body>
Witaj na testowej stronie<br/>
<h:form>
<h2> Super tajny tekst </h2>
Podaj tekst: <h:inputText id="superText" title="TajneHaslo" value="#{hello.text}" required="true" maxlength="40" />
<h:commandButton id="submit" value="Wyślij" action="response.xhtml"/>
</h:form>
</h:body>
</html>
strona response.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Response</title>
</h:head>
<h:body>
Odpowiedź od serwera: #{hello.resp} || #{hello.text}
<h:form>
<h:commandButton id="back" value="Wstecz" action="newjsf.xhtml"/>
</h:form>
</h:body>
</html>
Kod Hello.java
import javax.faces.bean.ManagedBean;
@ManagedBean
public class Hello {
private String text;
private String resp;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getResp() {
if(text != null) {
if(text.equals("SUPER_TAJNY_TEXT")) {
return "Brawo! Zgadłeś.";
}
else return "Nie zgadłeś";
}
else return "Text jest NULLem...";
}
}
Wszystko działa, tylko niepokoją mnie urle w przeglądarce mianowicie wstępny url:
http://localhost:8080/WebApplication1/faces/newjsf.xhtml
Pojawia się prawidłowa strona newjsf.xhtml
Po wpisaniu tekstu i naciśnięciu "wyślij" przechodzi mi na stronę z odpowiedzią (czyli jest wyświetlany response.xhtml)
ALE url nadal jest bez zmian a mianowicie http://localhost:8080/WebApplication1/faces/newjsf.xhtml !...
Natomiast po wciśnięciu przycisku wstecz wraca na stronę newjsf.xhtml a url jest http://localhost:8080/WebApplication1/faces/***response.xhtml*** (czyli wyświetla dobrze a url źle wskazuje?)
Jak naprawić, by urle były wyświetlane poprawnie