struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ajay Patil" <apa...@vertex.co.in>
Subject Re: Drop-Down List - Cannot Retrieve Definition From Form Bean Null
Date Tue, 02 Dec 2003 02:00:08 GMT
Hi Caroline,

The list should not be a session attribute.
Instead, you should declare member variables inside your Form bean
as follows..

public class EditorForm {
  String [] options;
  EditorBean editor;

  public String [] getOptions() {
    return options;
  }

  public EditorBean getEditor() {
    return this.editor;
  }
}

In your JSP page,

<html:select property="editor">
  <html:options property="options" />
</html:select>

Hope this helps you...

Ajay



My drop-down list got an error message:
org.apache.jasper.JasperException: Cannot retrieve
definition for form bean null

I have tried to display the drop-down list in two
ways:

First:
<html:select size="1" property="editor"
multiple="false">
<html:options collection="editors" property="name"
labelProperty="name"/>
</html:select>

Second:
<bean:define id="editorsList" name="editors"
scope="session" />
<html:select property="editor" size="1"
multiple="false">
<html:options collection="editorsList"
labelProperty="name" property="value"/>
</html:select> 

The editors is a Collection of EditorBean passed to
the JSP this way:
HttpSession session = request.getSession();
session.setAttribute( "editors", editors );

and Editor Bean is:
public class EditorBean 
{
   private String name;

   public EditorBean() {}

   public EditorBean( String name )
   {
      this.name = name;
   }
   public String getName() {
      return name;
   }
   public void setName( String name ) {
      this.name = name;
   }
} 




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message