org.formaria.data.pojo
Class PersistentListHelper

java.lang.Object
  extended by org.formaria.data.pojo.PersistentListHelper

public class PersistentListHelper
extends java.lang.Object

Helps to handle a List selection while working with POJO model.

Copyright (c) Formaria Ltd., 2008
License: see license.txt


Constructor Summary
PersistentListHelper(ListHolder lh, PageSupport ps)
          Creates a new instance of PersistentListHelper
PersistentListHelper(ListHolder lh, PageSupport ps, PersistentPojoModel sm)
          Creates a new instance of PersistentListHelper
PersistentListHelper(ListHolder lh, PageSupport ps, java.lang.String outputPath)
          Creates a new instance of PersisentListHelper
 
Method Summary
 void clearSelection()
          Removes the selection from the underlying list holder
 void clearSelectionModel()
          Removes the reference to the underlying POJO from the selection model.
 void deleteSelectedPojo()
          Removes the POJO being stored in the selection model from the persistent context.
 PersistentPojoModel getListSelectedModel()
          Gets the selected element on the list
 java.lang.Object getSelectedPojo()
          Gets the POJO of the selected model node, if the selection model has been set the its underlying POJO is returned, otherwise the POJO on the underlying list is returned.
 PersistentPojoModel getSelectionModel()
          Gets the selection model
 void mergeSelectedPojo()
          Merges the selected POJO, changes its state to persistent
 void persistSelectedPojo()
          Persists the selected POJO
 boolean selectionChanged()
          Copies the currently selected element on the list into the given model node.
 boolean selectionEmpty()
          Indicates whether the list selection is empty
 void updateBinding()
          Updates the binding of the underlying ListHolder object
 void updateListHolder()
          Marks the source model node as dirty and updates the binding of the underlying list holder object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistentListHelper

public PersistentListHelper(ListHolder lh,
                            PageSupport ps,
                            PersistentPojoModel sm)
Creates a new instance of PersistentListHelper

Parameters:
lh - the ListHolder object whose selection is to be handled.
ps - the owning page of the specified list holder object.
sm - the model node intended to store the selected POJO.

PersistentListHelper

public PersistentListHelper(ListHolder lh,
                            PageSupport ps)
Creates a new instance of PersistentListHelper

Parameters:
lh - the ListHolder object whose selection is to be handled.
ps - the owning page of the specified list holder object.

PersistentListHelper

public PersistentListHelper(ListHolder lh,
                            PageSupport ps,
                            java.lang.String outputPath)
Creates a new instance of PersisentListHelper

Parameters:
lh - the ListHolder object whose selection is to be handled
ps - the owning page of the specified list
outputPath - the binding path to the selection model node which will store the selected POJOs.
Method Detail

getListSelectedModel

public PersistentPojoModel getListSelectedModel()
Gets the selected element on the list

Returns:
selected model node

getSelectionModel

public PersistentPojoModel getSelectionModel()
Gets the selection model

Returns:
selected PersistentPojoModel object or null if nothing is selected

persistSelectedPojo

public void persistSelectedPojo()
Persists the selected POJO


mergeSelectedPojo

public void mergeSelectedPojo()
Merges the selected POJO, changes its state to persistent


deleteSelectedPojo

public void deleteSelectedPojo()
Removes the POJO being stored in the selection model from the persistent context.


clearSelectionModel

public void clearSelectionModel()
Removes the reference to the underlying POJO from the selection model.


selectionChanged

public boolean selectionChanged()
Copies the currently selected element on the list into the given model node. This method should be invoked whenever the selection event of the given list occurs.

Returns:
true if the selected index has actualy changed, false otherwise

selectionEmpty

public boolean selectionEmpty()
Indicates whether the list selection is empty

Returns:
true if nothing is selected, false otherwise

getSelectedPojo

public java.lang.Object getSelectedPojo()
Gets the POJO of the selected model node, if the selection model has been set the its underlying POJO is returned, otherwise the POJO on the underlying list is returned.

Returns:
the selected POJO on the list

clearSelection

public void clearSelection()
Removes the selection from the underlying list holder


updateBinding

public void updateBinding()
Updates the binding of the underlying ListHolder object


updateListHolder

public void updateListHolder()
Marks the source model node as dirty and updates the binding of the underlying list holder object.