Saturday, October 24, 2009

STEP 11: Create the Edit and Help Portlet Pages

We have created and tested the portlet's VIEW page. Now we will add the EDIT and HELP pages and test the poral server's navigation between these pages.


Create the Edit JSF Portlet Page

Projects (tab) | Expand ICEfacesLiferay001 | Right Click WebPages | New | JSF JSP Page...
  • JSP File Name: MyIcePortlet_edit

  • Project: ICEfacesLiferay001

  • Location: WebPages

  • Folder: (blank)

  • Created File: (automatically populated)

  • Options: JSP Document (XML Syntax)
Finish

A new file called MyIcePortlet_edit.jspx will be created. Replace the entire contents of this file with the following. Then save the new file.

<?xml version="1.0" encoding="UTF-8"?>
<f:view xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:ice="http://www.icesoft.com/icefaces/component">
    <html>

        <head>
            <title>EDIT: My ICEfaces Portlet</title>
        </head>

        <body>
            <ice:portlet>
                <ice:form id="iceform">

                    EDIT: Hello World ICEfaces Portlet

                </ice:form>
            </ice:portlet>
        </body>

    </html>
</f:view>


Create the Help JSF Portlet Page

Projects (tab) | Expand ICEfacesLiferay001 | Right Click WebPages | New | JSF JSP Page...
  • JSP File Name: MyIcePortlet_help

  • Project: ICEfacesLiferay001

  • Location: WebPages

  • Folder: (blank)

  • Created File: (automatically populated)

  • Options: JSP Document (XML Syntax)
Finish

A new file called MyIcePortlet_help.jspx will be created. Replace the entire contents of this file with the following. Then save the new file.

<?xml version="1.0" encoding="UTF-8"?>
<f:view xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:ice="http://www.icesoft.com/icefaces/component">
    <html>

        <head>
            <title>HELP: My ICEfaces Portlet</title>
        </head>

        <body>
            <ice:portlet>
                <ice:form id="iceform">

                    HELP: Hello World ICEfaces Portlet

                </ice:form>
            </ice:portlet>
        </body>

    </html>
</f:view>


Update portlet.xml

Projects (tab) | Expand ICEfacesLiferay001 | Expand Web Pages | Expand WEB-INF | Double Click portlet.xml

Edit portlet.xml and add the elements shown in bold, below. Then save the file.

<?xml version="1.0"?>

<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
             version="1.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">

    <portlet>

        <portlet-name>MyIcePortlet</portlet-name>
        <display-name>MyIcePortlet</display-name>
        <portlet-class>com.icesoft.faces.webapp.http.portlet.MainPortlet</portlet-class>

        <init-param>
            <name>com.icesoft.faces.portlet.viewPageURL</name>
            <value>/MyIcePortlet_view.iface</value>
        </init-param>

        <init-param>
            <name>com.icesoft.faces.portlet.editPageURL</name>
            <value>/MyIcePortlet_edit.iface</value>
        </init-param>

        <init-param>
            <name>com.icesoft.faces.portlet.helpPageURL</name>
            <value>/MyIcePortlet_help.iface</value>
        </init-param>

        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>VIEW</portlet-mode>

            <portlet-mode>EDIT</portlet-mode>
            <portlet-mode>HELP</portlet-mode>

        </supports>

        <portlet-info>
            <title>ICEfaces: MyIcePortlet</title>
            <short-title>MyIcePortlet</short-title>
            <keywords>ICEfaces My Ice Portlet</keywords>
        </portlet-info>
        
    </portlet>

</portlet-app>


Test

In NetBeans...
  • Click on the triangular green Run Main Project icon below the menu bar.

  • A browser window will automatically open. If the window does not open, go to http://localhost:8080/web/guest/ in your web browesr.

In the web browser...
  • Click on the Login as bruno link in the Current Users portlet.

  • Hover over Welcome Bruno Admin! at the top right.

  • Click Add Application.

  • The Add Application portlet will appear.

  • Click on ICEfaces Portlets in the The Add Application portlet to expand the node.

  • Click Add next to ICEfaces: MyIcePortlet.

  • The ICEfaces: MyIcePortlet will appear.

  • Click the (...) icon at the top right of the ICEfaces: MyIcePortlet portlet.

    • Select Preferences.

    • The EDIT page will appear.

    • Click the Return to Full Page link at the top right of the portlet.

    • The VIEW page will appear again.

  • Click the (...) icon at the top right of the ICEfaces: MyIcePortlet portlet.

    • Select Help.

    • The HELP page will appear.

    • Click the Return to Full Page link at the top right of the portlet.

    • The VIEW page will appear again.

In the web browser...
  • Confirm that the VIEW, EDIT, and HELP portlet pages are displayed.

  • Click the Remove (X) icon at the top right of the ICEfaces: MyIcePortlet portlet.

  • Are you sure you want to remove this component? OK

  • Hover over Welcome Bruno Admin! at the top right.

  • Click Sign Out.

In NetBeans...
  • On the Output panel, click the Stop Server (X) icon.

No comments:

Post a Comment