You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Elam Daly <el...@gmail.com> on 2006/04/28 21:01:44 UTC

MyFaces Portlets in JBoss Portal Server

Hi,

I am trying to write the simplest of portlets for JBoss Portal server 2.2.
The Page is being rendered okay, but it doesn't seem to be wired to my
backing beans.  The JBoss instructions on the JBoss site aren't very clear
on what to do so I'm wondering if there are other JBoss Portal users who
could glance over my files and see what I'm doing wrong.

One thing that's confusing to me, is that I have no jar files in my
WEB-INF/lib directory.  I realize JBoss uses Myfaces for its portal
components, but what If I want to use a new version of Myfaces?  Will
dropping newer jar's into my WEB-INF/lib directory interfere with the JBoss
Portal?

Thanks in advance.

Here's my files:

portlet.xml
---------------
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
/opt/SUNWps/dtd/portlet.xsd<http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd/opt/SUNWps/dtd/portlet.xsd>
"
             version="1.0">
    <portlet>
        <portlet-name>SimplePortlet</portlet-name>
        <display-name>SimpleNess</display-name>
        <portlet-class>org.apache.myfaces.portlet.MyFacesGenericPortlet
</portlet-class>
        <init-param>
            <name>default-view</name>
            <value>/simple.jsp</value>
        </init-param>
        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>VIEW</portlet-mode>
        </supports>
        <portlet-info>
            <title>Simple JBoss Portlet</title>
            <short-title>Simple</short-title>
        </portlet-info>
    </portlet>
</portlet-app>

web.xml
------------
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC
   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
   "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
   <listener>
      <listener-class>
org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
   </listener>
</web-app>

faces-config.xml
-----------------------
<?xml version='1.0' encoding='UTF-8'?>

<faces-config>
    <managed-bean-name>SimpleBean</managed-bean-name>
    <managed-bean-class>com.elam.SimpleBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
</faces-config>

simple-object.xml
------------------------
<?xml version="1.0" encoding="UTF-8"?>
<deployments>
    <deployment>
        <parent-ref>default</parent-ref>
        <properties/>
        <if-exists>overwrite</if-exists>
        <instance>
            <instance-name>SimplePortletInstance</instance-name>
            <component-ref>simple.SimplePortlet</component-ref>
        </instance>
    </deployment>
</deployments>

jboss-app.xml
--------------------
<?xml version="1.0" encoding="UTF-8"?>
<jboss-app>
    <app-name>simple</app-name>
</jboss-app>

simple.jsp
--------------
<HTML>
    <HEAD> <title>Hello</title> </HEAD>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <body bgcolor="white">
        <f:view>
            <h:form >
                <h:panelGrid columns="1">
                    <h:panelGrid columns="3">
                        <h:inputText value="#{SimpleBean.name}" />
                        <h:outputText value="You entered: "/><h:outputText
value="#{SimpleBean.name}" />
                        <h:outputText value="Hard Coded: "/><h:outputText
value="#{SimpleBean.name2}"/>
                    </h:panelGrid>
                    <h:commandButton value="Enter" action="#{
SimpleBean.process}"/>
                </h:panelGrid>
            </h:form>
        </f:view>
    </body>
</html>

SimpleBean.java
------------------------
package com.elam;

public class SimpleBean {

    private String _name;
    private String _name2 = "FRED";

    public void setName(String s) {
        _name = s;
    }

    public String getName() {
        return _name;
    }

    public String getName2() {
        return _name2;
    }

}