Hi there,

I tried to write a little ShoutBox jsp-Portlet. I don't know why, but it the Action 
doesn't work.

Here my Portlet Code:

======================================================
<%@ page import="java.sql.ResultSet"%>
<%@ page language="java" contentType="text/html; charset=iso-8859-1" session="true" %>

<%@ taglib uri='/WEB-INF/templates/jsp/tld/template.tld' prefix='jetspeed' %>
<jsp:useBean id="shoutBox" class="de.volke.jetspeed.modules.actions.ShoutBox" 
scope="request" />
<jsp:setProperty name="shoutBox" property="*" />


<%
    String jspeid = (String) request.getAttribute("js_peid");
%>
<table>
    <form name="shoutform" method="POST" action="<jetspeed:dynamicUri/>">
    <INPUT TYPE="hidden" NAME="js_peid" VALUE="<%=jspeid%>">
        <tr style="border-style:solid; border-color:#999999">
                <td>Shout</td><td>:</td>
                <td><input name="shout" type="TEXT" width="80" height="15"></td>
        </tr>
        <tr>
                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                <td align="center" colspan="2">
            <!--input type="hidden" name="action" value="portlets.ShoutBox"-->
            <INPUT TYPE="SUBMIT" NAME="eventSubmit_doUpdate" VALUE="Ok" 
style="width:60">
        </td>
        </tr>
    </form>
        <%
            //Show entries.
        String text;
        ResultSet rsshout = shoutBox.getShoutings();
        while(rsshout.next()){
            text = rsshout.getString("shouttext");
            out.println("<tr><td colspan='3'><hr>" + text + "</td></tr>");
        }

        try{
            rsshout.close();
            rsshout.getStatement().close();
            rsshout.getStatement().getConnection().close();
        }
        catch(Exception e){
            System.out.println("Schwerer Ausnahmefehler:");
            System.out.println(e);
    }
        %>
</table>

======================================================

the portlets.xreg entry:

======================================================

        <portlet-entry name="Shoutbox" hidden="false" type="ref" parent="JSP" 
application="false">
            <meta-info>
                <title>ShoutBox</title>
                <description>Schrei was das Zeug hält!</description>
        </meta-info>
            <parameter name="template" value="ShoutBox.jsp" hidden="false"/>
        <parameter name="action" value="portlets.ShoutBox" hidden="true" 
cachedOnName="true" cachedOnValue="true"/>
        <media-type ref="html"/>
        </portlet-entry>

======================================================

and the class:

======================================================

package de.volke.jetspeed.modules.actions;

import org.apache.jetspeed.modules.actions.portlets.JspPortletAction;
import org.apache.jetspeed.portal.Portlet;
import org.apache.turbine.util.RunData;

import java.sql.ResultSet;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.DriverManager;
import java.rmi.dgc.VMID;

/**
 * Created by Christoph Floßmann.
 */

public class ShoutBox extends JspPortletAction {

    String shout = "";

    public String getShout() {
        return shout;
    }

    public void setShout(String shout) {
        this.shout = shout;
    }

    public ResultSet getShoutings() throws Exception {

         //--Database Connect--
            Connection conn = null;
            Statement stmt = null;
            ResultSet rs = null;

            Class.forName("org.postgresql.Driver");

                String dbsource = "jdbc:postgresql://xxx/yyy";
                String dbuser = "xxx";
                String dbpassword = "xxx"; //If you want to try yourself edit the xxx 
and yyy entries
        conn = DriverManager.getConnection(dbsource, dbuser, dbpassword);
        stmt =  conn.createStatement();

                String sql = "SELECT " +
                                                "shouttext " +
                                         "FROM " +
                                                "portal.tbl_shoutbox " +
                                         "ORDER BY "+
                                                "date DESC, time DESC " +
                     "LIMIT 10";

        rs = stmt.executeQuery(sql);
        return rs;
    }

    protected void buildNormalContext(Portlet portlet, RunData rundata) throws 
Exception {

    }
    
    public void doUpdate(RunData rundata, Portlet portlet) throws Exception{

        System.out.println("Action is working!"); //just to test this thing!
    }
}

======================================================

Any suggestions?

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to