HornedToad
Programmer
Hi,
I am trying to pass a javabean class from the Java portlet file into the jsp file. Basically what is happening is that I want to set various cluster values in the JavaBean when the portlet is initialized in my portlet code and then have the jsp file retrieve those values and display them in a listbox.
It feels like the jsp and the portlet class are pointing at different instances of the ClusterBoxBean class but I don't know enough to fix the problem.
Currently the output of the javabean is either a "null" value in the listbox or an error if the name of my getMethod is getCluster() instead of getNextCluster(). Then instead of returning the value "null" it throws an error in the window. Similarly I tried to create just a dummy variable called value, set it inside the constructor and had a getValue() method try to call it in the jsp that also generated an error.
The final few error lines of the stack trace(from using getCluster() instead of getNextCluster() were as follows:
javax.portlet.PortletException at org.gridlab.gridsphere.portlet.jsrimpl.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:77) at org.gridlab.gridsphere.provider.portlet.jsr.ActionPortlet.doViewJSP(ActionPortlet.java:305) at org.gridlab.gridsphere.provider.portlet.jsr.ActionPortlet.doMode(ActionPortlet.java:362) at
etc.
Here's a little more code segment from what I am doing if it helps.
//Portlet Class:
//ClusterBean Class:
//nws.jsp
Thanks alot for any help you can offer.
HornedToad
I am trying to pass a javabean class from the Java portlet file into the jsp file. Basically what is happening is that I want to set various cluster values in the JavaBean when the portlet is initialized in my portlet code and then have the jsp file retrieve those values and display them in a listbox.
It feels like the jsp and the portlet class are pointing at different instances of the ClusterBoxBean class but I don't know enough to fix the problem.
Currently the output of the javabean is either a "null" value in the listbox or an error if the name of my getMethod is getCluster() instead of getNextCluster(). Then instead of returning the value "null" it throws an error in the window. Similarly I tried to create just a dummy variable called value, set it inside the constructor and had a getValue() method try to call it in the jsp that also generated an error.
The final few error lines of the stack trace(from using getCluster() instead of getNextCluster() were as follows:
javax.portlet.PortletException at org.gridlab.gridsphere.portlet.jsrimpl.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:77) at org.gridlab.gridsphere.provider.portlet.jsr.ActionPortlet.doViewJSP(ActionPortlet.java:305) at org.gridlab.gridsphere.provider.portlet.jsr.ActionPortlet.doMode(ActionPortlet.java:362) at
etc.
Here's a little more code segment from what I am doing if it helps.
//Portlet Class:
Code:
public class Nws extends ActionPortlet {
private String VIEW_PAGE = "nws.jsp";
public void init(PortletConfig config) throws PortletException {
super.init(config);
setupClusters();
DEFAULT_VIEW_PAGE = "prepare";
}
public void prepare(RenderFormEvent event) throws PortletException {
showForm(event.getRenderRequest());
setNextState(event.getRenderRequest(), VIEW_PAGE);
}
private void setupClusters() {
ClusterBoxBean clusterBean = ClusterBoxBean.getInstance();
clusterBean.addNextCluster("testCluster");
}
Code:
public class ClusterBoxBean {
private String [] cluster;
private static int MAX_CLUSTERS = 25;
private int currentClusterSize;
int value;
private static ClusterBoxBean ourInstance = new ClusterBoxBean();
public ClusterBoxBean() {
super();
this.cluster = new String[MAX_CLUSTERS];
this.currentClusterSize = 0;
this.value = 0;
}
public static ClusterBoxBean getInstance() {
return ourInstance;
}
public int getCurrentClusterSize() {
return currentClusterSize;
}
//test purposes only
public int getValue()
{
return value;
}
public String getNextCluster(int i) {
return cluster[i];
}
public void addNextCluster(String clusterName) {
//clusters[currentClusterSize] = clusterName;
cluster[0] = clusterName;
currentClusterSize++;
}
}
Code:
<%@ page import="org.gridlab.gridsphere.provider.portletui.beans.MessageStyle"%>
<%@ taglib uri="/portletUI" prefix="ui" %>
<%@ taglib uri="[URL unfurl="true"]http://java.sun.com/portlet"[/URL] prefix="portlet" %>
<jsp:useBean id="clusterBean" class="org.gridsphere.nws.portlets.ClusterBoxBean" scope="session"/>
<ui:form>
<ui:table cellpadding="4">
<ui:tablerow>
<ui:tablecell> <ui:text key="Cluster:"/> </ui:tablecell>
<ui:tablecell></ui:tablecell>
<ui:tablecell>
<ui:listbox beanId="clusterBox">
<ui:listboxitem value ="<%=clusterBean.getNextCluster(0)%>" selected = "true"/>
</ui:listbox>
</ui:tablecell>
</ui:tablerow>
Thanks alot for any help you can offer.
HornedToad