org.barracudamvc.contrib.sam.models
Class IterativeResultSetModel

java.lang.Object
  extended byorg.barracudamvc.core.comp.AbstractTemplateModel
      extended byorg.barracudamvc.core.comp.AbstractIterativeTemplateModel
          extended byorg.barracudamvc.contrib.sam.models.IterativeResultSetModel
All Implemented Interfaces:
Contextual, IterativeModel, Model, TemplateModel

public class IterativeResultSetModel
extends AbstractIterativeTemplateModel

A specific ListModel implementation for java.sql.ResultSets. To use this class, simply pass a ResultSet to the constructor, the model iterates over all rows of the underlying SQL query. A sample HTML fragment might look like

Username Password
abc abc

Version:
$Id: IterativeResultSetModel.java,v 1.3 2004/08/14 18:14:14 jkjome Exp $
Author:
Stefan Armbruster

Field Summary
protected static org.apache.log4j.Logger logger
           
protected  String name
          name of the model
protected  ResultSet resultSet
          ResultSet representing the SQL query
 
Fields inherited from class org.barracudamvc.core.comp.AbstractTemplateModel
listeners, UNDEFINED, viewContext
 
Constructor Summary
IterativeResultSetModel(String name, ResultSet rs)
          initialize the model
 
Method Summary
 Object getItem(String key)
          get the model's value for a specific key
 String getName()
          get the name of the model
 boolean hasNext()
          returns resultSet.next()
 void loadNext()
          empty implementation, does nothing.
 void setName(String name)
          set the name of the model
 
Methods inherited from class org.barracudamvc.core.comp.AbstractIterativeTemplateModel
postIterate, preIterate
 
Methods inherited from class org.barracudamvc.core.comp.AbstractTemplateModel
addModelListener, fireModelChanged, getItem, getViewContext, processDirective, removeModelListener, setViewContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.apache.log4j.Logger logger

resultSet

protected ResultSet resultSet
ResultSet representing the SQL query


name

protected String name
name of the model

Constructor Detail

IterativeResultSetModel

public IterativeResultSetModel(String name,
                               ResultSet rs)
initialize the model

Parameters:
name - Name of the model
rs - ResultSet to iterate
Method Detail

getName

public String getName()
get the name of the model

Returns:
name of the model

setName

public void setName(String name)
set the name of the model

Parameters:
name - name of the model

hasNext

public boolean hasNext()
returns resultSet.next()

Specified by:
hasNext in interface IterativeModel
Specified by:
hasNext in class AbstractIterativeTemplateModel
Returns:
resultSet.next()

getItem

public Object getItem(String key)
get the model's value for a specific key

Overrides:
getItem in class AbstractTemplateModel
Parameters:
key - must match the columns of the SQL query
Returns:
result of ResultSet's getString(colname)

loadNext

public void loadNext()
empty implementation, does nothing. Only reason for being here is to fully implement IterativeModel.

Specified by:
loadNext in interface IterativeModel
Specified by:
loadNext in class AbstractIterativeTemplateModel


Copyright © 2004 BarracudaMVC.org All Rights Reserved.