to.etc.domui.injector
Class UrlEntityInjector

java.lang.Object
  extended by to.etc.domui.injector.PropertyInjector
      extended by to.etc.domui.injector.UrlEntityInjector

public class UrlEntityInjector
extends PropertyInjector

This property injector takes the named URL parameter as a string. It does a lookup of the entity specified in the MetaData and locates it's ID property. The URL parameter string is then converted to the type of that primary key using the ConverterRegistry's URL converters. Finally it issues a LOOKUP of the entity using that PK. This converter accepts the special value "NEW"; when that is present it constructs a new instance of the entity.

Author:
Frits Jalvingh Created on Dec 19, 2008

Constructor Summary
UrlEntityInjector(java.lang.reflect.Method propertySetter, java.lang.String name, boolean mandatory, java.lang.Class<?> enityClass)
           
 
Method Summary
protected  java.lang.Object createNew(UrlPage page, RequestContextImpl ctx)
          Create a new instance.
protected  java.lang.Object getKeyInstance(QDataContext dc, UrlPage page, java.lang.String pv)
           
protected  java.lang.String getParameterName()
           
protected  java.lang.String getParameterValue(UrlPage page, PageParameters papa)
           
 void inject(UrlPage page, RequestContextImpl ctx, PageParameters papa)
           
protected  boolean isMandatory()
           
protected  boolean isNew(UrlPage page, RequestContextImpl ctx, PageParameters papa, java.lang.String value)
          Returns T if the request is to create a new instance.
 
Methods inherited from class to.etc.domui.injector.PropertyInjector
getPropertySetter, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UrlEntityInjector

public UrlEntityInjector(java.lang.reflect.Method propertySetter,
                         java.lang.String name,
                         boolean mandatory,
                         java.lang.Class<?> enityClass)
Method Detail

getParameterName

protected java.lang.String getParameterName()

isMandatory

protected boolean isMandatory()

getParameterValue

protected java.lang.String getParameterValue(UrlPage page,
                                             PageParameters papa)
                                      throws java.lang.Exception
Throws:
java.lang.Exception

createNew

protected java.lang.Object createNew(UrlPage page,
                                     RequestContextImpl ctx)
Create a new instance.

Returns:

isNew

protected boolean isNew(UrlPage page,
                        RequestContextImpl ctx,
                        PageParameters papa,
                        java.lang.String value)
                 throws java.lang.Exception
Returns T if the request is to create a new instance.

Parameters:
page -
ctx -
papa -
value -
Returns:
Throws:
java.lang.Exception

getKeyInstance

protected java.lang.Object getKeyInstance(QDataContext dc,
                                          UrlPage page,
                                          java.lang.String pv)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

inject

public void inject(UrlPage page,
                   RequestContextImpl ctx,
                   PageParameters papa)
            throws java.lang.Exception
Specified by:
inject in class PropertyInjector
Throws:
java.lang.Exception