Introduction

The Struts-Layout datagrid framework allow to easily display a list of objects and modify them. The datagrid features are:

  • lines editing,
  • addition of new lines without server request,
  • single / multiple line selection,
  • modification of the state of the selected lines
  • association of a css class to each possible state
  • initialization of the selected lines and states with the datagrid Java API
  • Java API allowing to get the modified lines, the added lines, the removed lines and the lines with a specific state
  • Works with any object class (BeanUtils is used)

Creating a datagrid

Here are the required steps to create a datagrid:

  • A Struts form bean must be defined
  • A property of type fr.improve.struts.taglib.layout.datagrid.Datagrid must be added to the Struts form
  • A Struts Action must be created to define the datagrid. The action must be associated with the previous form, and the form must be putted in the session scope
  • The Struts action must initialize the datagrid form property to a new Datagrid object
  • The object list and type must be set to the Datagrid object
  • The jsp file displaying the datagrid must use the defined Struts form bean
  • The tag <layout:datagrid> must be used to display the datagrid. This tag must be nested in a <layout:from> or a <html:form> tag
  • The tag <layout:datagridColumn> must be used to specify the different columns of the datagrid. This tag must be nested in the <layout:datagrid> tag

Next : creating the form bean and the Struts action.