操作被触发后不会导航到另一个页面

时间:2013-09-16 16:56:58

标签: jsf navigation faces-config

我使用jsf页面在eclpise ide中创建了web项目。我已经为导航规则配置了faces-config.xml。检查inputet用户名和密码后页面仍然相同。我使用的是tomcat版本7.

my faces-config.xml

<managed-bean>
    <managed-bean-name>loginAdmin</managed-bean-name>
    <managed-bean-class>logovanje.LoginAdmin</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
</managed-bean>

<navigation-rule>
    <description>Loging Admin</description>
    <from-view-id>/loginAdmin.jsp</from-view-id>
    <navigation-case>
        <from-action>#{loginAdmin.proveraSifreAdmina}</from-action>
        <from-outcome>valid</from-outcome>
        <to-view-id>/adminPage.jsp</to-view-id>
    </navigation-case>
    <navigation-case>
        <from-action>#{loginAdmin.proveraSifreAdmina}</from-action>
        <from-outcome>invalid</from-outcome>
        <to-view-id>/loginUser.jsp</to-view-id>
    </navigation-case>
</navigation-rule>

</faces-config>

和我调用loginAdmin.proveraSifreAdmina

的jsf文件
<f:view>

<h:form id="loginAdmin">
    <h:outputText value="Administrator: " />
    <h:inputText id="adminName" value="#{loginAdmin.adminName }"  required="true"/>
    <h:message for="adminName" id="adminNamePoruka" />
    <br>
    <h:outputText value="Sifra: " />
    <h:inputSecret id="password" value="#{loginAdmin.password }"  required="true"/>
    <h:message for="password" id="passwordPoruka"/>
    <br>
    <h:commandButton type="submit" value="Prijava" action="#{loginAdmin.proveraSifreAdmina }" />
    <h:commandButton value="resetuj" type="reset" />

</h:form>

</f:view>

在我班上我正在返回String

public String proveraSifreAdmina() {

    getAdmin(adminName);
    System.out.println("ide");
    if(adminName.equals(dbadminName) && password.equals(dbpass)) {
        System.out.println("Saslje");
        return "valid";
    } else {
        System.out.println("isto salje");
        return "invalid";

    }
}

0 个答案:

没有答案