Wednesday, October 28, 2009

STEP 15: Handle Button Actions

The Managed Beans must produce the correct form-outcomes, as defined in faces-config.xml, for each button click.

Update MyIcePortlet_view.java

Projects (tab) | Expand ICEfacesLiferay001 | Expand Source Packages | Expand my.icefaces.liferay.portlet | Double Click MyIcePortlet_view.java

Edit MyIcePortlet_view.java and add the two methods as shown in bold, below. Note that these method names are referenced in the action attributes of the the <ice:commandButton> tags in MyIcePortlet_view.jspx. Also note that the method return values match the <from-outcome> values specified in faces-config.xml. After makeing these changes, save the file.

package my.ice.faces.liferay.portlet;

public class MyIcePortlet_view {

    public MyIcePortlet_view() {
    }

    public String goToEdit() {
        return "edit";
    }

    public String goToHelp() {
        return "help";
    }
}


Update MyIcePortlet_edit.java

Projects (tab) | Expand ICEfacesLiferay001 | Expand Source Packages | Expand my.icefaces.liferay.portlet | Double Click MyIcePortlet_edit.java

Edit MyIcePortlet_view.java and add the two methods as shown in bold, below. Note that these method names are referenced in the action attributes of the the <ice:commandButton> tags in MyIcePortlet_edit.jspx. Also note that the method return values match the <from-outcome> values specified in faces-config.xml. After makeing these changes, save the file.

package my.ice.faces.liferay.portlet;

public class MyIcePortlet_edit {

    public MyIcePortlet_edit() {
    }

    public String goToView() {
        return "view";
    }

    public String goToHelp() {
        return "help";
    }
}


Update MyIcePortlet_help.java

Projects (tab) | Expand ICEfacesLiferay001 | Expand Source Packages | Expand my.icefaces.liferay.portlet | Double Click MyIcePortlet_help.java

Edit MyIcePortlet_view.java and add the two methods as shown in bold, below. Note that these method names are referenced in the action attributes of the the <ice:commandButton> tags in MyIcePortlet_help.jspx. Also note that the method return values match the <from-outcome> values specified in faces-config.xml. After makeing these changes, save the file.

package my.ice.faces.liferay.portlet;

public class MyIcePortlet_help {

    public MyIcePortlet_help() {
    }

    public String goToView() {
        return "view";
    }

    public String goToEdit() {
        return "edit";
    }
}

No comments:

Post a Comment