ox.system.core.dynamic.concurrent.Callable interface">
ColdBox Platform - LogBox Version 1.5

logbox.system.core.dynamic
Class BeanPopulator

WEB-INF.cftags.component
        extended by logbox.system.core.dynamic.BeanPopulator

public class BeanPopulator
extends WEB-INF.cftags.component

This is a bean populator that binds different types of data to a bean.


Constructor Summary
init()
          Constructor
 
Method Summary
private Util getUtil()
          Create and return a util object
 any populateFromJSON(any target, string JSONString, [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''])
          Populate a named or instantiated bean from a json string
 Any populateFromQuery(any target, query qry, [Numeric rowNumber='1'], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''])
          Populate a named or instantiated bean from query
 any populateFromQueryWithPrefix(any target, query qry, [Numeric rowNumber='1'], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], string prefix)
          Populates an Object using only specific columns from a query
 any populateFromStruct(any target, struct memento, [string scope], [boolean trustedSetter='false'], [string include=''], [string exclude=''])
          Populate a named or instantiated bean from a structure
 any populateFromXML(any target, any xml, [string root=''], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''])
          Populate a named or instantiated bean from an XML packet
 
Methods inherited from class WEB-INF.cftags.component
 

Constructor Detail

init

public init()
Constructor

Method Detail

getUtil

private Util getUtil()
Create and return a util object


populateFromJSON

public any populateFromJSON(any target, string JSONString, [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''])
Populate a named or instantiated bean from a json string

Parameters:
target - The target to populate
JSONString - The JSON string to populate the object with. It has to be valid JSON and also a structure with name-key value pairs.
scope - Use scope injection instead of setters population. Ex: scope=variables.instance.
trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean
include - A list of keys to include in the population
exclude - A list of keys to exclude in the population

populateFromQuery

public Any populateFromQuery(any target, query qry, [Numeric rowNumber='1'], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''])
Populate a named or instantiated bean from query

Parameters:
target - The target to populate
qry - The query to popluate the bean object with
rowNumber - The query row number to use for population
scope - Use scope injection instead of setters population. Ex: scope=variables.instance.
trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean
include - A list of keys to include in the population
exclude - A list of keys to exclude in the population

populateFromQueryWithPrefix

public any populateFromQueryWithPrefix(any target, query qry, [Numeric rowNumber='1'], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], string prefix)
Populates an Object using only specific columns from a query. Useful for performing a query with joins that needs to populate multiple objects.

Parameters:
target - This can be an instantiated bean object or a bean instantitation path as a string. If you pass an instantiation path and the bean has an 'init' method. It will be executed. This method follows the bean contract (set{property_name}). Example: setUsername(), setfname()
qry - The query to popluate the bean object with
rowNumber - The query row number to use for population
scope - Use scope injection instead of setters population. Ex: scope=variables.instance.
trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean
include - A list of keys to include in the population
exclude - A list of keys to exclude in the population
prefix - The prefix used to filter, Example: 'user_' would apply to the following columns: 'user_id' and 'user_name' but not 'address_id'.

populateFromStruct

public any populateFromStruct(any target, struct memento, [string scope], [boolean trustedSetter='false'], [string include=''], [string exclude=''])
Populate a named or instantiated bean from a structure

Parameters:
target - The target to populate
memento - The structure to populate the object with.
scope - Use scope injection instead of setters population.
trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean
include - A list of keys to include in the population
exclude - A list of keys to exclude in the population

populateFromXML

public any populateFromXML(any target, any xml, [string root=''], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''])
Populate a named or instantiated bean from an XML packet

Parameters:
target - The target to populate
xml - The XML string or packet
root - The XML root element to start from
< code>scope - Use scope injection instead of setters population. Ex: scope=variables.instance.
trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean
include - A list of keys to include in the population
exclude - A list of keys to exclude in the population

Callable
ColdBox Platform - LogBox Version 1.5