1
votes

<h:commandButton action> is not working in following code snippest.

bean(Employee.java):-

        public String deleteEmployee(){
        return "success3";
            }

JSF page(delete-employee.xhtml):-

<h:form>
    <h:commandButton action="employee.deleteEmployee" type="submit" value="delete"/>
</h:form> 

Faces-config.xml:-

    <managed-bean>
      <description>Employee navigation</description>
      <managed-bean-name>employee</managed-bean-name>
      <managed-bean-class>erpJavaFiles.Employee</managed-bean-class>
      <managed-bean-scope>application</managed-bean-scope>
    </managed-bean>

<navigation-rule>
        <from-view-id>/add-Employee.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/CRM.xhtml</to-view-id>
            <redirect/>
        </navigation-case>
        <navigation-case>
            <from-outcome>failure</from-outcome>
            <to-view-id>/home.xhtml</to-view-id>
            <redirect/>
        </navigation-case>
    </navigation-rule>

    <navigation-rule>
        <from-view-id>/delete-employee.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success3</from-outcome>
            <to-view-id>/CRM.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>

Second navigation rule is not working but the first navigation rule is working. Thanks in advance.

1
Why are you still using the faces-config.xml approach? JSF 2.0 offers annotations for managed beans and implicit navigation. blogs.sun.com/rlubke/entry/faces_config_xml_we_don Anyway, the missing EL #{} in the action attribute is also a "typo", right?BalusC
V v v thanks BalusC.But ur provided link does not work, kindly send it again.Adnan
The page is down. In the meantime, see coreservlets.com/JSF-Tutorial/jsf2/index.html#Basics - all-around solid JSF tutorials.Matt Ball

1 Answers

1
votes

You misspelled employee in the <from-view-id>.

<from-view-id>/delete-employee.xhtml</from-view-id>