jsf 2.1 navigation rule doesn't work

NoXiD

Bekanntes Mitglied
Hallo,
habe folgendes Problem:

login.xhtml
HTML:
<h:body>

	<p:fieldset legend="-User Authentication-" id="test"> 
		<h:panelGrid columns="2" cellpadding="10">   
       		<h:outputLabel for="username" value="Username:" />
       		<p:inputText id="username" value="#{userBean.username}"></p:inputText>
       		
       		<h:outputLabel for="password" value="Password:"/>
       		<p:password id="password" value="#{userBean.password}"></p:password>
       		
       		
       	</h:panelGrid>
       	<p:commandButton value="login" id="loginbutton" action="#{userBean.doLogin()}"></p:commandButton>
	</p:fieldset> 
	
</h:body>

die doLogin() Methode macht folgendes:
Code:
public String doLogin(){
		if(this.username.equalsIgnoreCase("admin") && this.password.equalsIgnoreCase("test")){
			return "success";
		}
		return "fail";
	}
und in der Faces Config habe ich die Navigation Rule definiert:
[XML] <navigation-rule>
<from-view-id>/login.xhtml</from-view-id>
<navigation-case>
<from-action>#{userBean.doLogin}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/index.xhtml</to-view-id>
</navigation-case>
</navigation-rule>[/XML]

Komischerweise funktioniert die Weiterleitung aber nicht, obwohl laut Debugger die Funktion doLogin() success zurückgibt...

stehe da grad ein wenig an... Danke für eure Hilfe!
 

geqoo

Bekanntes Mitglied
Mal probiert, vor login.xhtml das / wegzulassen?

Alternativ evtl. mal das return-Statement erweitern:

return "success?faces-redirect=true";
 
Zuletzt bearbeitet:

NoXiD

Bekanntes Mitglied
danke schon mal für die schnelle Antwort.

hab jetzt mal
Code:
success?faces-redirect=true
und das "/" vor login.xhtml entfernt, nachwievor das gleiche Problem :/

Ich weiß zwar das es in JSF 2.1 schon möglich ist die Seite direkt per return Statement aufzurufen (funktioniert auch), aber ich persönlich finde es mit Navigation Rules übersichtlicher.
 
Zuletzt bearbeitet:

JimPanse

Bekanntes Mitglied
Hi,

es fehlt die form:

[XML]

<h:body>
<h:form>
<p:fieldset legend="-User Authentication-" id="test">
<h:panelGrid columns="2" cellpadding="10">
<h:eek:utputLabel for="username" value="Username:" />
<p:inputText id="username" value="#{userBean.username}"></p:inputText>

<h:eek:utputLabel for="password" value="Password:"/>
<p:password id="password" value="#{userBean.password}"></p:password>


</h:panelGrid>
<p:commandButton value="login" id="loginbutton" action="#{userBean.doLogin()}"></p:commandButton>
</p:fieldset>
</h:form>
</h:body>
[/XML]
 

Ähnliche Java Themen

Neue Themen


Oben